casey / casey/just

evaluating PATH in justfile comes too late when using which()

Open
#2,597 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
35.8k
Forks
846
Avg merge
27m
Merged PRs (30d)
3

Description

just 1.39.0

testing the which-command:

use-case: run commands in a python-virtualenv,
some commands might be installed in the .venv and others might not.

when i run a command via just, i want to display the absolute path of the command

this works when ruff is installed globally, outside the .venv:
note: I dont want to "activate my python-env".

```
# prepend local bin-directory to $PATH
venv_bin_dir := if os_family() == "windows" { justfile_directory() / ".venv/Scripts" } else { justfile_directory() / ".venv/bin" }
export PATH := if os_family() == "windows" { venv_bin_dir + x";${PATH}" } else { venv_bin_dir + x":${PATH}" }

RUFF_EXE := which("ruff")

# show which ruff is used
[group: 'ruff']
ruff-which:
@ echo -e "Using executable {{RUFF_EXE}}"

# run ruff on python-files
[group: 'ruff']
ruff args="":
- {{RUFF_EXE}} docs/ etc/ src/ tests/ {{args}}

```

global ruff on global $PATH is found
```
just ruff-which
Using executable /opt/tools/bin/ruff
```

local ruff in .venv/bin/ruff is not found

```
just ruff-which
Using executable --> not found, empty
```

It seems tthat the updated PATH in just comes to late,
after evaluating RUFF_EXE := which("ruff")

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.