Forc is using different versions for different commands, why is this happening?

This is a result of mixing different methods of installment. You can fix this by removing everything and reinstalling with either fuelup or cargo. Mixing these two together creates duplicate binaries with different versions in your Path.

6 Likes

Nice explanation!

To add to this, you can find out exactly which “version” of a command is being used with the which command. For example:

$ which forc-fmt
/nix/store/mzijvfwbq8vq7cxv7ih2sk3gxmhq0y6l-forc-fmt-0.31.1/bin/forc-fmt

Here we can see the version of forc-fmt I have in use is one that I have installed via Nix. On your system this might be /home/USER/.fuelup/bin/forc-fmt, /home/USER/.cargo/bin/forc-fmt or similar.

PATH

On all Unix systems, if we have multiple versions of a command installed, the version that is selected is based on the order in which their paths appear within the PATH environment variable.

You can inspect your PATH with:

echo $PATH

This will output a list of :-separated paths which describe the order in which your system will search for executable commands.

If you want to change this order (e.g. to give ~/.fuelup/bin priority over ~/.cargo/bin), I suggest looking up the recommended way to edit the PATH environment variable on your OS or distribution, as the approach is different on almost every platform.

2 Likes

As of version 0.14, fuelup should now warn during installation and updating if any executables with the same name as a fuel component already exist on the PATH.

You can check out the PR for details:

3 Likes