Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem install on bundle folder (vendor/bundle)

I am trying to install a ruby project, which has a dependency like in Gemfile

nokogiri (1.6.1)

bundlr fails

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.

I followed the instructions to install nokogiri manually and succeeded (OSX 10.9.2)

 which nokogiri
/usr/bin/nokogiri
nokogiri
Nokogiri: an HTML, XML, SAX, and Reader parser
Usage: nokogiri <uri|path> [options] ...

but, how can I install nokogiri to the expected path by the app (vendor/bundle , like the other dependencies, not in system folder). I tried an option --path vendor/bundle with gem install, but it is not recognized

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

I am running gem install as another user, that is why no permission to write to system folder. still, it is not trying to install at vendor/bundle.

It is also ok if I can find a way to use bundle (instead of gem) to install nokogiri. But, I am not sure how to specify the dependencies like the installation command below.

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
like image 325
bsr Avatar asked May 17 '14 22:05

bsr


People also ask

Why bundle install is installing gems in vendor bundle?

In deployment, isolation is a more important default. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application.

How do I install gem bundles?

Install BundlerSelect Tools | Bundler | Install Bundler from the main menu. Press Ctrl twice and execute the gem install bundler command in the invoked popup. Open the RubyMine terminal emulator and execute the gem install bundler command.


1 Answers

Try to create config for bundler in ~/.bundle/config:

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

and after bundle install --path vendor/bundle.

like image 150
Philidor Avatar answered Oct 17 '22 11:10

Philidor