I'm trying to write a task for Capistrano 3 that involves executing 'composer install' within the directory of the current release. It looks something like this:
namespace :composer do
desc 'Install dependencies with Composer'
task :install do
on roles(:web) do
within release_path do
execute "#{fetch(:composer_command)} install"
end
end
end
end
composer_command
is set in the staging and production files - in my particular case to php /home/user/composer.phar
For some reason this command does not actually run in the current release directory, but instead runs in the parent directory (containing current, shared, releases, etc)
I delved into this a bit further and found that when I ran a single word command, like:
within release_path do
execute "pwd"
end
It works just fine, and runs the command in the current release directory. But... when I run a command with spaces, like:
within release_path do
execute "pwd && ls"
end
It runs in the parent directory, and not the directory set by the within
block.
Can someone shed some light on this? Thanks!