无法使用 ASDF 安装 gem



所以我正在切换到一个使用 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

听起来您可能需要将相关行添加到.zshrc以便识别 asdf 填充程序。您可以在此处找到说明

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

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

执行此操作后,source ~/.zshrc或重新启动终端

相关内容

  • 没有找到相关文章

最新更新