【问题标题】:"brew install ruby@2.3" + "gem install bundler" => why bundle command not found?“brew install ruby​​@2.3” + “gem install bundler” => 为什么找不到 bundle 命令?
【发布时间】:2019-02-08 00:26:44
【问题描述】:
$ brew install ruby@2.3
...
$ echo 'export PATH="/usr/local/opt/ruby@2.3/bin:$PATH"' >> ~/.zshrc
$ zsh
$ ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin17]
$ gem install bundler
Successfully installed bundler-1.16.4
Parsing documentation for bundler-1.16.4
Done installing documentation for bundler after 4 seconds
1 gem installed
$ bundle
zsh: command not found: bundle

问题:为什么找不到bundle 命令?

$ gem content bundler我找到了bundle的可执行文件:

$ /usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.16.4/exe/bundle --version

捆绑器版本 1.16.4

为什么bundle 可执行文件不在/usr/local/opt/ruby@2.3/bin 中?

我看到Bundle command not found mac 的问题,我必须使用rbenv 吗?我不能只使用brew install ruby@2.3

更多信息:

$ brew --version
Homebrew 1.7.2-112-g0dc2c72
Homebrew/homebrew-core (git revision bc34; last commit 2018-09-02)

还有:

$ brew info ruby@2.3
ruby@2.3: stable 2.3.7 (bottled) [keg-only]
Powerful, clean, object-oriented scripting language
https://www.ruby-lang.org/
/usr/local/Cellar/ruby@2.3/2.3.7 (15,093 files, 38.3MB)
  Poured from bottle on 2018-09-02 at 19:44:13
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ruby@2.3.rb
==> Dependencies
Build: pkg-config ✔
Required: libyaml ✔, openssl ✔, readline ✔
==> Caveats
By default, binaries installed by gem will be placed into:
  /usr/local/lib/ruby/gems/2.3.0/bin

You may want to add this to your PATH.

ruby@2.3 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have ruby@2.3 first in your PATH run:
  echo 'export PATH="/usr/local/opt/ruby@2.3/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby@2.3 you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby@2.3/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby@2.3/include"

For pkg-config to find ruby@2.3 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/ruby@2.3/lib/pkgconfig"

【问题讨论】:

  • macOS 也带有自己的 ruby​​ 版本,因此 bundler gem 可能正在安装一个版本而不是另一个版本。使用 rbenv 进行检查,它可以更轻松地使用多个版本的 ruby​​。 github.com/rbenv/rbenv

标签: ruby macos bundler


【解决方案1】:

我建议使用rvmrbenv。否则,您最终会得到多个红宝石,而无法控制它们及其不同的上下文。

会很乱。你刚刚开始这个烂摊子!

【讨论】:

  • rbenv 比必须 brew 安装特定的 ruby​​ 版本要简单得多。
猜你喜欢
  • 1970-01-01
  • 2016-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-02
相关资源
最近更新 更多