6

So I'm switching to a project that is using ruby. They use asdf as a package manager

I’m having trouble installing the gems, I’m using zsh and I’m thinking there might be an issue with the paths

Running gem install bundler outputs: You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

ruby -v outputs: ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

which ruby output: /usr/bin/ruby

And I tried setting a global version for ruby with asdf global ruby 2.5.3 but that doesn’t seem to change the version

This is my gem environment:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.2.3
  - RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
  - USER INSTALLATION DIRECTORY: /Users/carlos.grijalva/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /Users/carlos.grijalva/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-18
  - GEM PATHS:
     - /Library/Ruby/Gems/2.3.0
     - /Users/carlos.grijalva/.gem/ruby/2.3.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/carlos.grijalva/.asdf/shims
     - /Users/carlos.grijalva/.asdf/bin
     - /Users/carlos.grijalva/bin
     - /usr/local/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
Flux
  • 9,805
  • 5
  • 46
  • 92
CarlosG90
  • 165
  • 1
  • 9

1 Answers1

5

It sounds like you may need to add the relevant lines to your .zshrc so asdf shims get recognized. You can find the instructions here

For macOS & zsh the correct lines to append to .zshrc are:

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc

After doing so, either source ~/.zshrc or restart your terminal

Jay Dorsey
  • 3,563
  • 2
  • 18
  • 24
  • Saw that too and ran those exact commands. For some reason I'm still getting: `You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.` And I can't seem to change the version of ruby with `asdf`. Not sure what else could be happening – CarlosG90 May 28 '19 at 17:44
  • @CarlosG90 Did you open a new terminal so they're actually in effect? All those commands do is modify your startup script. – Dave Newton May 28 '19 at 18:10
  • Yeah, modified and ran `source ~/.zshrc` also checked the actual file is changed and restarted the terminal multiple times. Ruby version doesn't seem to change. – CarlosG90 May 28 '19 at 18:36
  • @CarlosG90 can you run `which ruby`, `which asdf`, `which gem` and post the results? Also, inspect your $PATH and see where `/Users/username/asdf` folders are in relation to `/usr/bin` (`/usr/bin` is where the system ruby/gem commands are kept) – Jay Dorsey May 28 '19 at 19:57
  • 1
    it seems that the paths were incorrect, I was able to add them and the shims are there now! Thanks! – CarlosG90 May 28 '19 at 21:01