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

PROPOSAL: Do not change current working directory when just finds a target in the parent #2051

Closed
gabyx opened this issue May 18, 2024 · 3 comments

Comments

@gabyx
Copy link

gabyx commented May 18, 2024

Whenjust gaga ./myfileis executed in a subfolder /a/b/c of a /justfile it will change the working directory to this justfile's directory e.g. / and then execute the
target. Arguments given to the command might be relative file paths and these will then not work as intended, when suddenly the cwd is changed (there is also no documentation for this behavior AFAIK).

It would be nice to disable this behavior (ok its braking change I guess, or introduce a setting set cwd-to-current-justfile = false.

@laniakea64
Copy link
Contributor

Can you use [no-cd] attribute on the recipes where you want this behavior disabled?

@casey
Copy link
Owner

casey commented May 18, 2024

Good noticing that there wasn't any documentation of this. I opened #2053 to rectify this.

This is a pretty fundamental behavior of just, and I think there are more pros for it than cons, although I see how this case is annoying.

You can use [no-cd] on a recipe, like @laniakea64 says, to change this behavior.

A potential feature that could be added is marking an argument as a path somehow, which would cause it to be joined with the invocation directory, making it an absolute path, and thus insensitive to the current directory:

@foo bar~path:
  echo {{bar}}
$ cd subdir
$ just foo hello/baz
/subdir/hello/baz

@casey casey closed this as completed May 18, 2024
@gabyx
Copy link
Author

gabyx commented May 19, 2024

Ah nice there is already a solution, cool.
Maybe yes, the path thing on an argument would be nice.

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

No branches or pull requests

3 participants