我正在尝试安装一个ruby项目,它具有像Gemfile
这样的依赖项nokogiri (1.6.1)
bundlr失败
An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
我跟着instructions手动安装nokogiri并成功(OSX 10.9.2)
which nokogiri
/usr/bin/nokogiri
nokogiri
Nokogiri: an HTML, XML, SAX, and Reader parser
Usage: nokogiri <uri|path> [options] ...
但是,如何通过应用程序(供应商/软件包,如其他依赖项,而不是系统文件夹)将nokogiri安装到预期路径。我尝试使用--path vendor/bundle
选项gem install
,但无法识别
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
我正在以另一个用户身份运行gem install,这就是为什么没有写入系统文件夹的权限。不过,它并没有尝试在vendor/bundle
安装。
如果我能找到一种方法来使用bundle(而不是gem)来安装nokogiri,这也没关系。但是,我不知道如何指定依赖项,如下面的安装命令。
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
答案 0 :(得分:1)
尝试在~/.bundle/config
中为bundler创建配置:
BUNDLE_PATH: ./vendor/bundle
BUNDLE_BUILD__NOKOGIRI: --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
--with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include
--with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
和bundle install --path vendor/bundle
之后。
答案 1 :(得分:0)
在Mac上,我尝试了以下方法,并且有效。
bundle config build.nokogiri --use-system-libraries
bundle install --path vendor/bundle