Reputation: 8693
How to avoid multiple gems under shared bundle folder, when doing a deploy using the capistrano command. Most of the times when I migrate a gem from a version to another the shared bundle folder still contains both the versions, causing issues. How should we avoid this?
Upvotes: 1
Views: 927
Reputation: 28285
khustochka's answer above solved my problem perfectly. However, if your system is using Capistrano v3, the syntax has changed significantly. I used the following:
namespace :bundle do
task :clean do
on roles(:web) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :clean
end
end
end
end
end
after "deploy:cleanup", "bundle:clean"
~
Upvotes: 1
Reputation: 2386
I am not sure I ever saw conflicts like this. But I have extended capistrano deploy:cleanup
task with cleaning outdated bundler gems:
after "deploy:cleanup", "bundle:clean"
namespace :bundle do
task :clean, :except => {:no_release => true} do
bundle_cmd = fetch(:bundle_cmd, "bundle")
run "cd #{latest_release} && #{bundle_cmd} clean"
end
end
If it causes you conflicts, you can probably do it after deploy
instead.
Upvotes: 4