pixi icon indicating copy to clipboard operation
pixi copied to clipboard

bug(tasks): cache glob doesn't work with relative paths pointing out of workspace

Open phcerdan opened this issue 1 year ago • 6 comments

Checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

[tasks]
cmd = "mkdir -p ../folder_a && echo Hello >> ../folder_a/a.txt"
outputs = ["../folder_a/a.txt"]
pixi --version
0.39.4

Issue description

Following the same example given in #1237 Not sure if expected, but the glob doesn't work if the folder is out of the project:

[tasks]
cmd = "mkdir -p ../folder_a && echo Hello >> ../folder_a/a.txt"
outputs = ["../folder_a/a.txt"]
✨ Pixi task (start in cxx): mkdir -p ../folder_a && echo Hello >> ../folder_a/a.txt
 WARN No files matched the output globs for task` 'start'
 WARN Output globs: ["../folder_a/a.txt"]

But the folder is indeed there:

ls ../folder_a
a.txt

These out of source folders are specially useful for CMake projects, where the build folder is strongly recommended to not be nested with the source (project) folder.

Something odd with the glob:

These two give different results:

This works ✅

[tasks]
cmd = "mkdir -p folder_a && echo Hello >> folder_a/a.txt"
outputs = ["folder_a/a.txt"]

This doesn't ❌

[tasks]
cmd = "mkdir -p folder_a && echo Hello >> folder_a/a.txt"
outputs = ["./folder_a/a.txt"]

Expected behavior

I expect that the glob works with relative paths:

[tasks]
cmd = "mkdir -p ../folder_a && echo Hello >> ../folder_a/a.txt"
outputs = ["../folder_a/a.txt"]

phcerdan avatar Jan 02 '25 23:01 phcerdan

@nichmor is this also fixed with your latest PR that made changes to the GlobHashCache?

baszalmstra avatar May 27 '25 08:05 baszalmstra

@nichmor is this also fixed with your latest PR that made changes to the GlobHashCache?

I'm not sure without testing it ( but I'm inclined to say that no )

nichtmacho avatar May 27 '25 08:05 nichtmacho

Is there a way I can help? The current broken behavior is a bit surprising, and I don't think it should be a huge fix. Relative globs don't work, can we workaround somehow? if the glob is relative... do something else?

phcerdan avatar Sep 10 '25 20:09 phcerdan

hey @phcerdan ! Sorry for such a long reply time - I will take a look tomorrow at this as I've touched something similar and will let you know

nichtmacho avatar Sep 10 '25 20:09 nichtmacho

hey @phcerdan ! I've checked the issue on the pixi 0.54.2 with this example:

[workspace]
authors = ["nichmor <[email protected]>"]
channels = ["conda-forge"]
name = "relative-paths-tasks"
platforms = ["osx-arm64"]
version = "0.1.0"

[tasks.jora]
cmd = "mkdir -p ../folder_a && echo Hello >> ../folder_a/a.txt"
outputs = ["../folder_a/a.txt"]

[dependencies]

And I can confirm that running it twice indeed caches it:

graf@Nichitas-MacBook-Pro relative-paths-tasks % pixi run jora
✨ Pixi task (jora): mkdir -p ../folder_a && echo Hello >> ../folder_a/a.txt                                                            Task 'jora' can be skipped (cache hit) 🚀  

Could you please check on your side? If it works, then we can happily close it

nichtmacho avatar Sep 12 '25 15:09 nichtmacho

Closing, feel free to re-open it case it doesn't work on your side

nichtmacho avatar Sep 18 '25 09:09 nichtmacho