Open Ziqi-Yang opened 8 months ago
I tried using a symlinked import source file, and I was able to get it to work:
: tree
8192 B symlink-justfile
4096 B ├─ bar.just
4096 B ├─ justfile
0 B └─ foo.just → /Users/rodarmor/tmp/symlink-justfile/bar.just
2 files, 1 link
: cat justfile
import 'foo.just'
: cat foo.just
bar:
echo BAR
: just bar
echo BAR
BAR
Can you provide steps to reproduce the issue you're getting?
Yes, here is the steps for reproducing this issue (make sure you use bash or bash-compatible shells.
cd /tmp
mkdir ./issue-reproduce
cd ./issue-reproduce/
# write justfile
cat > justfile << EOF
#!/usr/bin/env -S just --working-directory . --justfile
pwd:
pwd
import 'foo.just'
EOF
chmod +x ./justfile
# write foo.just
cat > foo.just << EOF
foo:
pwd
EOF
Then
cd .. # go back to /tmp
ln -s /tmp/issue-reproduce/justfile ./justfile
./justfile
Finally we can see the error:
❯ ./justfile
error: Could not find source file for import.
——▶ justfile:5:8
│
5 │ import 'foo.just'
│ ^^^^^^^^^^
Ahh gotcha, I see the issue. This could be fixed by interpreting imports relative to the canonicalized path to the current justfile, since canonicalization resolves symlinks. However, I worry that this would be somewhat unexpected behavior. I.e., if you didn't want this behavior, and you had a justfile which was symlinked from somewhere else, you would get a pretty confusing error. I could see enabling this with a setting.
I have these content in my justfile:
I can run the file normally. However, when I symbol linked file (for example
ln -sf
) and run the symbol link, it promptserror: Could not find source file for import.
. (Note the symbol link is at the different directory than targeted justfile)