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

Run function does not run functions from the deploy_path #381

Closed
antonydandrea opened this issue Jun 28, 2015 · 10 comments
Closed

Run function does not run functions from the deploy_path #381

antonydandrea opened this issue Jun 28, 2015 · 10 comments
Assignees
Labels

Comments

@antonydandrea
Copy link

In the documentation it says
Runs a command on a remote server in the working path (server(...)->env('deploy_path', '/home/path')).

But when I run 'pwd', I found the working path was the home directory of the user. Either there is a bug or the documentation is wrong?

@ad3n
Copy link
Contributor

ad3n commented Jun 29, 2015

all command run using cd {{release_path}} && [[comman]]

@peterjaap
Copy link
Contributor

peterjaap commented Dec 23, 2016

This also happens when a command is run through a hook (after);

after('elgentos:test', 'elgentos:test2');

Both test and test2 commands have one line;

writeln(run('pwd'));
➜  project git:(master) ✗ dep elgentos:test staging
➤ Executing task elgentos:test
/home/elgentos/project

✔ Ok
➤ Executing task elgentos:test_next
/home/elgentos

✔ Ok

The suggestion by @ad3n does not work when the commands are not run in the deploy context, because at that point the {{release_path}} variable isn't set and an error is thrown.

Right now I'm left with two options;

within('{{deploy_path}}', function () use ($all, $my, $args) { run('whatever ' . $all . $my . $args); });

or

run('cd {{deploy_path}} && whatever ' . $all . $my . $args);

Both of which aren't elegant.

So I vote for this issue to be re-opened @Elfet

@antonmedv
Copy link
Member

Will look close on it.

@antonmedv antonmedv reopened this Dec 23, 2016
@antonmedv antonmedv added the bug label Dec 23, 2016
@antonmedv antonmedv self-assigned this Jan 18, 2017
@antonmedv
Copy link
Member

There was bug with working_path, indeed. But for now it's about 1.5 years since bug was discovered. And this become default behavior. So i'm thinking to save this behavior and update docs: run executes command in user home dir. If you want to change to deploy_path used `cd1 function:

task('...', function () {
    cd('{{deploy_path}}');
    run('pwd');
});

@antonmedv
Copy link
Member

Or use short syntax:

task('hook', '
    cd {{deploy_path}};
    pwd;
');

@antonmedv
Copy link
Member

👁 17dcad7

@naquad
Copy link

naquad commented Apr 20, 2017

This is a 🤦‍♂️ kind of behavior: every task now needs to cd('{{deployment_path}}');. It breaks DRY principle + it is error prone (recipe maintainer can forget to do it or forget to change it).

I've tried before('deploy:*', 'a_hack:cd_to_deployment''); and ->set('working_path', '/path/to/deployment') both didn't work.

Usually project is residing in a single folder that is not user home directory and it makes sense to cd {{deployment_path}} for isolation and convenience. Documentation doesn't state that default directory is user home directory either.

Even if you don't want to change the default behavior it would be awesome if you would provide some workaround like optional setting default_path or similar setting to be used as a fallback in case if one needs to run all commands in given directory.

Thank you.

@antonmedv
Copy link
Member

makes sense to cd {{deployment_path}} for isolation and convenience.

Maybe this will go to v5 (it still in beta). I don't like to cding to release path too. But i think what task should be without side effects as possible (cd in one mustn't effect working_path in another one)

default_path or similar setting

Try this:

set('working_path', '{{release_path}}');

If you can add this to docs (and more stuff what you this necessary about cding) will be really cool.

@naquad
Copy link

naquad commented Apr 20, 2017

@antonmedv
Copy link
Member

Yeah, this should be fixed.

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

No branches or pull requests

5 participants