Skip to content

Commit

Permalink
Write shebang recipes to $XDG_RUNTIME_DIR (#2128)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jun 5, 2024
1 parent 7c30fb4 commit af249db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) enum Error<'src> {
token: Token<'src>,
output_error: OutputError,
},
CacheDirIo {
RuntimeDirIo {
io_error: io::Error,
path: PathBuf,
},
Expand Down Expand Up @@ -287,9 +287,6 @@ impl<'src> ColorDisplay for Error<'src> {
}?,
OutputError::Utf8(utf8_error) => write!(f, "Backtick succeeded but stdout was not utf8: {utf8_error}")?,
}
CacheDirIo { io_error, path } => {
write!(f, "I/O error in cache dir `{}`: {io_error}", path.display())?;
}
ChooserInvoke { shell_binary, shell_arguments, chooser, io_error} => {
let chooser = chooser.to_string_lossy();
write!(f, "Chooser `{shell_binary} {shell_arguments} {chooser}` invocation failed: {io_error}")?;
Expand Down Expand Up @@ -407,6 +404,9 @@ impl<'src> ColorDisplay for Error<'src> {
write!(f, "Recipe `{recipe}` was not confirmed")?;
}
RegexCompile { source } => write!(f, "{source}")?,
RuntimeDirIo { io_error, path } => {
write!(f, "I/O error in runtime dir `{}`: {io_error}", path.display())?;
}
Search { search_error } => Display::fmt(search_error, f)?,
Shebang { recipe, command, argument, io_error} => {
if let Some(argument) = argument {
Expand Down
6 changes: 3 additions & 3 deletions src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ 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() {
let path = cache_dir.join("just");
fs::create_dir_all(&path).map_err(|io_error| Error::CacheDirIo {
if let Some(runtime_dir) = dirs::runtime_dir() {
let path = runtime_dir.join("just");
fs::create_dir_all(&path).map_err(|io_error| Error::RuntimeDirIo {
io_error,
path: path.clone(),
})?;
Expand Down
4 changes: 2 additions & 2 deletions tests/tempdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub(crate) fn tempdir() -> TempDir {

builder.prefix("just-test-tempdir");

if let Some(cache_dir) = dirs::cache_dir() {
let path = cache_dir.join("just");
if let Some(runtime_dir) = dirs::runtime_dir() {
let path = runtime_dir.join("just");
fs::create_dir_all(&path).unwrap();
builder.tempdir_in(path)
} else {
Expand Down

0 comments on commit af249db

Please sign in to comment.