Bundler in deployment mode does not find Gems

有些话、适合烂在心里 提交于 2020-01-06 19:49:13

问题


I was heavily struggling with my Capistrano Setup, when my Hoster migrated the server:

Capistrano3 deploy fails after migrating the server

One thing I ran into that used to work just fine on the old machine and now seems to be a mess is bundler:

I could successfully run bundler through Capistrano:

cap staging bundler:install

This resulted in the following command on the server

/usr/bin/env bundle install --binstubs \ 
/var/www/mydomain.com/subdomains/dev/shared/bin \
--path /var/www/mydomain.com/subdomains/dev/shared/bundle \
--without development test \
--deployment

But now when I ran my server cap staging deploy:start_passenger which results in the following:

/usr/bin/env passenger start --socket tmp/passenger.socket -e staging -d

Then I got the error in my log file, that Rake was missing:

Could not find rake-10.2.2 in any of the sources (Bundler::GemNotFound)
<pre>  /var/www/mydomain.com/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/spec_set.rb:92:in `block in materialize&#39;

What is very weird, is the fact that the ruby version 2.1.2(the one I really use) shows up with 2.1.0. I have no visible reference to2.1.0` in my project, and my Gemfile contains:

ruby '2.1.2'

Since RBENV is used on the server I can run rbenv versions which shows me:

  system
* 2.1.2 (set by /var/www/mydomain.com/.rbenv/version)

So where does that weird 2.1.0 come from and how can I make sure that my server has all the dependencies it requires.


回答1:


I finally managed to deploy my application on the new server.

These steps were required to do it. However since I fought with it for a few hours some of it might be redundant:

  • gem install bundler && rbenv rehash: This is required since bundler is one of the gems that I need outside of the Rails App context in terms of dependencies.
  • Another one is gem install passenger && rbenv rehash
  • I am now using https://github.com/capistrano/rbenv but for this I had to wipe RVM from my system, which was a step I wasn't too enthusiastic of doing.
  • I had to make sure the current symlink was created so I added this to the deploy.rb

    after 'deploy:set_current_revision', 'deploy:symlink:release'
    
  • I had to delete some of the shared directories:

    rm -fr bin
    rm -fr shared/bundle/
    rm -fr bundle
    


来源:https://stackoverflow.com/questions/26146273/bundler-in-deployment-mode-does-not-find-gems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!