0
$ 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

Question: why bundle command not found?

With $ gem content bundler I found bundle executable file:

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

Bundler version 1.16.4

Why bundle executable isn't in /usr/local/opt/ruby@2.3/bin?

I see Bundle command not found mac question, must I use rbenv? I can't just use brew install ruby@2.3?

More information:

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

And :

$ 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"
Casper
  • 33,403
  • 4
  • 84
  • 79
Stéphane Klein
  • 856
  • 1
  • 11
  • 20
  • macOS comes with its own version of ruby as well, so bundler gem may be installing for one version and not the other. Check out using rbenv, it makes working with multiple versions of ruby easier. https://github.com/rbenv/rbenv – Hayden Sep 02 '18 at 22:45

1 Answers1

4

I'd recommend using rvm or rbenv. otherwise you will end up with multiple rubies without any control on them and their different contexts.

It'll be very messy. You just hit the start of this mess!

Tarek N. Elsamni
  • 1,718
  • 1
  • 12
  • 15