Write shebang recipes to $XDG_RUNTIME_DIR (#2128)

This commit is contained in:
Casey Rodarmor 2024-06-05 21:03:14 +02:00 committed by GitHub
parent 7c30fb4944
commit af249dbce1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View File

@ -20,7 +20,7 @@ pub(crate) enum Error<'src> {
token: Token<'src>, token: Token<'src>,
output_error: OutputError, output_error: OutputError,
}, },
CacheDirIo { RuntimeDirIo {
io_error: io::Error, io_error: io::Error,
path: PathBuf, path: PathBuf,
}, },
@ -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}")?, 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} => { ChooserInvoke { shell_binary, shell_arguments, chooser, io_error} => {
let chooser = chooser.to_string_lossy(); let chooser = chooser.to_string_lossy();
write!(f, "Chooser `{shell_binary} {shell_arguments} {chooser}` invocation failed: {io_error}")?; write!(f, "Chooser `{shell_binary} {shell_arguments} {chooser}` invocation failed: {io_error}")?;
@ -407,6 +404,9 @@ impl<'src> ColorDisplay for Error<'src> {
write!(f, "Recipe `{recipe}` was not confirmed")?; write!(f, "Recipe `{recipe}` was not confirmed")?;
} }
RegexCompile { source } => write!(f, "{source}")?, 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)?, Search { search_error } => Display::fmt(search_error, f)?,
Shebang { recipe, command, argument, io_error} => { Shebang { recipe, command, argument, io_error} => {
if let Some(argument) = argument { if let Some(argument) = argument {

View File

@ -353,9 +353,9 @@ impl<'src, D> Recipe<'src, D> {
let tempdir = match &context.settings.tempdir { let tempdir = match &context.settings.tempdir {
Some(tempdir) => tempdir_builder.tempdir_in(context.search.working_directory.join(tempdir)), Some(tempdir) => tempdir_builder.tempdir_in(context.search.working_directory.join(tempdir)),
None => { None => {
if let Some(cache_dir) = dirs::cache_dir() { if let Some(runtime_dir) = dirs::runtime_dir() {
let path = cache_dir.join("just"); let path = runtime_dir.join("just");
fs::create_dir_all(&path).map_err(|io_error| Error::CacheDirIo { fs::create_dir_all(&path).map_err(|io_error| Error::RuntimeDirIo {
io_error, io_error,
path: path.clone(), path: path.clone(),
})?; })?;

View File

@ -5,8 +5,8 @@ pub(crate) fn tempdir() -> TempDir {
builder.prefix("just-test-tempdir"); builder.prefix("just-test-tempdir");
if let Some(cache_dir) = dirs::cache_dir() { if let Some(runtime_dir) = dirs::runtime_dir() {
let path = cache_dir.join("just"); let path = runtime_dir.join("just");
fs::create_dir_all(&path).unwrap(); fs::create_dir_all(&path).unwrap();
builder.tempdir_in(path) builder.tempdir_in(path)
} else { } else {