无法使用asdf安装gems

时间:2019-05-28 16:47:23

标签: ruby asdf

所以我要切换到使用ruby的项目。他们使用asdf作为包管理器

我在安装gem时遇到问题,我在使用zsh,并且认为路径可能有问题

运行gem install bundler输出:You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

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

which ruby 输出:/usr/bin/ruby

我尝试使用asdf global ruby 2.5.3为ruby设置全局版本,但这似乎并没有改变版本

这是我的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

1 个答案:

答案 0 :(得分:0)

听起来您可能需要将相关行添加到.zshrc中,以便识别asdf垫片。您可以找到说明here

对于macOS和zsh,添加到.zshrc的正确行是:

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

这样做之后,source ~/.zshrc或重新启动您的终端