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_working_dir dependent on release path #37

Closed
Clindbergh opened this issue Mar 5, 2015 · 4 comments
Closed

composer_working_dir dependent on release path #37

Clindbergh opened this issue Mar 5, 2015 · 4 comments

Comments

@Clindbergh
Copy link

If my composer project was in a subdirectory, I expect to be able to do

set :composer_working_dir, "directory/with/composer/project"

However this fails, since the default is dependent on :release_path. This dependency should probably be handled within the code. Or if I am misunderstanding the use of it, maybe a second variable for this would be useful.

Never having used ruby before, I came up with this alternative:

set :composer_working_dir, Proc.new { fetch(:release_path) ? fetch(:release_path) + "mySubdirectory" :"" }

Might be related to this: #36

@swalkinshaw
Copy link
Member

The default composer_working_dir is:

set :composer_working_dir, -> { fetch(:release_path) }

You can override it like this:

set :composer_working_dir, -> { 'directory/with/composer/project' }

Can you confirm is that works or not? I don't see how it wouldn't but you never know.

@Clindbergh
Copy link
Author

No this does not work. My custom composer_working_dir apparently needs to be a concatenation of my directory and the release path. And since :release_path nil at the beginning, I need to do that check in my proc (probably the reason for #36).


Here is what happens:

  • set :composer_working_dir, -> { 'myDirectory' }

    DEBUG [c24e6a58] Running /usr/bin/env if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi as deployer@127.0.0.1
    DEBUG [c24e6a58] Command: if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi
    DEBUG [c24e6a58]        Directory does not exist 'myDirectory'
    (Backtrace restricted to imported tasks)
    cap aborted!
    SSHKit::Runner::ExecuteError: Exception while executing as deployer@127.0.0.1: if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi exit status: 1
    if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi stdout: Nothing written
    if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi stderr: Directory does not exist 'myDirectory'
    
    SSHKit::Command::Failed: if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi exit status: 1
    if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi stdout: Nothing written
    if test ! -d myDirectory; then echo "Directory does not exist 'myDirectory'" 1>&2; false; fi stderr: Directory does not exist 'myDirectory'
    
    Tasks: TOP => composer:run
    
  • set :composer_working_dir, -> { fetch(:release_path) }

    INFO [7d242e5d] Running /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as deployer@127.0.0.1
    DEBUG [7d242e5d] Command: cd /var/www/home/live/releases/20150305150803 && ( SYMFONY_ENV=prod /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )
  • set :composer_working_dir, Proc.new { fetch(:release_path) ? fetch(:release_path) + "myDirectory" :"" }

    DEBUG [bd13c3b3] Running /usr/bin/env if test ! -d /var/www/home/live/releases/20150305150927/myDirectory; then echo "Directory does not exist '/var/www/home/live/releases/20150305150927/myDirectory'" 1>&2; false; fi as deployer@127.0.0.1
    DEBUG [bd13c3b3] Command: if test ! -d /var/www/home/live/releases/20150305150927/myDirectory; then echo "Directory does not exist '/var/www/home/live/releases/20150305150927/myDirectory'" 1>&2; false; fi
    DEBUG [bd13c3b3] Finished in 0.009 seconds with exit status 0 (successful).
    INFO [3e2ab45f] Running /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader as deployer@127.0.0.1
    DEBUG [3e2ab45f] Command: cd /var/www/home/live/releases/20150305150927/myDirectory&& ( SYMFONY_ENV=prod /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )

    -> works

@Clindbergh
Copy link
Author

@swalkinshaw: The property "composer_project_dir" in my PR would now have the behaviour expected in your post.

@swalkinshaw
Copy link
Member

release_path should never be nil during a deploy. I made a mistake when I suggested:

set :composer_working_dir, -> { fetch(:release_path) }

You're correct that it should be:

set :composer_working_dir, -> { "#{fetch(:release_path)/myDirectory}" }
# or
set :composer_working_dir, -> { File.join(fetch(:release_path), 'myDirectory') }

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