简体   繁体   中英

If Bundler installs gems in a non-standard path, how do I get access to those gems and any bin files they come with?

I'm deploying a Rails 3 app using Capistrano. I've got RVM running on the remote server (as well as locally) and Bundler is managing all my gems. Here's the issue:

When I deploy, the following command is run by Capistrano:

bundle install --gemfile /var/www/releases/20110301225633/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test

So, all my gems are in /var/www/shared/bundle , okay. But, this means that no gems are installed in the system path (ie, running gem list returns nothing), so I can't use any bin files that may have come with those gems, including the rails command itself. The only way I've been able to get the web server (thin) started is to manually gem install thin . Once thin spools up it starts Rails just fine, including all of its required gems.

So, how do I get access to those gems outside of my running app? I know I shouldn't have to manually install anything to get this to work, but I don't know what I'm missing. I've tried running rvm-shell '1.9.2@mygemset' -c 'thin start' but I get the same error as trying to call thin start directly from the command line: bash: thin: command not found Even going directly to bundler's bin directory /var/www/shared/bundle/bundle/ruby/1.9.1/bin to start thin gives me the same error.

I feel like RVM should be taking care of this for me...maybe there's an environment variable I'm missing?

Thanks for any help!

The idea behind bundling is that it will install local copies of the gems your project needs without affecting the system-wide gems.

If you want full access to something outside of your rails app, you'll need to manually gem install it.

However, if you want to run a bin file for a gem within your project (for example, your Gemfile has gem "thin" in it and you want to be able to run thin start for that project), you can use bundle exec and it'll run the bundled version:

bundle exec thin start

我更喜欢使用:

bundle install --path binpaths

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM