just icon indicating copy to clipboard operation
just copied to clipboard

Shell not found in module

Open jneuendorf-i4h opened this issue 1 year ago • 3 comments

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.

jneuendorf-i4h avatar Jan 14 '25 10:01 jneuendorf-i4h

Interpolations are not expanded in strings.

See https://github.com/casey/just/issues/11 and https://github.com/casey/just/issues/2309

laniakea64 avatar Jan 14 '25 15:01 laniakea64

Is there any recommended workaround? Would using a bash shebang recipe with a cd to the desired working directory work? 🤔

jneuendorf-i4h avatar Jan 14 '25 19:01 jneuendorf-i4h

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"

cspotcode avatar Nov 20 '25 18:11 cspotcode