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

[npm-installer] support more than tar.gz #226

Open
Gankra opened this issue Apr 24, 2023 · 1 comment
Open

[npm-installer] support more than tar.gz #226

Gankra opened this issue Apr 24, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Gankra
Copy link
Member

Gankra commented Apr 24, 2023

cargo-dist currently lets you select your binary archive format:

  • .zip (default windows)
  • .tar.gz
  • .tar.xz (default unix)
  • .tar.zstd

But the npm installer can only handle .tar.gz! This is a limitation inherited from the binary-install npm package (yes the "fork" is the Real One), which in turn inherits the limitation from the npm tar package which in turn inherits the limitation from "node-js bundles a gzip encoder/decoder and that's all we use".

As a workaround I will be making the new interactive UX default to .tar.gz compression if you enable npm installers, but we should really deal with by fixing/forking/ditching binary-install.

@Gankra Gankra added the bug Something isn't working label Apr 24, 2023
@Gankra Gankra added the good first issue Good for newcomers label May 9, 2024
@Gankra
Copy link
Member Author

Gankra commented May 9, 2024

We have now forked/vendored binary-install, and so we have the ability to fix this.

The JS code that needs to change is here:

return axios({ ...fetchOptions, url: this.url, responseType: "stream" })
.then((res) => {
return new Promise((resolve, reject) => {
const sink = res.data.pipe(
tar.x({ strip: 1, C: this.installDirectory }),
);
sink.on("finish", () => resolve());
sink.on("error", (err) => reject(err));
});

Given the above researach I think we should just invoke on-end-user-system CLIs for greater support. This would make the npm installer as reliable as the shell/powershell installers.

Relevant shell code:

# unpack the archive
case "$_zip_ext" in
".zip")
ensure unzip -q "$_file" -d "$_dir"
;;
".tar."*)
ensure tar xf "$_file" --strip-components 1 -C "$_dir"
;;
*)
err "unknown archive format: $_zip_ext"
;;

Relevant Powershell code:

switch -Wildcard ($zip_ext) {
".zip" {
Expand-Archive -Path $dir_path -DestinationPath "$tmp";
Break
}
".tar.*" {
tar xf $dir_path --strip-components 1 -C "$tmp";
Break
}
Default {
throw "ERROR: unknown archive format $zip_ext"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant