Install multiple versions of a binary?

I'm unsure how to install multiple versions of a binary with cargo. In my case I'd like to have mdbook@^0.4, and mdbook@^0.5

One option is to download the repo, build it, and rename the binary so there isn't a clash.

Any other suggestions?

ChatGPT gave me a useful suggestion:

cargo install mdbook --version ^0.5 --root /tmp/stage-mdbook-0.5
mv /tmp/stage-mdbook-0.5/bin/mdbook ~/.cargo/bin/mdbook-0.5

It works perfectly, I just needed to source my .zshrc file afterwards.

BTW, mdbook version 0.5 looks awesome :smile:

One option is to install each app in its own directory:

/opt/PACKAGE-VERSION/

Then use symlinks to control access:

ln -s /opt/PACKAGE-VERSION/bin/name /usr/bin/name-VERSION

An alternative would be to set up aliases in your shell’s rc file:

alias name-VERSION=/opt/PACKAGE-VERSION/bin/name

Personally, I would always go with the symlinks. They are easy to manage, the package can be removed cleanly, and searching for dangling symlinks is straightforward.

1 Like