为什么不安装nokogiri?[英] Why doesn't nokogiri install?

本文是小编为大家收集整理的关于为什么不安装nokogiri?的处理方法,想解了为什么不安装nokogiri?的问题怎么解决?为什么不安装nokogiri?问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我在 Ubuntu 12.04 上安装 Nokogiri 时遇到了麻烦.我使用 rbenv.

    $ gem install nokogiri -v '1.6.1'
    ERROR:  While executing gem ... (Errno::EACCES)
        Permission denied - /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1/.autotest

    $ sudo gem install nokogiri -v '1.6.1'
    ERROR:  Error installing nokogiri:
        nokogiri requires Ruby version >= 1.9.2.

    $ rbenv sudo gem install nokogiri -v '1.6.1'
    Building native extensions.  This could take a while...
    ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

        /home/deploy/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb

    Gem files will remain installed in /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
    Results logged to /home/deploy/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out

    $ ruby -v
    ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

    $ sudo ruby -v
    ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

    $ rbenv sudo ruby -v 
    ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

    $ echo $PATH
    /home/deploy/.rbenv/bin:/home/deploy/.rbenv/bin:/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

看来我需要一些方法让 sudo ruby -v 给我 2.0.0.我错过了什么?

推荐答案

当你用 rbenv 做 gem install 时你不应该需要 sudo.不幸的是,新安装时 .rbenv 目录的所有权通常不正确.

首先要正确设置您的权限:

sudo chown -R $USER "$HOME/.rbenv"

然后继续并再次运行安装:

gem install nokogiri -v '1.6.1'

它应该在没有 sudo 的情况下工作.

本文地址:https://www.itbaoku.cn/post/786806.html