I'm running bundle install
and I'm getting this error:
我正在运行捆绑安装,我得到了这个错误:
Building nokogiri using system libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
--with-pkg-config
--without-pkg-config
extconf failed, exit code 1
Gem files will remain installed in /Users/myuser/projectpath/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.2.rc2 for inspection.
Results logged to /Users/myuser/projectpath/vendor/bundle/ruby/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.2.rc2/gem_make.out
An error occurred while installing nokogiri (1.6.2.rc2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.rc2'` succeeds before bundling.
Any ideas what could this be?
有什么想法吗?
EDIT:
I also have installed nokogiri following the instructions in the tutorial, and the weird thing is that the gem was successfully installed. When I run gem list
, I have nokogiri (1.6.2.1)
, but when running bundle install
it displays the error.
我还按照教程中的说明安装了nokogiri,奇怪的是gem被成功安装了。当我运行gem列表时,我有nokogiri(1.6.2.1),但是当运行bundle install时,它会显示错误。
16 个解决方案
#1
221
Advises above didn't help me, here is the solution for OS 10.9:
以上的建议对我没有帮助,以下是OS 10.9的解决方案:
brew install libxml2
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
bundle install
#2
50
On Mavericks this workaround worked for me:
在小牛身上,这个变通方法对我起了作用:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
See: https://github.com/sparklemotion/nokogiri/issues/1099#issuecomment-43023208
参见:https://github.com/sparklemotion/nokogiri/issues/1099 # issuecomment - 43023208
#3
14
On Amazon Linux, I had to install these two devel libraries, and then specify the include path for libxml2
在Amazon Linux上,我必须安装这两个devel库,然后指定libxml2的include路径
$ yum install libxml2-devel libxslt-devel
$ gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2/
#4
4
I also had some problems installing nokogiri, Than I installed following packages, It worked for me:
我在安装nokogiri时也遇到了一些问题,比我安装了以下的软件包,它对我很有用:
libxslt-dev
libxml2-dev
libruby1.8
libreadline-ruby1.8
libopenssl-ruby
libxml2
I am not sure, which one was exactly needed.
我不确定到底需要哪一个。
#5
3
http://nokogiri.org/tutorials/installing_nokogiri.html. Refer to this link and install the dependencies required for nokogiri. Then run this
http://nokogiri.org/tutorials/installing_nokogiri.html。请参考此链接并安装nokogiri所需的依赖项。然后运行这个
bundle config build.nokogiri --use-system-libraries
- 包配置构建。nokogiri——use-system-libraries
bundle install
- 包安装
#6
2
On Yosemite 10.10.1, this step did not help (may be it works for others)
在Yosemite 10.10.1中,这个步骤没有帮助(可能对其他人有用)
gem install nokogiri -- --use-system-libraries
Basically issue on my local was due to libxml2
, so following workaround did the trick
我的本地问题主要是由于libxml2引起的,因此遵循解决方案就可以解决这个问题
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2
bundle install
#7
2
This worked for OS X El Capitan:
这对操作系统X El Capitan是有效的:
brew install libxml2 libxslt libiconv
After running the'brew install libxml2 libxslt libiconv ' You may find, that they are already installed. No worries, it never hurts to double check.
在运行“brew安装libxml2 libxslt libiconv”之后,您可能会发现它们已经安装好了。不用担心,再检查一下也无妨。
sudo gem install nokogiri -v '1.6.7' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
bundle install
Change the version of nokogiri, if needed. e.g.
如果需要,更改nokogiri的版本。如。
sudo gem install nokogiri -v '1.6.5' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
#8
1
The error states that your libxml2 system library is out of date. You need version 2.6.21 or later.
错误表明libxml2系统库已经过时。您需要版本2.6.21或更高版本。
On my Debian/ubuntu system, nokogiri compiles for me, and I can see I have version 2.9.1
在我的Debian/ubuntu系统上,nokogiri为我编译,我可以看到我有2.9.1版
dpkg -l | grep libxml2-dev
ii libxml2-dev:amd64 2.9.1+dfsg1-3 amd64 Development files for the GNOME XML library
You have three options here.
这里有三个选项。
-
Check if your OS package manager provides a newer version of libxml2 library
检查您的OS包管理器是否提供了libxml2库的更新版本
-
Download the latest libxml2 source code, compile and install it
下载最新的libxml2源代码,编译并安装它
- Manually specify an older version of nokogiri in your Gemfile that works with older libxml2 library. The nokogiri changelog shows that you won't have this problem with nokogiri version 1.4.7 (although using an older version can expose you to security issues)
- 在Gemfile中手动指定使用旧libxml2库的旧版本nokogiri。nokogiri changelog显示您不会遇到nokogiri 1.4.7版本的问题(尽管使用旧版本会使您暴露于安全问题)
For solution #3, you would put this in your gemfile: gem 'nokogiri', '1.4.7'
对于解决方案#3,您可以将其放入gemfile: gem 'nokogiri', '1.4.7'
#9
1
On Yosemite 10.10 the following steps solved my issues completely:
在约塞米蒂10.10上,以下步骤完全解决了我的问题:
sudo xcode-select -switch /Library/Developer/CommandLineTools
- sudo xcode-select开关/图书馆/开发/ CommandLineTools
gem uninstall nokogiri libxml-ruby
- 宝石卸载nokogiri libxml-ruby
gem install nokogiri
- gem安装nokogiri
#10
1
For mac, the reason why it failed is that you didn't have latest Xcode Developer Tools. Nokogiri has already been packaged with libxml2. For the lack of latest Xcode Developer Tools, it can't build native extensions.
对于mac来说,失败的原因是您没有最新的Xcode开发工具。Nokogiri已经打包了libxml2。由于缺乏最新的Xcode开发工具,它不能构建本机扩展。
To update Xcode Developer Tools using:
更新Xcode开发者工具:
xcode-select --install
And then:
然后:
gem install nokogiri
If you fix it by using
如果你用
gem install nokogiri -- --use-system-libraries
may get a similar warning later:
以后可能会得到类似的警告:
WARNING: Nokogiri was built against LibXML version 2.9.3, but has dynamically loaded 2.9.0
#11
0
This thread on GitHub gave me the trick I needed get Nokogiri 1.6.2 to install:
GitHub上的这个线程给了我一个诀窍,让Nokogiri 1.6.2安装:
My ~/.gitconfig had the setting
autocrlf = input
. When I remove this setting the nokogiri build succeeds.我的~ /。gitconfig有一个设置为authorlf = input。当我删除此设置时,nokogiri构建成功。
#12
0
On Yosemite 10.10 this workaround worked for me:
在约塞米蒂10.10中,这个方法对我起了作用:
gem install nokogiri -- --use-system-libraries
#13
0
For #CentOS I needed to do the following:
对于#CentOS,我需要做以下事情:
gem update --system
yum install libxml2-devel libxslt-devel ruby-devel
gem install nokogiri -- --use-system-libraries
#14
0
This is an old thread, but I hit similar issues, and the solution in my case was quite different to those posted so far.
这是一个旧的线程,但我遇到了类似的问题,我的解决方案与到目前为止发布的解决方案非常不同。
After some digging, I found this thread: https://github.com/bundler/bundler/issues/2648#issuecomment-25124800
经过一些挖掘,我找到了这个线程:https://github.com/bundler/bundler/issues/2648#issue -25124800
It talks about bundler using a different version of ruby to that used by gem.
它讲述的是bundler使用的ruby版本的不同版本。
From OP's paste, we can see bundler is using the Mac system copy of ruby: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
从OP的粘贴中,我们可以看到bundler正在使用ruby: / system /Library/ framework/ ruby .framework/ version /2.0/usr/bin/ruby的Mac系统拷贝
In my case I found that gem was coming from brew; which gem
gave /usr/local/bin/gem
which symlinks to /Cellar/ruby/2.3.3/bin/gem
. My guess is that the OP's case was the same.
在我的案例中,我发现gem来自brew;哪个gem为/usr/local/bin/gem提供了/Cellar/ruby/2.3.3/bin/gem ?我猜OP的情况是一样的。
So, gem and bundler are not working off the same ruby installation, which explains why the OP sees this:
因此,gem和bundler并没有使用相同的ruby安装,这就解释了为什么OP会看到以下情况:
When I run gem list, I have nokogiri (1.6.2.1), but when running bundle install it displays the error.
当我运行gem列表时,我有nokogiri(1.6.2.1),但是当运行bundle install时,它会显示错误。
In my case, I simply ran gem install bundler
, which made bundler start using the brew version of ruby, and all problems disappeared.
在我的例子中,我只是运行gem安装bundler,它使bundler开始使用brew版本的ruby,所有的问题都消失了。
#15
0
On OSX 10.12 (Sierra) this worked for me:
在OSX 10.12 (Sierra)上,这对我很有效:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
gem安装nokogiri -- -use-system-libraries=true -xml2-include=/ application /Xcode.app/ content /Developer/ Developer/ platform/ MacOSX.platform/Developer/SDKs/ macosx10.12 sdk/usr/include/libxml2
#16
0
I had this exact issue. I run a rails environment on a mac. After I upgraded from Yosemite to Sierra I believe thats when it started.
我有这个问题。我在mac上运行一个rails环境。当我从Yosemite升级到Sierra之后,我相信这就是它的开始。
To fix the problem I just had to install xcode command line tools
. I don't know if the Sierra upgrade removed them or what.
为了解决这个问题,我只需安装xcode命令行工具。我不知道Sierra升级项目是否删除了它们。
xcode-select --install
xcode-select——安装
(this will install the xcode command line tools
)
(这将安装xcode命令行工具)
Also another symptom..things like git status won't work. After this i was able to do rails new appname and it was fine.
另一个症状。git状态之类的东西不会起作用。在此之后,我就可以执行rails的新appname了。
#1
221
Advises above didn't help me, here is the solution for OS 10.9:
以上的建议对我没有帮助,以下是OS 10.9的解决方案:
brew install libxml2
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
bundle install
#2
50
On Mavericks this workaround worked for me:
在小牛身上,这个变通方法对我起了作用:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
See: https://github.com/sparklemotion/nokogiri/issues/1099#issuecomment-43023208
参见:https://github.com/sparklemotion/nokogiri/issues/1099 # issuecomment - 43023208
#3
14
On Amazon Linux, I had to install these two devel libraries, and then specify the include path for libxml2
在Amazon Linux上,我必须安装这两个devel库,然后指定libxml2的include路径
$ yum install libxml2-devel libxslt-devel
$ gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2/
#4
4
I also had some problems installing nokogiri, Than I installed following packages, It worked for me:
我在安装nokogiri时也遇到了一些问题,比我安装了以下的软件包,它对我很有用:
libxslt-dev
libxml2-dev
libruby1.8
libreadline-ruby1.8
libopenssl-ruby
libxml2
I am not sure, which one was exactly needed.
我不确定到底需要哪一个。
#5
3
http://nokogiri.org/tutorials/installing_nokogiri.html. Refer to this link and install the dependencies required for nokogiri. Then run this
http://nokogiri.org/tutorials/installing_nokogiri.html。请参考此链接并安装nokogiri所需的依赖项。然后运行这个
bundle config build.nokogiri --use-system-libraries
- 包配置构建。nokogiri——use-system-libraries
bundle install
- 包安装
#6
2
On Yosemite 10.10.1, this step did not help (may be it works for others)
在Yosemite 10.10.1中,这个步骤没有帮助(可能对其他人有用)
gem install nokogiri -- --use-system-libraries
Basically issue on my local was due to libxml2
, so following workaround did the trick
我的本地问题主要是由于libxml2引起的,因此遵循解决方案就可以解决这个问题
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2
bundle install
#7
2
This worked for OS X El Capitan:
这对操作系统X El Capitan是有效的:
brew install libxml2 libxslt libiconv
After running the'brew install libxml2 libxslt libiconv ' You may find, that they are already installed. No worries, it never hurts to double check.
在运行“brew安装libxml2 libxslt libiconv”之后,您可能会发现它们已经安装好了。不用担心,再检查一下也无妨。
sudo gem install nokogiri -v '1.6.7' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
bundle install
Change the version of nokogiri, if needed. e.g.
如果需要,更改nokogiri的版本。如。
sudo gem install nokogiri -v '1.6.5' -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib
#8
1
The error states that your libxml2 system library is out of date. You need version 2.6.21 or later.
错误表明libxml2系统库已经过时。您需要版本2.6.21或更高版本。
On my Debian/ubuntu system, nokogiri compiles for me, and I can see I have version 2.9.1
在我的Debian/ubuntu系统上,nokogiri为我编译,我可以看到我有2.9.1版
dpkg -l | grep libxml2-dev
ii libxml2-dev:amd64 2.9.1+dfsg1-3 amd64 Development files for the GNOME XML library
You have three options here.
这里有三个选项。
-
Check if your OS package manager provides a newer version of libxml2 library
检查您的OS包管理器是否提供了libxml2库的更新版本
-
Download the latest libxml2 source code, compile and install it
下载最新的libxml2源代码,编译并安装它
- Manually specify an older version of nokogiri in your Gemfile that works with older libxml2 library. The nokogiri changelog shows that you won't have this problem with nokogiri version 1.4.7 (although using an older version can expose you to security issues)
- 在Gemfile中手动指定使用旧libxml2库的旧版本nokogiri。nokogiri changelog显示您不会遇到nokogiri 1.4.7版本的问题(尽管使用旧版本会使您暴露于安全问题)
For solution #3, you would put this in your gemfile: gem 'nokogiri', '1.4.7'
对于解决方案#3,您可以将其放入gemfile: gem 'nokogiri', '1.4.7'
#9
1
On Yosemite 10.10 the following steps solved my issues completely:
在约塞米蒂10.10上,以下步骤完全解决了我的问题:
sudo xcode-select -switch /Library/Developer/CommandLineTools
- sudo xcode-select开关/图书馆/开发/ CommandLineTools
gem uninstall nokogiri libxml-ruby
- 宝石卸载nokogiri libxml-ruby
gem install nokogiri
- gem安装nokogiri
#10
1
For mac, the reason why it failed is that you didn't have latest Xcode Developer Tools. Nokogiri has already been packaged with libxml2. For the lack of latest Xcode Developer Tools, it can't build native extensions.
对于mac来说,失败的原因是您没有最新的Xcode开发工具。Nokogiri已经打包了libxml2。由于缺乏最新的Xcode开发工具,它不能构建本机扩展。
To update Xcode Developer Tools using:
更新Xcode开发者工具:
xcode-select --install
And then:
然后:
gem install nokogiri
If you fix it by using
如果你用
gem install nokogiri -- --use-system-libraries
may get a similar warning later:
以后可能会得到类似的警告:
WARNING: Nokogiri was built against LibXML version 2.9.3, but has dynamically loaded 2.9.0
#11
0
This thread on GitHub gave me the trick I needed get Nokogiri 1.6.2 to install:
GitHub上的这个线程给了我一个诀窍,让Nokogiri 1.6.2安装:
My ~/.gitconfig had the setting
autocrlf = input
. When I remove this setting the nokogiri build succeeds.我的~ /。gitconfig有一个设置为authorlf = input。当我删除此设置时,nokogiri构建成功。
#12
0
On Yosemite 10.10 this workaround worked for me:
在约塞米蒂10.10中,这个方法对我起了作用:
gem install nokogiri -- --use-system-libraries
#13
0
For #CentOS I needed to do the following:
对于#CentOS,我需要做以下事情:
gem update --system
yum install libxml2-devel libxslt-devel ruby-devel
gem install nokogiri -- --use-system-libraries
#14
0
This is an old thread, but I hit similar issues, and the solution in my case was quite different to those posted so far.
这是一个旧的线程,但我遇到了类似的问题,我的解决方案与到目前为止发布的解决方案非常不同。
After some digging, I found this thread: https://github.com/bundler/bundler/issues/2648#issuecomment-25124800
经过一些挖掘,我找到了这个线程:https://github.com/bundler/bundler/issues/2648#issue -25124800
It talks about bundler using a different version of ruby to that used by gem.
它讲述的是bundler使用的ruby版本的不同版本。
From OP's paste, we can see bundler is using the Mac system copy of ruby: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
从OP的粘贴中,我们可以看到bundler正在使用ruby: / system /Library/ framework/ ruby .framework/ version /2.0/usr/bin/ruby的Mac系统拷贝
In my case I found that gem was coming from brew; which gem
gave /usr/local/bin/gem
which symlinks to /Cellar/ruby/2.3.3/bin/gem
. My guess is that the OP's case was the same.
在我的案例中,我发现gem来自brew;哪个gem为/usr/local/bin/gem提供了/Cellar/ruby/2.3.3/bin/gem ?我猜OP的情况是一样的。
So, gem and bundler are not working off the same ruby installation, which explains why the OP sees this:
因此,gem和bundler并没有使用相同的ruby安装,这就解释了为什么OP会看到以下情况:
When I run gem list, I have nokogiri (1.6.2.1), but when running bundle install it displays the error.
当我运行gem列表时,我有nokogiri(1.6.2.1),但是当运行bundle install时,它会显示错误。
In my case, I simply ran gem install bundler
, which made bundler start using the brew version of ruby, and all problems disappeared.
在我的例子中,我只是运行gem安装bundler,它使bundler开始使用brew版本的ruby,所有的问题都消失了。
#15
0
On OSX 10.12 (Sierra) this worked for me:
在OSX 10.12 (Sierra)上,这对我很有效:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
gem安装nokogiri -- -use-system-libraries=true -xml2-include=/ application /Xcode.app/ content /Developer/ Developer/ platform/ MacOSX.platform/Developer/SDKs/ macosx10.12 sdk/usr/include/libxml2
#16
0
I had this exact issue. I run a rails environment on a mac. After I upgraded from Yosemite to Sierra I believe thats when it started.
我有这个问题。我在mac上运行一个rails环境。当我从Yosemite升级到Sierra之后,我相信这就是它的开始。
To fix the problem I just had to install xcode command line tools
. I don't know if the Sierra upgrade removed them or what.
为了解决这个问题,我只需安装xcode命令行工具。我不知道Sierra升级项目是否删除了它们。
xcode-select --install
xcode-select——安装
(this will install the xcode command line tools
)
(这将安装xcode命令行工具)
Also another symptom..things like git status won't work. After this i was able to do rails new appname and it was fine.
另一个症状。git状态之类的东西不会起作用。在此之后,我就可以执行rails的新appname了。