Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer:install should accept an optional directory/path argument #26

Closed
clov3r opened this issue Aug 29, 2014 · 5 comments
Closed

Composer:install should accept an optional directory/path argument #26

clov3r opened this issue Aug 29, 2014 · 5 comments

Comments

@clov3r
Copy link
Contributor

clov3r commented Aug 29, 2014

In my use case, I have a submodule that manages its dependencies with
composer. Currently, composer:install is hard-coded to run within
release_path, which fails, with no option to change directories, as
composer cannot find a suitable composer.json. Allowing the user to
specify an execution path for the install command would be most helpful!

@swalkinshaw
Copy link
Member

What about just setting --working-dir in composer_install_flags? See https://getcomposer.org/doc/03-cli.md#global-options

@clov3r
Copy link
Contributor Author

clov3r commented Sep 2, 2014

Ah, that should do it…. but at the moment isn’t. Which confuses me.

Almost certainly an error on my end, though. Thanks for the knowledge :)

Callum Kerr

201 Main Street, Suite 206
Rapid City, SD 57701
605-484-9461 Mobile
605-341-2388 Office

On Aug 29, 2014, at 4:02 PM, Scott Walkinshaw notifications@github.com wrote:

What about just setting --working-dir in composer_install_flags? See https://getcomposer.org/doc/03-cli.md#global-options


Reply to this email directly or view it on GitHub.

@clov3r clov3r changed the title Composer:install should accept an optinal directory/path argument Composer:install should accept an optional directory/path argument Sep 2, 2014
@clov3r
Copy link
Contributor Author

clov3r commented Sep 2, 2014

Ok, I've done some tinkering and now have things working with --working-dir, but there are still some niggles, which I'll lay out:

# deploy/staging.rb

set :composer_install_flags, "--no-interaction --optimize-autoloader --working-dir=#{release_path}/content/plugins/timber"

At the point at which the composer install task runs, after "deploy:updated", the above path resolves to:
/Server/Path/Here/InternalStaging/deployments/site/current/content/plugins/timber.

Note the /current part of the path. As I understand it, release_path should resolve to the path to the releases/XXXXXXXXXX folder. I may be mistaken about that, but that's the assumption I'm operating under.

So when the composer install task runs, it runs in the current path, before deploy:publishing comes along and removes the current link and relinks to the new current release. So the install task is running in an obsolete folder.

I have worked around this as so:

# deploy.rb

Rake::Task['deploy:updated'].prerequisites.delete('composer:install')
after "deploy:published", "composer:install"

(Because after deploy:published, release_path resolves to the correct path)

But I'm sure I'm missing something. Am I looking at the wrong variable for the correctly resolved release_path?

@swalkinshaw
Copy link
Member

Capistrano doesn't have the best docs on this, but you need to use a lambda function (->(args) { block }) and fetch when referencing variables like release_path to ensure it's evaluated at the proper time:

set :composer_install_flags, -> { "--no-interaction --optimize-autoloader --working-dir=#{fetch(:release_path)}/content/plugins/timber" }

That should hopefully solve it.

@clov3r
Copy link
Contributor Author

clov3r commented Sep 2, 2014

Yes, this was it. Thank you kindly, sir!
Callum Kerr

201 Main Street, Suite 206
Rapid City, SD 57701
605-484-9461 Mobile
605-341-2388 Office

On Sep 2, 2014, at 10:10 AM, Scott Walkinshaw notifications@github.com wrote:

Capistrano doesn't have the best docs on this, but you need to use a lambda function (->(args) { block }) and fetch when referencing variables like release_path to ensure it's evaluated at the proper time:

set :composer_install_flags, -> { "--no-interaction --optimize-autoloader --working-dir=#{fetch(:release_path)}/content/plugins/timber" }
That should hopefully solve it.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants