10 ms·
I'm curious why `npm` is used to install a `rust` binary?
by betaby 8mo ago
I'm curious why `npm` is used to install a `rust` binary?
- varenc 8mo agoI found that strange as well. My guess is that `npm` is just the package manager people are most likely to already have installed and doing it this way makes it easy. They might think asking people to install Cargo is too much effort. Wonder if the pattern of using npm to install non-node tools will keep gaining traction.
- freakynit 8mo agoWhy not just downloadable binary then?
- varenc 8mo agoFor many, installing something with npm is still easier. It chooses the right binary for your OS/architecture, puts it on your PATH, and streamlines upgrades. Their Github releases provides the binaries, as well as a `curl ... | sh` install method and a guide to use github releases attestation which I liked.
- freakynit 8mo agoHmm, that's right... thanks..
- krzyk 8mo agoI feel better with `curl ... | sh` than with npm. npm suggests projects written in js, which is not something I'm comfortable. It is nice to see that this is not JS, but Rust.
- varenc 8mo agoAgreed! The `curl ... | sh` is sketchy, but it's more obviously a security risk and easier to inspect. With install hooks, `npm install ...` also allows arbitrary code execution when you run it, but this is less obvious.
- patates 8mo agoThey have them: https://github.com/googleworkspace/cli/releases https://github.com/googleworkspace/cli/releases
- bigstrat2003 8mo agoMost people aren't going to have npm installed though. Nobody outside of web devs uses it.
- sankalpmukim 8mo ago"Most people" are webdevs Bracing for getting cancelled
- patates 8mo agoA lot of people who are not web devs use it, that's what I see. I even saw some mainframe developers use npx to call some tool on some data dump. Also, this is a web project anyway. Google Workspace is web based, so while there is a good chance that the users aren't web developers, it's a better chance that they have npm than anything else. In the case that they don't, releases can be downloaded directly too: https://github.com/googleworkspace/cli/releases https://github.com/googleworkspace/cli/releases
- gempir 8mo agoIf you had to pick one package manager that was most likely installed across all the different user machines in the world, I'd say npm is a pretty good bet.
- wiseowise 8mo agoPip.
- m000 8mo agoIt's still weird. Why not just use an effing install.sh script like everybody else? And don't tell me "security". Because after installation you will be running an unknown binary anyway.
- brunoborges 8mo agoNPM as a cross platform package distribution system works really well. The install script checks the OS and Arch, and pulls the right Rust binary. Then, they get upgrade mechanism out of the box too, and an uninstall mechanism. NPM has become the de facto standard for installing any software these days, because it is present on every OS.
- danpalmer 8mo agoTo my knowledge NPM isn't shipped in _any_ major OSes. It's available to install on all, just like most package managers, but I'm not sure it's in the default distributions of macOS, Windows, or the major Linux distros?
- anilgulecha 8mo agoNo package manager is. But of the ones that are installed by users, npm is probably the most popular.
- deleted 8mo ago[deleted]
- spinagon 8mo agoWhat about pip? It's either installed or immediately available on many OSes
- cobbal 8mo agoThey're not doing so here, but shipping a wasm-compiled binary with npm that uses node's WASI API is a really easy way to ship a cross-platform CLI utility. Just needs ~20 lines of JS wrapping it to set up the args and file system.
- mountainriver 8mo agoDoesn’t this seem excessive over just using rust’s cross platform builds?
- csomar 8mo agoThere's no such thing as a truly "cross-platform" build. Depending on what you use, you might have to target specific combinations of OS and processor architecture. That's actually why WASM (though they went with WASI) is a better choice; especially for libraries, since anyone can drop it into their environment without worrying about compatibility.
- jitl 8mo agothere’s 3 os and 2 architectures minus darwin-amd64 so you just need to do 5 builds to avoid the WASM performance tax. (freebsd runs linux binaries and the openbsd people probably want to build from source anyways)
- rendaw 8mo agoI think GP's point is that instead of having 3 target-specific rust-built binaries, they have 3 target-specific node binaries running rust-built wasm plus wrapper code.
- Lord_Zero 8mo agoCan you link to a sample of how I can do this?
- taskylizard 8mo agohttps://axodotdev.github.io/cargo-dist/ https://axodotdev.github.io/cargo-dist/
- jamesmishra 8mo agoWhy should the package's original language matter? When I use apt-get, I have no idea what languages the packages were written in.
- r2champloo 8mo agoInteresting fact, because cargo builds every tool it downloads from source, you can’t actually run cargo install on Google laptops internally.
- efreak 8mo agoI use cargo-binstall, which supports quick install and a couple other methodsfor downloading binaries for rust packages