Nokogiri(1.6.2)加载错误,ruby 2.0,rails 4.1.1

Pee*_*151 2 ruby ruby-on-rails paperclip

这真让我抓狂...

我在这里看到了几个问题与nokogiri(一个在这里),但它们与脚本有关.我有一个完整的rails应用程序,我刚刚安装了paperclip和amazon-aws,当我进行捆绑安装时也下载了nokogiri ..

gem dependency paperclip
...
nokogiri (>= 0, development)
...
Run Code Online (Sandbox Code Playgroud)

这就是这个宝石被引入的地方..

我读到Nokogiri应该在我的gemfile中,所以我做了一个

gemfile.rb =>

gem 'nokogiri'
gem 'aws-sdk'
gem 'paperclip'
Run Code Online (Sandbox Code Playgroud)

现在我的本地服务器无法启动...

nokogiri-1.6.2.1/lib/nokogiri.rb:29:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
Run Code Online (Sandbox Code Playgroud)

我也尝试过nokogiri 1.4.4 ......

以前(在我的gemfile中没有nokogiri)服务器会加载,但是当我尝试上传图像时会出现加载错误...同上面的错误

cannot load such file -- nokogiri/nokogiri
Run Code Online (Sandbox Code Playgroud)

关于nokogiri的thotbot/paperclip文档中没有任何内容.我试过了

gem install nokogiri
Run Code Online (Sandbox Code Playgroud)

gem pristine nokogiri
Run Code Online (Sandbox Code Playgroud)

没有骰子..

我在捆绑上注意到这条消息:

        IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

        If this is a concern for you and you want to use the system library
        instead, abort this installation process and reinstall nokogiri as
        follows:

            gem install nokogiri -- --use-system-libraries

        If you are using Bundler, tell it to use the option:

            bundle config build.nokogiri --use-system-libraries
            bundle install

        However, note that nokogiri does not necessarily support all versions
        of libxml2.

        For example, libxml2-2.9.0 and higher are currently known to be broken
        and thus unsupported by nokogiri, due to compatibility problems and
        XPath optimization bugs.
Run Code Online (Sandbox Code Playgroud)

所以我做到了

bundle config build.nokogiri --use-system-libraries
bundle install
Run Code Online (Sandbox Code Playgroud)

我得到了同样的错误.所以我的智慧结束了.有什么建议?

****编辑:****

我认为这是与AWS-SDK gem的交互,不确定.他们在13年11月放弃了对旧版本的支持,但我正在使用它

gem 'aws-sdk', '~> 1.0'
gem 'nokogiri', '~> 1.5.0'
Run Code Online (Sandbox Code Playgroud)

感叹我也试过Nokogiri.org的安装方法......

brew install libxml2 libxslt
brew link libxml2 libxslt

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 
Run Code Online (Sandbox Code Playgroud)

仍有问题.Nokogiri Nokogiri !!!

Lou*_*tti 6

我遇到了同样的问题.

我不得不安装

gem pristine nokogiri
Run Code Online (Sandbox Code Playgroud)

然后我跑了

bundle config build.nokogiri --use-system-libraries
bundle install
Run Code Online (Sandbox Code Playgroud)

然后得到了

Restored nokogiri-1.6.2.1
Building native extensions with: '--use-system-libraries'
This could take a while...
Building nokogiri using system libraries.
Restored nokogiri-1.6.3.1
Run Code Online (Sandbox Code Playgroud)

这似乎解决了我的问题,希望这有帮助!