Skip to content

Commit

Permalink
Use GNU format tarballs to support longer paths
Browse files Browse the repository at this point in the history
This fixes errors related to paths being too long, which is common when
using git dependencies. Note that cargo itself switched from UStar to
GNU format in 2020.

    thread 'main' panicked at src/main.rs:290:32:
        called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "provided value is too long when setting path for some-crate-0.123.123/src/" }
  • Loading branch information
cormacrelf committed Jan 7, 2025
1 parent 5fba6b7 commit f1987e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ flate2 = "1.0.22"
openssl = { version = '0.10.41', optional = true }
serde = { version = "1.0.104", features = ['derive'] }
serde_json = "1.0.46"
tar = "0.4.26"
tar = "0.4.43"
url = "2.1.1"

[dev-dependencies]
Expand Down
10 changes: 2 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::fs::{self, File};
use std::io;
use std::io::prelude::*;
use std::path::{self, Path, PathBuf};
use tar::{Builder, Header};
use tar::Builder;
use url::Url;

#[derive(Deserialize)]
Expand Down Expand Up @@ -285,13 +285,7 @@ fn build_ar(ar: &mut Builder<GzEncoder<File>>, pkg: &Package, config: &GlobalCon
relative
);

let mut header = Header::new_ustar();
let metadata = file.metadata().unwrap();
header.set_path(&path).unwrap();
header.set_metadata(&metadata);
header.set_cksum();

ar.append(&header, &mut file).unwrap();
ar.append_file(&path, &mut file).unwrap();
}
}

Expand Down

0 comments on commit f1987e9

Please sign in to comment.