Skip to content

Commit

Permalink
Fix locking error (#3572)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hind-M authored Oct 30, 2024
1 parent b94b30e commit 94bb087
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libmamba/src/core/prefix_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ namespace mamba
return;
}

// Run `pip freeze`
// Run `pip inspect`
std::string out, err;

const auto get_python_path = [&]
Expand Down
11 changes: 10 additions & 1 deletion libmamba/src/core/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,18 @@ namespace mamba
, m_locked(false)
{
std::error_code ec;

// Check if `path` exists
if (!fs::exists(path, ec))
{
throw_lock_error(fmt::format("Could not lock non-existing path '{}'", path.string()));
// If `path` doesn't exist, consider creating the directory
// (and its parents if they don't exist)
if (!fs::create_directories(path, ec))
{
throw_lock_error(
fmt::format("Could not create directory '{}': {}", path.string(), ec.message())
);
}
}

if (fs::is_directory(path))
Expand Down

0 comments on commit 94bb087

Please sign in to comment.