I am using capistrano v2.9.0 to deploy to a ubuntu server running
apache v2.2.12, passenger v3.0.4, ruby v1.9.2 and rails v3.0.1. When
I deploy a new application, I often get error messages like:
Could not find net-ssh-2.2.2 in any of the sources
(Bundler::GemNotFound)
The missing gem is actually in the vendor/cache directory, but it is
being ignored. For a while I was globally installing these missing
gems, but recently I found that by running the command:
$ bundle install --path vendor/cache
after deploying the application, passenger would use the gems in the
application.
Why do I need to do this extra step and why can’t capistrano do it for
me?
My understanding (which may be faulty) is that the --path option tell
bundle install where to put the gems, so this command installs the
gems to vendor/cache.
after deploying the application, passenger would use the gems in the
application.
Why do I need to do this extra step and why can’t capistrano do it for
me?
Because that is what bundle install is for, to install the appropriate
gems as defined by Gemfile and gemfile.lock.
The one thing I am not sure of is why it did not work when the gems
were already in vendor/cache. How did you get them there in the first
place?
Because that is what bundle install is for, to install the appropriate
gems as defined by Gemfile and gemfile.lock.
The one thing I am not sure of is why it did not work when the gems
were already in vendor/cache. How did you get them there in the first
place?
Colin
In my development environment I used the command:
$ bundle pack
to get the gems into vendor/cache. I then committed them to
subversion and
$ cap deploy
copied them from subversion to the target machine.
Colin
copied them from subversion to the target machine.
So the question is, what is the difference between
bundle pack
and
bundle install --path vendor/cache
So the question is, what is the difference between
bundle pack
and
bundle install --path vendor/cache
Colin
I found the pack command in “Agile Web D. with Rails”, fourth
edition on page 235. I stumbled across the install command while
researching this issue on the web.
Looking into this I see one big difference:
$ bundle install --path vendor/cache
installs all of ruby in the directory vendor/cache/ruby! It also
creates a file .bundle/config containing:
I guess I’d rather not have a fresh copy of ruby with each
application, so I’m back to my original problem - how to get passenger
and capistrano to set things up so that the gems in vendor/cache are
used.
I am having the same issue(s). It appears that bundle puts the gems into
vendor/cache, but the application (or capistrano during install?) is not
looking for them there. The installation fails, but examining
shared/cached-copy/vendor/cache on the server (deployment destination)
shows the “missing” gems are there.
Where did you run “bundle install --path vendor/cache”? On the
development machine, or the server?
Has there been any progress with a work-around?
The command that fails on the server during deployment is: “rake
RAILS_ENV=production RAILS_GROUPS=assets assets:precompile”
By the way… running “bundle install --path vendor/cache” on the
development system, then re-deploying did not fix the problem – the
deploy still failed at the assets compile step.
To get it to deploy I have to shell into the server, cd to
“shared/cached-copy” and then run “bundle pack” to install the missing
gems. After that the project will deploy, at least until the gem list is
changed again.
Well, this makes little sense to me, but it is a work-around for this
problem.
Add the following line to your deploy.rb file:
before “deploy:assets:precompile”, :bundle_install
I’ve also run (on the server) “bundle config path vendor/cache” and
placed “export BUNDLE_PATH=vendor/cache” in the .bashrc file.
Now, before precompiling the assets, the bundler installs the gems,
apparently into vendor cache. The last few lines are:
** [out :: ] Installing will_paginate (3.0.2)
** [out :: ]
** [out :: ] Updating .gem files in vendor/cache
** [out ::] Your bundle is complete! It was installed into
./vendor/cache
command finished in 103066ms
and the deployment continues to completion.
The end of my deploy.rb file looks like…
This is a hack to avoid deployment failure on the assets:precompile
step
Failure is “Could not find in any of the sources”
seems to be a bundler problem, as all gems are in vendor/cache, and
shouldn’t need
a bundle:install command
before “deploy:assets:precompile”, :bundle_install
after “deploy:update_code”, :bundle_install
desc “install the necessary prerequisites”
task :bundle_install, :roles => :app do
run “cd #{release_path} && bundle install”
end
See here for an explanation to this issue, that was presumably closed
last September…
after deploying the application, passenger would use the gems in the
application.
Why do I need to do this extra step and why can’t capistrano do it for
me?
If you add ‘–local’ to your ‘set :bundle_flags’ statement, capistrano
will automatically look into vendor/cache for the gems during the
deploy process without extra work.
They should be previously packaged with bundle package.
Usually it looks more like:
set :bundle_flags, “–deployment --local --without development test”
–deployment has several effects, which you can read at bundler page
as they are qute a few to write them here, specific to deployment
environments
–without avoids installing gems grouped on :development and :test on
your Gemfile
Anyway, you should post your error messages for further help if this
doesn’t solve them.
If you add ‘–local’ to your ‘set :bundle_flags’ statement, capistrano
will automatically look into vendor/cache for the gems during the
deploy process without extra work.
They should be previously packaged with bundle package.