-
Notifications
You must be signed in to change notification settings - Fork 399
fix: don't strip the path on out of source paths. #5190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note that claude is extremely bad at this part of the code, and has been my worst experience so far. So yeah the code is a bit tricky, and reading it after a month it can definitely be more clear, one of the reasons bas has introduced But when reading this: https://github.com/tdejager/pixi/blob/7cff5ea608e64c03dda2e86c9737534e5934a1c8/crates/pixi_record/src/source_record.rs#L103 It seems to say something differently. But I think that comment is actually incorrect or talks about the part in parentheses? Not sure, because we also discussed about having everything as absolute to get rid of this behavior. I'm also confused. BackgroundThe reason these functions exist is when talking about them internally we use a different representation, relative to workspace root, then when locked, at that point they are relative to the manifest. So that's why the path mangling is here when reading from and to the lock. This part that was removed when commented: let base_absolute = base_path.resolve(workspace_root);
// We know that possible_relative_path is relative here
let relative_std_path = Path::new(build_source_path.as_str());
// Join base with relative path to get the target absolute path
let target_path_abs = base_absolute.join(relative_std_path);
// Normalize the path (resolve . and ..)
let normalized = crate::path_utils::normalize_path(&target_path_abs);
// Convert back to a path that's either absolute or relative to workspace
let path_spec = normalized.strip_prefix(workspace_root).expect(
"the workspace_root should be part of the source build path at this point",
);
I think we want to return a path relative to the workspace and not the absolute. Would be great for @baszalmstra to chime in quickly here. Answering: does the function |
|
@tdejager Thank you for the extended reply! The test would indeed fail; it would always fail with out-of-tree packages, as the normalization would delete the workspace root from the path so it would not be able to remove that part from the path, and thus the expect is thrown. |
Yeah, I think that join actually does normalization so it can move out of the workspace when it's joined, I did not account for that. So that would be the error. |
|
Just fyi, I did a more involved investigation with claude if we can always return absolute paths. Summary: Path Handling in
|
|
I want to propose a different solution. The problem is that the SourceRecord loses information about whether the original build source spec provided by the user is lost. We could also consider storing the "original" (but possibly resolved in case of git) spec alongside the "workspace relative" path. Then we can simply store that in the lock-file. |
|
Closing in favor of #5247 |
Description
Potential fix for #5125
Unfortunately, I struggle to understand what the goal of the function is. Should it return relative or absolute paths? The custom path mangling feels like a solution to some other problem in the pipeline.
The main issue is that it didn't work for out-of-tree paths.
How Has This Been Tested?
It has been tested against the issue.
AI Disclosure
Tools: Claude
Checklist: