cargo-bins / cargo-binstall

Binary installation for rust projects
GNU General Public License v3.0
1.56k stars 54 forks source link

Having hard time installing unsupported crates #376

Closed azzamsa closed 2 years ago

azzamsa commented 2 years ago

Hi.

I tried to run the command below, but I get an error.

❯ ./cargo-binstall   --pkg-url="https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip" --pkg-fmt="zip" fnm
error: Invalid value "zip" for '--pkg-fmt <PKG_FMT>': Matching variant not found

I thought I use the wrong pkg-fmt variant, So, I expect the help/man page had the variant listed. Turns out it is not.

Overrides:
        --bin-dir <BIN_DIR>                Override Cargo.toml package manifest bin-dir
        --manifest-path <MANIFEST_PATH>    Override Cargo.toml package manifest path
        --pkg-fmt <PKG_FMT>                Override Cargo.toml package manifest pkg-fmt
        --pkg-url <PKG_URL>                Override Cargo.toml package manifest pkg-url

I expect something like;

        --pkg-fmt <PKG_FMT>    ["zip", "tgz"] (default: "tgz)            Override Cargo.toml package manifest pkg-fmt

Then I just remove the --pkg-fmt options. But, I get a new error.

❯ ./cargo-binstall --pkg-url="https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip" fnm
Do you wish to continue? yes/[no]
? y
binstall::io

  × failed to iterate over archive
  ╰─▶ Unknown frame descriptor
❯ ./cargo-binstall -V
cargo-binstall 0.13.0
OS: Fedora Linux 36 (Workstation Edition) x86_64
Shell: zsh 5.8.1
passcod commented 2 years ago

hi, please don't use 0.13.0, and stick to 0.12.0 for now; we've unreleased 0.13.0 due to other such issues (#370) and will release 0.13.1 once we've got definitive fixes for these.

passcod commented 2 years ago

There is also no default for the pkg-fmt in 0.13, the default is "guess". We'll improve the help messages. (#378)

passcod commented 2 years ago

For your case, use this:

$ cargo binstall fnm \
  --pkg-url="https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip" \
  --pkg-fmt Zip \
  --bin-dir '{ bin }'
azzamsa commented 2 years ago

I use ~/.local/bin as a target --bin-dir. and now binstall moved all my item in that directory to .cargo/bin.

~ took 28s
❯ cargo binstall fnm --pkg-url="https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip" --pkg-fmt Zip --bin-dir ~/.local/bin
00:52:33 [INFO] Installing package: 'fnm'
00:52:35 [INFO] Checking for package at: 'https://github.com/alsuren/cargo-quickinstall/releases/download/fnm-1.31.1-x86_64-unknown-linux-gnu/fnm-1.31.1-x86_64-unknown-linux-gnu.tar.gz'
00:52:35 [INFO] Checking for package at: 'https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip'
00:52:35 [INFO] Checking for package at: 'https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip'
00:52:35 [INFO] Checking for package at: 'https://github.com/alsuren/cargo-quickinstall/releases/download/fnm-1.31.1-x86_64-unknown-linux-musl/fnm-1.31.1-x86_64-unknown-linux-musl.tar.gz'
00:52:35 [INFO] Winning URL is https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip
00:52:35 [INFO] Winning URL is https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip
00:52:35 [INFO] The package will be downloaded from github.com
00:52:35 [INFO] This will install the following binaries:
00:52:35 [INFO]   - fnm (bin -> /home/azzamsa/.cargo/bin/fnm-v1.31.1)
00:52:35 [INFO] And create (or update) the following symlinks:
00:52:35 [INFO]   - fnm (/home/azzamsa/.cargo/bin/fnm -> fnm-v1.31.1)
Do you wish to continue? yes/[no]
? y
00:52:44 [INFO] Downloading package from: 'https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-arm64.zip'
00:52:45 [INFO] Installing binaries...
00:52:45 [INFO] Installation completed in 12.469813887s
❯ ls ~/.local/bin
ls: cannot access '/home/user/.local/bin': No such file or directory

~
❯ ls ~/.cargo/bin
broot           cargo-fmt                    cargo-outdated     cargo-upgrade  git-cliff              rustc        rustlings
cargo           cargo-install-update         cargo-rm           cargo-watch    git-cliff-completions  rustdoc      rust-lldb
cargo-add       cargo-install-update-config  cargo-set-version  clippy-driver  git-cliff-mangen       rustfmt      rustup
cargo-binstall  cargo-miri                   cargo-tarpaulin    fnm            rg                     rust-gdb     stylua
cargo-clippy    cargo-nextest                cargo-udeps        fnm-v1.31.1    rls                    rust-gdbgui  watchexec

~
❯ ls ~/.cargo/bin/fnm/
black   dprint   flask         grip   isort-identify-imports  mdformat  pygmentize  pylint-config  symilar
blackd  epylint  get_objgraph  isort  markdown-it             poetry    pylint      pyreverse      undill
```_
passcod commented 2 years ago

--bin-dir is not where things are installed, that's --install-path. --bin-dir is where the binaries are in the archive (it's also misnamed, and should be bin-path, as it's the full path including filename (#380))

passcod commented 2 years ago

We should definitely guard against looking outside the archive when doing those operations (#379) but technically binstall did do what you told it to. Kind of.

NobodyXu commented 2 years ago

I use ~/.local/bin as a target --bin-dir.

bin-dir is dir name used in extracting the archive.

To specify the installation path, use --install-path

azzamsa commented 2 years ago

Thanks.

Works like a charm :tada:

❯ cargo binstall fnm --pkg-url="https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-linux.zip" --pkg-fmt Zip --bin-dir "{ bin }" --install-path ~/.local/bin

I will maximize the use of binstall, as: 1) using package manager gets outdated package 2) cargo install took a very long time on old hardware. Wasting time and resource 3) Writing shell scripts for each package is time consuming.

Is it okay for me to open a PR that add /examples directory for installing unsupported packages?


Update:

Any way for binsall to make the binary executable automatically? (chmod +x)

.rwxr-xr-x@   208 user  5 Sep 13:03 flask*
lrwxrwxrwx@    11 user 14 Sep 09:32 fnm -> fnm-v1.31.1
.rw-r-----@ 6.8Mi user 14 Sep 09:32 fnm-v1.31.1
.rwxr-x--x@ 1.6Ki user 12 Sep 14:36 get_objgraph*
.rwxr-xr-x@   203 user  5 Sep 13:03 grip*
.rwxr-xr-x@   209 user 12 Sep 14:36 isort*
NobodyXu commented 2 years ago

Any way for binsall to make the binary executable automatically? (chmod +x)

I think it might be that the upstream fnm might forget to include the unix attribute when packing the archive.

Is it okay for me to open a PR that add /examples directory for installing unsupported packages?

IMHO you can modify that README directly since cargo-binstall is not a library crate, not many people would check examples/.

azzamsa commented 2 years ago

Hi. Is there any way to tell binstall not to append version to binary?

cargo binstall fnm --no-symlinks --pkg-url="https://github.com/Schniz/fnm/releases/download/v1.31.1/fnm-linux.zip" --pkg-fmt Zip --bin-dir "{ bin }" --install-path /tmp/foo
❯ ls /tmp/foo
broot-v1.14.3  fnm-v1.31.1
azzamsa commented 2 years ago

I think it might be that the upstream fnm might forget to include the unix attribute when packing the archive.

Thanks, reported the issue https://github.com/Schniz/fnm/issues/805

passcod commented 2 years ago

any way to tell binstall not to append version to binary?

Ack! Yeah, --no-symlinks really should do that instead of the current thing. I'll open up a new issue for it

NobodyXu commented 2 years ago

@azzamsa v0.13.1 is released!

azzamsa commented 2 years ago

:tada: wow!