Skip to content

Commit

Permalink
Fix working dir bug when composer:run is executed directly via the CLI
Browse files Browse the repository at this point in the history
When not running via a deploy (e.g. composer:run executed directly via CLI), the command fails because
the release_path variable is not set. It's only set as part of a deploy.

This fix changes the way composer:run works: when not executed within the context of a deploy, Composer's
working directory will be set to current_path instead of release_path.

This is a backwards-compatible bugfix, but it might be worth bumping at least minor version because
behavior changes considerably for end-users.
  • Loading branch information
gsomoza committed Oct 30, 2018
1 parent 876298a commit 306534d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/capistrano/tasks/composer.rake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ namespace :composer do
task :run, :command do |t, args|
args.with_defaults(:command => :list)
on release_roles(fetch(:composer_roles)) do
within fetch(:composer_working_dir) do

composer_working_dir = fetch(:composer_working_dir)
if composer_working_dir.nil? # not in deploy context? (e.g. task was executed directly)
# run in current_path
composer_working_dir = current_path
end

within composer_working_dir do
execute :composer, args[:command], *args.extras
end
end
Expand Down

0 comments on commit 306534d

Please sign in to comment.