在 vanilla ubuntu 上安装 Gem 失败 - EACCESS

在 vanilla ubuntu 上安装 Gem 失败 - EACCESS

我正在尝试在完全通用的 Ubuntu Trusty (i386) 安装上安装 Middleman gem。这是我的控制台输入/输出:

vagrant@vagrant-ubuntu-trusty-32:~/rj$ which ruby
/usr/bin/ruby
vagrant@vagrant-ubuntu-trusty-32:~/rj$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
vagrant@vagrant-ubuntu-trusty-32:~/rj$ gem install middleman
Fetching: bundler-1.7.7.gem (100%)
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems

如您所见,我在主机系统上收到类似错误后使用了 Vagrant VM。(之前别人的问题的另一个答案让我想到了 Vagrant 和 Docker,它们都给出了类似上述行的输出。)有趣的是,即使使用也sudo gem install middleman给我带来了问题。

(我考虑过把这个输出粘贴到这里,如果有人问起我可能还是会这么做,但说实话,如果可能的话,我宁愿避免以 root 身份安装外部 gem,而是更愿意关注上面的错误。毕竟,中间人的全部意义在于创建一组定义的平面输出,限制对特权和自定义的需求。)

以前有人遇到过类似的错误吗?

======================

编辑:根据要求,这是我使用时的输出sudo gem install middleman

Fetching: bundler-1.7.7.gem (100%)
Fetching: rack-1.5.2.gem (100%)
Fetching: tilt-1.4.1.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: uber-0.0.11.gem (100%)
Fetching: hooks-0.4.0.gem (100%)
Fetching: rack-test-0.6.2.gem (100%)
Fetching: thor-0.19.1.gem (100%)
Fetching: i18n-0.6.11.gem (100%)
Fetching: json-1.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing middleman:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'

Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out

答案1

听起来您需要运行这个 gem install,sudo因为它使用受限的系统文件夹。

错误:执行 gem 时...(Errno::EACCES)权限被拒绝 - /var/lib/gems

尝试这样做:

sudo gem install middleman

相关内容