为什么我无法成功安装RubyGem?

时间:2017-09-24 01:50:28

标签: ruby rubygems

亲爱的Stack Overflow读者,

我遇到了安装RubyGem的问题。我尝试了两种方法来安装它,但都失败了。

首先,我运行sudo command gem install github-pages。 输出如下:


dhcp-128-189-232-78:Repos 7Ymr$ sudo gem install github-pages
Password:
Fetching: public_suffix-2.0.5.gem (100%)
Successfully installed public_suffix-2.0.5
Fetching: addressable-2.5.2.gem (100%)
Successfully installed addressable-2.5.2
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: rb-fsevent-0.10.2.gem (100%)
Successfully installed rb-fsevent-0.10.2
Fetching: ffi-1.9.18.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.18
Fetching: rb-inotify-0.9.10.gem (100%)
Successfully installed rb-inotify-0.9.10
Fetching: sass-listen-4.0.0.gem (100%)
Successfully installed sass-listen-4.0.0
Fetching: sass-3.5.1.gem (100%)
Successfully installed sass-3.5.1
Fetching: jekyll-sass-converter-1.5.0.gem (100%)
Successfully installed jekyll-sass-converter-1.5.0
Fetching: listen-3.0.6.gem (100%)
Successfully installed listen-3.0.6
Fetching: jekyll-watch-1.5.0.gem (100%)
Successfully installed jekyll-watch-1.5.0
Fetching: kramdown-1.13.2.gem (100%)
Successfully installed kramdown-1.13.2
Fetching: liquid-4.0.0.gem (100%)
ERROR:  Error installing github-pages:
    liquid requires Ruby version >= 2.1.0.
#>                               ^

然后,我也尝试从rubygems网站下载并安装。我下载了最新版本并运行install命令,但也有一些错误。


dhcp-128-189-232-78:downloads 7Ymr$ cd rubygems-2.6.13/
dhcp-128-189-232-78:rubygems-2.6.13 7Ymr$ ruby setup.rb
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Library/Ruby/Site/2.0.0/rubygems
#>                                   ^                              ^

我在网上搜索了很长时间。但没用。请帮助或尝试提供一些如何实现这一点的想法。想知道最好的方法是什么?

提前致谢。

1 个答案:

答案 0 :(得分:1)

错误非常清楚。在第一种情况下,您的Ruby版本对于需要安装的液体版本来说太旧了。运行ruby --version以查找系统默认使用的Ruby版本。您需要更新到Ruby 2.1.0或更高版本才能安装liquid,这是您尝试安装的github-pages gem的必需依赖项。

在第二种情况下,Ruby没有写入该文件夹的权限。 "许可被拒绝"错误几乎总是意味着您忘记使用管理权限运行命令。在这种情况下,您应该运行sudo ruby setup.rb