Skip to content
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

Softlinks were not getting created properly earlier. --always-softlin… #2813

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ macro(libmamba_create_target target_name linkage output_name)
${LIBXML2_LIBRARY}
${ICONV_LIBRARY}
${CHARSET_LIBRARY}
zstd::libzstd_static
zstd::libzstd_static
${LZ4_LIBRARY}
${LZO2_LIBRARY}
${BZIP2_LIBRARIES}
Expand Down
25 changes: 20 additions & 5 deletions libmamba/src/core/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,6 @@ namespace mamba
{
bool copy = path_data.no_link || m_context->always_copy;
bool softlink = m_context->always_softlink;

if (!copy && !softlink)
{
std::error_code lec;
Expand Down Expand Up @@ -786,9 +785,25 @@ namespace mamba
}
if (copy)
{
fs::copy(src, dst);
LOG_TRACE << "copied '" << src.string() << "'" << std::endl
<< " --> '" << dst.string() << "'";
try
{
fs::copy(src, dst);
LOG_TRACE << "copied '" << src.string() << "'" << std::endl
<< " --> '" << dst.string() << "'";
}
catch (const std::filesystem::filesystem_error& ex)
{
Console::stream() << "could not copy: " << src.string() << " -> "
<< dst.string() << ": " << ex.what();
if (fs::exists(dst))
{
LOG_TRACE << dst.string() << " already exists" << std::endl;
}
else
{
throw ex;
}
}
}
}
else if (path_data.path_type == PathType::SOFTLINK)
Expand All @@ -807,6 +822,7 @@ namespace mamba
+ std::to_string(static_cast<int>(path_data.path_type))
);
}

return std::make_tuple(
path_data.sha256.empty() ? validation::sha256sum(dst) : path_data.sha256,
rel_dst.string()
Expand Down Expand Up @@ -1093,7 +1109,6 @@ namespace mamba
LOG_TRACE << "Adding package to prefix metadata at '" << meta.string() << "'";
std::ofstream out_file = open_ofstream(meta);
out_file << out_json.dump(4);

if (!m_clobber_warnings.empty())
{
LOG_WARNING << "[" << f_name
Expand Down
2 changes: 2 additions & 0 deletions micromamba/tests/test_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_copy(self, existing_cache, test_pkg):
def test_always_softlink(self, existing_cache, test_pkg):
create(
"xtensor",
"r-base",
"-n",
TestLinking.env_name,
"--json",
Expand All @@ -101,6 +102,7 @@ def test_cross_device(self, allow_softlinks, always_copy, existing_cache, test_p
pytest.skip("o/s is not linux")

create_args = ["xtensor", "-n", TestLinking.env_name, "--json"]

if allow_softlinks:
create_args.append("--allow-softlinks")
if always_copy:
Expand Down