Open fmarier opened 7 years ago
Just mentioning the obvious, in case someone stumbles on this, but cargo internally uses tempdir
crate, which in turn uses std::env::temp_dir()
. Which means that on linux it consults $TMPDIR
environment variable (and nothing else, like $XDG_RUNTIME_DIR
, which happens to be not noexec
for me, sigh) before falling back to /tmp
.
And indeed, TMPDIR=$XDG_RUNTIME_DIR cargo install CRATE
fixes cargo install for me.
As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it.
I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect?
The team would be especially grateful if such a comment included details such as:
Thank you for contributing!
(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)
If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!
This is still an issue. The reproduction steps in https://github.com/rust-lang/cargo/issues/4350#issue-247238683 are still accurate and the work-around in https://github.com/rust-lang/cargo/issues/4350#issuecomment-340215811 still works.
I ran into this on a portable VSCode install on windows. I've raised https://github.com/microsoft/vscode/issues/83998 with them.
Pragmatically any temp dir that's accesssable and writable is fair game. Could we check if it's writable before we use it?
Feel free to label this with 'enterprise-adoption-papercut' or some such as it's enterprises that lock down temp dirs.
This is still a problem, i just encountered this.
Issue still exists, but the workaround provided by albel727 works like a charm!! So grateful! Been trying to find a solution to this for quite some time--never thought to check fstab to see that my /tmp directory is mounted as noexec.
See https://github.com/kubernetes/kubernetes/issues/48912
There's a common control that requires noexec
for tmpfs
mounts. This means Cargo is to be changed.
So far the proposed solutions are
Some initial questions that need to be worked out for this to move forward
The cargo
command must be called cargo
as it uses its executable name to determine what it is. My first attempt at a cargo-specific TMPDIR was to rename cargo
to cargo-real
and then have a bash script set TMPDIR and then pass its arguments to cargo. This didn't work. So what I ended up with was (this is on Linux):
mkdir /path/to/cargo/tmp
(or somewhere, wherever you want tmp files to go) mkdir ~/.cargo/bin/real
mv ~/.cargo/bin/cargo ~/.cargo/bin/real
~/.cargo/bin/cargo
with the following content:
#!/bin/bash
export TMPDIR=/path/to/cargo/tmp
~/.cargo/bin/real/cargo "$@"
Hopefully this illustrates how to wrap binaries with simple scripts to set things like environment variables. (For example with nvim I use this trick so that e.g. chad
loads nvim with its config from ~/.config/NvChad
rather than ~/.config/nvim
as another example of this trick.)
Hi,
I am having a similar issue where the IT policy of my company restricts .exe files inside the TMP folder to be executed. What would be a proper workaround for that?
Thanks
I am having a similar issue where the IT policy of my company restricts .exe files inside the TMP folder to be executed. What would be a proper workaround for that?
A workaround might be to try setting the TMP
environment variable in the console to somewhere you can run exe files from.
Per-user build cache may help here https://github.com/rust-lang/cargo/issues/5931, if we move install temporary directory into it.
Per-user caches won't completely solve it because we'll still be compiling to the target directly for anything not (yet) in the cache. If we had rust-lang/rfcs#3371 and made it the default, even for cargo install
, then that might do it.
My
/tmp
directory is mounted asnoexec
from within/etc/fstab
:and when I try to install sccache, I get the following error:
It would be nice if cargo could either use a different directory to put executables in, or at the very least warn about this limitation and give a clearer error message.