Can't install gems using asdf
Asked Answered
G

1

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
Glaring answered 28/5, 2019 at 16:47 Comment(4)
Seems like an asdf installation/etc issue. Did you add the asdf lines to your shell startup?Azrael
Hmm, should that be done in the .zshrc file? Not sure where to add the linesGlaring
Yes, since that's your startup file. When you install asdf it actually says what to do. I'm not saying it's the (or only) issue, but... you do actually need to give asdf access to your shims/etc.Azrael
Hmm, trying to figure out what exact lines to add for this...Glaring
B
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

Baines answered 28/5, 2019 at 17:39 Comment(5)
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 happeningGlaring
@Glaring Did you open a new terminal so they're actually in effect? All those commands do is modify your startup script.Azrael
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.Glaring
@Glaring 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)Baines
it seems that the paths were incorrect, I was able to add them and the shims are there now! Thanks!Glaring

© 2022 - 2024 — McMap. All rights reserved.