-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shebang recipes no longer works when HOME is read-only #2123
Comments
Thank you for opening this issue! I changed the location shebang scripts are written to in #2067. The precipitating issue was that someone's I sort of had a hunch that #2067 would break something else and I didn't know what, but it makes sense that read-only home would be the culprit. Thinking out loud here, I'm wondering which is more common, having a read-only homedir or a noexec tmpdir? #2067 wasn't a particularly principled choice, I got a report of an issue with a particular configuration and made a change which fixed things for that configuration, but there is now a new issue with a different configuration, so it would be perfectly reasonable to just change it back. Also, I'm not entirely sure that the cache dir is the right way to put shebang scripts anyways. Shebang scripts aren't reused once they're written, so there's no benefit to persisting them in the cache dir, vs having them be cleared on restart, as they would be in the tempdir. Maybe the way to fix this is:
|
What about using
See also systemd/systemd#4081 (comment) It'd make sense to not use world writable temporary locations from a security perspective anyway, so maybe cache_dir could be used as a fallback for Windows and Mac. Tested, that using the below diff is sufficient to fix build in nixpkgsdiff --git a/src/recipe.rs b/src/recipe.rs
index 97dc847..230f685 100644
--- a/src/recipe.rs
+++ b/src/recipe.rs
@@ -353,7 +353,7 @@ impl<'src, D> Recipe<'src, D> {
let tempdir = match &context.settings.tempdir {
Some(tempdir) => tempdir_builder.tempdir_in(context.search.working_directory.join(tempdir)),
None => {
- if let Some(cache_dir) = dirs::cache_dir() {
+ if let Some(cache_dir) = dirs::runtime_dir() {
let path = cache_dir.join("just");
fs::create_dir_all(&path).map_err(|io_error| Error::CacheDirIo {
io_error,
diff --git a/tests/tempdir.rs b/tests/tempdir.rs
index a7d2a5f..17a6f63 100644
--- a/tests/tempdir.rs
+++ b/tests/tempdir.rs
@@ -5,7 +5,7 @@ pub(crate) fn tempdir() -> TempDir {
builder.prefix("just-test-tempdir");
- if let Some(cache_dir) = dirs::cache_dir() {
+ if let Some(cache_dir) = dirs::runtime_dir() {
let path = cache_dir.join("just");
fs::create_dir_all(&path).unwrap();
builder.tempdir_in(path) |
I just released 1.28, which uses the runtime dir, which seems like the correct choice anyways, since it should be cleared between restarts. Let me know if that works! |
Everything looks good so far! 🚀 |
Great! |
As the temporary directories are now created in
~/.cache
on Linux by default.Figured this out while trying to update Just in nixpkgs1.
IMO, it would be nice to fall back gracefully to the platform's temporary directory
when we could not use the cache directory. I am willing to open a PR with something like the following diff, if you find this acceptable.
Footnotes
https://github.com/NixOS/nixpkgs/pull/316156 ↩
The text was updated successfully, but these errors were encountered: