$ 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"
答案 0 :(得分:2)
我建议使用rvm
或rbenv
。否则,您将最终获得多个红宝石,并且无法对其进行任何控制。
这将非常混乱。您只是遇到了麻烦!