ruby 如何在 Mac OS Sierra 10.12 上安装 Nokogiri
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40038953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install Nokogiri on Mac OS Sierra 10.12
提问by Julian Popov
I'm having troubles installing Nokogiri (1.6.8.1) on Mac OS Sierra 10.12.
我在 Mac OS Sierra 10.12 上安装 Nokogiri (1.6.8.1) 时遇到问题。
I tried using brew install libxml2 libxsltand then referencing the install directories using command line options but it didn't help.
我尝试使用brew install libxml2 libxslt,然后使用命令行选项引用安装目录,但没有帮助。
回答by Julian Popov
Open Xcode and, from the menu XCode-> Preferencesupdate your Command Line Tools (Xcode 8.0).
打开 Xcode,然后从菜单XCode->Preferences更新您的命令行工具 (Xcode 8.0)。
Then do:
然后做:
bundle config build.nokogiri --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
bundle install
or just:
要不就:
gem install nokogiri -v 1.6.8.1 -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
回答by NDan
The more simple solution is to execute:
更简单的解决方案是执行:
xcode-select --install
gem install nokogiri
Update
更新
For Mojave I'm using gem install nokogiri -v '1.6.6.2' -- --use-system-libraries
对于莫哈韦沙漠我正在使用 gem install nokogiri -v '1.6.6.2' -- --use-system-libraries
回答by Quanlong
Try install libxml2 first with Homebrew.
首先尝试使用 Homebrew 安装 libxml2。
brew install libxml2
Then if installing with bundle
然后如果用捆绑安装
bundle config build.nokogiri --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2
bundle install
If installing directly with gem
如果直接用 gem 安装
gem install nokogiri -- --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2
回答by yuяi
gem update --system
xcode-select --install
brew unlink xz
gem install nokogiri -v '1.6.8.1'
brew link xz
If the above steps fail to fix the issue, what has also worked for me is running brew doctorand cleaning up any unbrewed header files.
如果上述步骤未能解决问题,那么对我也brew doctor有用的是运行并清理任何未生成的头文件。
回答by Orangenhain
This might be a duplicate of gem install nokogiri -v '1.6.8.1' fails... latest accepted answer there was to do:
这可能是gem install nokogiri -v '1.6.8.1' failed... 最新接受的答案的重复:
brew unlink xz; bundle install; brew link xz
brew unlink xz; bundle install; brew link xz
Re-linking xzmight not be necessary ... if for example you only have that dependency because of the_silver_searcher(which links directly against the non-symlinked library).
重新链接xz可能不是必需的……例如,如果您只有该依赖项,因为the_silver_searcher(它直接链接到非符号链接库)。
回答by Rimian
Similar to yuяi's answer and from Nokogiri's help:
类似于 yuяi 的回答和 Nokogiri 的帮助:
brew unlink xz
gem install nokogiri
brew link xz
http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x
http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x
This worked for 1.7.0.1
这适用于 1.7.0.1
回答by lraboteau
For Middleman
对于中间人
gem install nokogiri -v '1.8.2' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2/
gem install nokogiri -v '1.8.2' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ MacOSX10.13.sdk/usr/include/libxml2/
回答by Niels Kristian
If you have earlier installed nokogiri using bundler with bundle config build.nokogiri --use-system-librariesthis setting will still be there. If you then meanwhile have solved your Xcode setup (as suggested as the primary method of installation in the nokogiri installation) then you might wanna try removing that fra from bundler bundle config --delete build.nokogiriand try again doing bundle install.
如果您之前使用 bundler 安装了 nokogiri,bundle config build.nokogiri --use-system-libraries此设置仍然存在。如果您同时已经解决了您的 Xcode 设置(如建议作为 nokogiri 安装中的主要安装方法),那么您可能想尝试从捆绑器中删除该 frabundle config --delete build.nokogiri并再次尝试执行bundle install.

