Hello everyone, I encountered a problem. I compiled the binary on one machine, and then when I ran it on another machine, the program panicked. When I printed the call stack information, the line of code where the panic occurred was: What is the path information of the machine when I compile the binary?
It looks like you forgot to include the code you wanted to show.
Setting the environment variable
RUST_BACKTRACE=1 can be helpful for getting it to print the full stack trace in many common cases.
If the reported line is too specific and unclear what is calling it, then check out:
strings my_binary | grep "$HOME will cause binary leakage
If you are looking to change the debuginfo so that it does not refer to a directory on your build machine, you can can pass the
--remap-path-prefix argument to
For example, to replace your home directory path with the string
"~", set this environment variable when running
There is also an unstable
remap-cwd-prefix option that may be more convenient, after it's stabilized.
If I remap the path in the binary file, will it solve the problem of printing out the Home information when I panic?
The remap only applies to compiler-generated strings. That will solve your problem for panics, but it doesn't prevent you or some dependency from doing this, say.
const GOTTEM: &str = env!("HOME");
// Despite the name I used for this example, it's conceivable that
// some crate would do something like this for some HOME-containing
// environment variable non-maliciously, like storing some cargo env
// variable for telemetry blah blah blah something something when
// you have used rustup to install all the rust things in your HOME
Or more generally that information could be captured by build "scripts" that can currently do, well, pretty much anything they want.
So I suggest weighing how sure you want to be relative to how much trust you have in your dependencies. If the remap isn't good enough for you after that consideration, do your development under an account with a generic name at a minimum.
Thanks very much！
thanks very much！