casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
17.6k stars 399 forks source link

Confusion around current working directory #1965

Open bamiaux opened 2 months ago

bamiaux commented 2 months ago

Hello,

First, thanks for your tool, it replaced Makefile on all my projects, including those on windows platforms!

One of my just file which was working on just 1.21 is now broken. It seems related to #1813 I understand why it was fixed, but it breaks my use-case, and seems to make the recipe attribute no-cd useless ?

Here's a reduced test case

/tmp/justbug/justfile

import "bar/bar.just
import "foo/foo.just

/tmp/justbug/bar/bar.just

[no-cd, private]
bar:
    @echo bar
    pwd
    # echo *.c

/tmp/justbug/foo/foo.just

foo:
    @echo foo
    pwd
    just @bar
    # cc *.c

On 1.21

/tmp> cd justbug
/tmp/justbug> just foo
foo
/tmp/justbug/foo
bar
/tmp/justbug/foo

It was nice, I could put some just files into dedicated directories & work directly into those directories. I could import other files and share their code. If I only wanted to share some code, I could use the no-cd attribute to make it explicit.

On latest version

/tmp> cd justbug
/tmp/justbug> just foo
foo
/tmp/justbug
bar
/tmp/justbug

Now, no-cd does nothing, the current directory is always the root directory. If you want to keep this behavior, may I suggest removing 'no-cd' and replace it with 'cd' so I could add it to the foo: command & avoid adding cd foo to every commands ?

laniakea64 commented 2 months ago

Can you use modules instead of import?

bamiaux commented 2 months ago

I'm not sure about modules: