geminstall时权限问题的修正
进⾏gem install时,如果报如下权限错误:
$ gem install jekyll bundler
gem install jekyll bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
可尝试下⾯这些解决⽅式。
--user-install
根据,似乎加上--user-install参数就可以修正:
gem install name_of_gem --user-install
修正 PATH
如果实测发现仍然不⾏:
$ gem install jekyll bundler --user-install
WARNING: You don't have /Users/wayongliu/.gem/ruby/2.6.0/bin in your PATH,
gem executables will not run.
Building native extensions. This could take
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
…
不过这⾥的错误信息提⽰变了,和 PATH 有关,于是根据,修正⼀个 PATH:
$ PATH="`ruby -e 'puts Gem.user_dir'`/bin:$PATH"
fish 环境使⽤如下命令:
$ set PATH "`ruby -e 'puts Gem.user_dir'`/bin:$PATH"
或者添加如下命令到 shell 配置⽂件中:
set -gx PATH ~/.gem/ruby/2.6.0/bin $PATH
重装 Ruby
如果仍然不⾏,可以尝试使⽤ brew 重装 Ruby,抛弃 mac ⾃带的版本。安装过程输出的信息会有如下提⽰:By default, binaries installed by gem will be placed into:
/usr/local/lib/ruby/gems/2.7.0/bin
You may want to add this to your PATH.
ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have ruby first in your PATH run:
echo 'set -g fish_user_paths "/usr/local/opt/ruby/bin" $fish_user_paths' >> ~/.config/fish/config.fish
For compilers to find ruby you may need to set:
set -gx LDFLAGS "-L/usr/local/opt/ruby/lib"
set -gx CPPFLAGS "-I/usr/local/opt/ruby/include"
For pkg-config to find ruby you may need to set:
set -gx PKG_CONFIG_PATH "/usr/local/opt/ruby/lib/pkgconfig"
根据提⽰,添加相应脚本的 shell 的配置中。
echo 'set -g fish_user_paths "/usr/local/opt/ruby/bin" $fish_user_paths' >> ~/.config/fish/config.fish
刷新配置:
$ source ~/.config/fig
然后再执⾏ gem 安装相关的命令,应该就解决了。
$ gem install --user-install bundler jekyll
Fetching public_suffix-4.
Fetching i18n-1.
Fetching eventmachine-1.
Fetching eventmachine-1.
Fetching http_parser.rb-0.
Fetching colorator-1.
Fetching addressable-2.
Fetching concurrent-ruby-1.
Fetching em-websocket-0.
…
rubyinstaller安装检查安装:
$ jekyll -v
jekyll 4.1.1
如果报 jekyll 命令不到,检查 shell 配置中是 PATH 是否配置正确,见上⾯步骤。
以上。
The text was updated successfully, but these errors were encountered:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论