Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into perf/prefix-always-…
Browse files Browse the repository at this point in the history
…sharded
  • Loading branch information
baszalmstra committed Nov 12, 2024
2 parents 559f76c + 8bb8835 commit f2d7251
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
21 changes: 17 additions & 4 deletions crates/rattler_cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ pub mod validation;
mod consts;
pub use consts::{PACKAGE_CACHE_DIR, REPODATA_CACHE_DIR};

/// Returns the default cache directory used by rattler.
/// Determines the default cache directory for rattler.
/// It first checks the environment variable `RATTLER_CACHE_DIR`.
/// If not set, it falls back to the standard cache directory provided by `dirs::cache_dir()/rattler/cache`.
pub fn default_cache_dir() -> anyhow::Result<PathBuf> {
Ok(dirs::cache_dir()
.ok_or_else(|| anyhow::anyhow!("could not determine cache directory for current platform"))?
.join("rattler/cache"))
std::env::var("RATTLER_CACHE_DIR")
.map(PathBuf::from)
.or_else(|_| {
dirs::cache_dir()
.ok_or_else(|| {
anyhow::anyhow!("could not determine cache directory for current platform")
})
// Append `rattler/cache` to the cache directory
.map(|mut p| {
p.push("rattler");
p.push("cache");
p
})
})
}
1 change: 1 addition & 0 deletions crates/rattler_shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readme.workspace = true
[dependencies]
enum_dispatch = { workspace = true }
indexmap = { workspace = true }
fs-err = { workspace = true }
itertools = { workspace = true }
rattler_conda_types = { path="../rattler_conda_types", version = "0.29.0", default-features = false }
serde_json = { workspace = true, features = ["preserve_order"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_shell/src/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
//! This crate provides helper functions to activate and deactivate virtual
//! environments.

use fs_err as fs;
use std::{
collections::HashMap,
ffi::OsStr,
fs,
path::{Path, PathBuf},
process::ExitStatus,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_shell/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn run_in_environment(
let file = tempfile::Builder::new()
.suffix(&format!(".{}", shell.extension()))
.tempfile()?;
std::fs::write(file.path(), shell_script.contents()?)?;
fs_err::write(file.path(), shell_script.contents()?)?;

match shell {
ShellEnum::Bash(_) => Ok(Command::new(shell.executable()).arg(file.path()).output()?),
Expand Down

0 comments on commit f2d7251

Please sign in to comment.