Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
18.09k stars 459 forks source link

support cargo-binstall #1280

Open ahaoboy opened 2 weeks ago

ahaoboy commented 2 weeks ago

https://github.com/cargo-bins/cargo-binstall

cargo-binstall can skip the compilation process. fnm has released executable programs for different platforms, but it does not support cargo-binstall.

cargo binstall fnm
ahaoboy commented 2 weeks ago

On Ubuntu, It will use the quickInstall source, and on Windows, fnm will compile from source.

SkySingh04 commented 2 weeks ago

@ahaoboy This sounds like a fun issue to work on! I'd love to pick it up.

My Approach is simple :

Let me know if this approach works, and I'd be happy to get started!

Schniz commented 2 weeks ago

This sounds good and I’d love to see that contributed! I suggest stacking these changes on a fork so we see that it works (all the release process has a very slow feedback loop). I think it will be best to first have both fnm-macos.zip etc along to the new files, so we can make sure all installers are updated (like winget, brew, apt etc). We just symlink or duplicate release artifacts to avoid breaking :) if there are any issues I can try to help

Schniz commented 2 weeks ago

Making cross compile work faster and nicer is pretty cool. Maybe with cargo zigbuild or whatever it is called

ahaoboy commented 2 weeks ago

It is not clear whether fnm-macos is currently x86_64 or arm64, perhaps it should support both

ahaoboy commented 2 weeks ago

Making cross compile work faster and nicer is pretty cool. Maybe with cargo zigbuild or whatever it is called

I often use this action, it is easier to use than cargo-dist

https://github.com/taiki-e/upload-rust-binary-action

SkySingh04 commented 2 weeks ago

@Schniz @ahaoboy Before I proceed with adding cargo-binstall support and updating the release process, I wanted to check on the current binaries that are already available for fnm.

Could you confirm which binaries are currently being generated for each platform (e.g., fnm-x86_64-apple-darwin.zip, fnm-arm64-apple-darwin.zip, etc.)? This will help ensure I update the install script and CI process correctly without duplicating existing work.

This is in referrence to any existing work/ open PR's on the same

ahaoboy commented 2 weeks ago

cargo-binstall has full list, but we don't need support all of them https://github.com/cargo-bins/cargo-binstall/releases

SkySingh04 commented 2 weeks ago

@ahaoboy @Schniz I have made a PR with the binstall.toml and CI changes, can you help me with what other changes are required to support the same?

ahaoboy commented 2 weeks ago

Because actions/upload-artifact@v4 is used to compress files, CRC calculation errors occur. https://github.com/cargo-bins/cargo-binstall/issues/1080. Therefore, zip packages such as fnm-windows.zip cannot be used even if metadata is added. It needs to be tested to prevent this problem.

You can test whether the local Cargo.toml is configured correctly by the following command

 cargo binstall --manifest-path=./Cargo.toml fnm --force

 WARN resolve: Error while downloading and extracting from fetcher github.com: Failed to extract zipfile: a computed CRC32 value did not match the expected value

Also, should the meta information be added to Cargo.toml? Using binstall.toml will duplicate package information, and I'm not sure if it will work.

[package.metadata.binstall]
pkg-fmt = "zip"
bin-dir = "fnm{ binary-ext }"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-url = "{ repo }/releases/download/v{ version }/fnm-windows.zip"

[package.metadata.binstall.overrides.x86_64-apple-darwin]
pkg-url = "{ repo }/releases/download/v{ version }/fnm-macos.zip"

[package.metadata.binstall.overrides.x86_64-unknown-linux-musl]
pkg-url = "{ repo }/releases/download/v{ version }/fnm-linux.zip"