Skip to content
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

scarb package is crashing on invalid symlinks which should be ignored from the package #740

Open
mkaput opened this issue Oct 3, 2023 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@mkaput
Copy link
Member

mkaput commented Oct 3, 2023

Problem

The following test currently asserts failure because of implementation simplifications:

#[test]
fn broken_but_excluded_symlink() {
let t = TempDir::new().unwrap();
ProjectBuilder::start()
.name("foo")
.version("1.0.0")
.build(&t);
symlink_dir("nowhere", t.child("target"));
// FIXME(mkaput): Technically, we can just ignore such symlinks.
Scarb::quick_snapbox()
.arg("package")
.current_dir(&t)
.assert()
.failure()
.stdout_matches(indoc! {r#"
[..] Packaging [..]
error: failed to list source files in: [..]
Caused by:
[..]
"#});
}

Actually, what could happen here is that we can successfully create the tarball because the invalid symlink shouldn't be visited by the packaging process (it should be filtered out by dirwalker).

Steps

No response

Possible Solution(s)

Expand this logic:

.try_for_each(|entry| {
let entry = entry?;
if !is_dir(&entry) {
ret.push(entry.into_path().try_into_utf8()?);
}
Ok(())
})

to do something like this: https://github.com/rust-lang/cargo/blob/af1a78b424db7d517a359fd23d548e7fb30be98f/src/cargo/sources/path.rs#L458-L478

There are some differences between ignore and walkdir crates here, so this won't be a 1:1 copypaste.

Notes

No response

Version

No response

@mkaput mkaput added bug Something isn't working help wanted Extra attention is needed labels Oct 3, 2023
@mkaput mkaput added this to the Package registry & new resolver milestone Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Backlog
Development

No branches or pull requests

1 participant