Closed AldaronLau closed 3 years ago
Hello and thanks for the issue!
In the just released 0.8.0
(update with cargo install --force rust-script
), the RUST_SCRIPT_BASE_PATH
and other RUST_SCRIPT_*
environment variables are also defined at compilation time, so env!("RUST_SCRIPT_BASE_PATH")
will work.
Let me know if there are any issues related to that!
Doing something like
does not work.
I came up with the following solution:
But it is not completely cross platform, as
PWD
is not defined on Windows (I think unless you're in PowerShell or Git BASH).All of the
CARGO_*
environment variables point inside the./.rust-script
folder, so there's no way to compose a path that points to the current directory.I wonder if it's possible to override
CARGO_MANIFEST_DIR
to point to the directory in which the script is located, or makeenv!("RUST_SCRIPT_BASE_PATH")
work (currentlyRUST_SCRIPT_BASE_PATH
is only defined for the runtime of the script and not during rustc compilation).