For some reason Capistrano is failing on just about every operation, because it seems to think my current_path
should be in /u/apps/
. I've set all the variables that (AFAIK) should be set, and eliminated all other similar default paths, but this one persists.
Here are the values returned by relevant variables:
current_dir: current
releases_path: /var/www/vhosts/dev.www.example.com/html/releases
shared_path: /var/www/vhosts/dev.www.example.com/html/shared
current_path: /u/apps/www.example.com/current
I'm setting :deploy_to
, so shouldn't current_path
be computed based on that!?
set :deploy_to, "/var/www/vhosts/dev.www.example.com/"
The kind of kludgey solution is just to manually
set :current_path, ""
The better solution, which can be found explained in this e-mail thread by Jamis Buck himself, is to use lazy evaluation when you set another variable that depends on current_path
. In my case, I had a setting something like this
set :some_path_var, "#{current_path}/some/path/"
that I had to change to something like this:
set(:some_path_var) { "#{current_path}/some/path/" }
By passing in a block, the :some_path_var was not immediately evaluated, and did not force current_path
to be evaluated based on a default value for :deploy_to
So I had this issue as well and I found that this was the best solution.
Add this to your config/deploy.rb
desc "Make sure the symlink will be from the right directory"
task :change_correct_dir, roles: :web do
set :current_path, File.join(deploy_to, current_dir)
end
before "deploy:create_symlink", "deploy:change_correct_dir"
I got the idea from looking at the source of the capistrano gem and finding
_cset(:current_path) { File.join(deploy_to, current_dir)
in
lib/capistrano/recipes/deploy.rb
This can also happen if you don't specify a task in your cap command.
cap deploy:setup
Will attempt to set up Capistrano in /u/apps
cap production deploy:setup
Will set up Capistrano in the directory specified in :deploy_to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With