Shell not found in module
Description
When I use set working-directory in a child module and the value contains an expression, the following error occurs:
error: Backtick could not be run because just could not find the shell:
No such file or directory (os error 2)
The expression itself seems to be irrelevant, as I tried both set working-directory := '{{ "." }}' and set working-directory := '{{ justfile_directory() }}'. However, it works without the expression, i.e. set working-directory := '.'
I need this for Terraform/Ansible where relative paths are important for correct file lookups but at the same time I need to ensure that each just module has its own settings (i.e. to avoid env var clashes).
Example
.
├── justfile
└── modules
└── a.just
# ./justfile
USERNAME := `whoami`
mod a 'modules/a.just'
task:
echo {{ USERNAME }}
# ./modules/a.just
set working-directory := '{{ "." }}'
USERNAME := `whoami`
task:
echo {{ USERNAME }}
Versions
Just: 1.38.0 OS: macOS 15.2
Update: The same goes for using the attribute [working-directory: '{{ BASE_DIR }}/path'].
PS: I just read about Werk which seems to draw a lot of inspiration from just. Maybe some improvements there could be valuable features for just as well.
Interpolations are not expanded in strings.
See https://github.com/casey/just/issues/11 and https://github.com/casey/just/issues/2309
Is there any recommended workaround? Would using a bash shebang recipe with a cd to the desired working directory work? 🤔
This is wrong:
set working-directory := '{{ "." }}'
set working-directory := '{{ justfile_directory() }}'
set working-directory := '{{ justfile_directory() }}/foo'
The correct syntax is:
set working-directory := "."
set working-directory := justfile_directory()
set working-directory := justfile_directory() + "/foo"