Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Capistrano to deploy a Ruby on Rails application to a server. Everything is running up until the point when bundle install is called in which case I get the error "Some gems seem to be missing from your vendor/cache directory."

This error is caused because there are some gems checked into the vendor/cache directory of the git repository that Capistrano is cloning from. I understand the best approach would be to clean up the git repository but since that is not an option for me I would like to have Capistrano delete the vendor/cache directory on the remote server after the git clone but before the call to bundle. I have run the steps manually and have found that by deleting the directory manually bundle executes correctly but I can't seem to figure out how to get Capistrano to perform the delete.

Here is the pertinent fragment from my deploy.rb file:

after "deploy:update_code" do
  run "rm -rf #{release_path}/vendor/cache"
end
after "deploy:update_code", "bundle:install"

And here is the command line output

executing `deploy:update_code'
executing locally: "git ls-remote my_git_repository HEAD"
command finished in xxxms
* executing "git clone [snipped for brevity]
servers: ["my_server"]
[my_server] executing command
** [my_server :: out] Error reading response length from authentication socket.
** [my_server :: out]
command finished in xxxms
* executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* executing `bundle:install'
* executing "[snipped for brevity] bundle install [snipped for brevity]"
servers: ["my_server"]
[my_server] executing command
** [out :: my_server] Some gems seem to be missing from your vendor/cache directory.
** [out :: my_server] 
** [out :: my_server] Could not find gem-version in any of the sources
** [out :: my_server] 
command finished in xxxms

It does not look like run "rm -rf #{release_path}/vendor/cache" ever gets run. Am I using the correct command? Any other ideas on what I should do?

share|improve this question

1 Answer 1

I'm wondering whether it's an issue with the order the tasks are being run; perhaps try the following?

task :clean_vendor_cache
  run "rm -rf #{release_path}/vendor/cache"
end
before "bundle:install", "clean_vendor_cache"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.