Search code examples
rubygruntjscapistranobowercapistrano3

Capistrano returning wrong release_path


I have a question about capistrano version 3.2.1. In my deploy.rb file I'm using the following line:

set :theme_path, "#{release_path}/web/app/themes/myproject"

The variable release_path is not showing to latest release folder, lets say 201409151420 as it should, but it is pointing to folder current, so the output is:

DEBUG[68031037] Command: cd /var/www/myproject/current/web/app/themes/myproject && ( WP_ENV=staging /usr/bin/env npm install --silent )

The output should be:

DEBUG[68031037] Command: cd /var/www/myproject/201409151420/web/app/themes/myproject && ( WP_ENV=staging /usr/bin/env npm install --silent )

Does anyone know, why the release_path variable isn't showing to the proper folder?

Thank you for your help.


Solution

  • I think it should work if you evaluate your theme_path lazily:

    set(:theme_path) { "#{release_path}/web/app/themes/myproject" }

    set :theme_path, lambda { "#{release_path}/web/app/themes/myproject" }
    

    The value you are seeing is expected if release_path is not defined (see dsl/paths.rb):

    def release_path
      fetch(:release_path, current_path)
    end
    

    That is, the default value for release_path is current_path.