According to the man page for cargo install:
The installation root is determined, in order of precedence: • --root option • CARGO_INSTALL_ROOT environment variable • install.root Cargo config value <https://doc.rust-lang.org/cargo/reference/config.html> • CARGO_HOME environment variable • $HOME/.cargo
I have a multi-binary install. One binary is a CLI app for users, the other is a daemon that runs in the background. The CLI needs to set up some things with the daemon, but to do so, it must know where the daemon binary is installed.
I can use the
env! macro from the std library to find the
CARGO_HOME environment variables and get a path to my binary. But only if the default install happens.
If the user installs using
--root or for some reason has some other uncommon configuration, then I see no way to find the installation location. Should I just include a note to never do those things in my documentation, or is there another way to get the install path for certain? Thank you.