diff --git a/conan/internal/cache/cache.py b/conan/internal/cache/cache.py index 03165dc334b..6ecfe629fd8 100644 --- a/conan/internal/cache/cache.py +++ b/conan/internal/cache/cache.py @@ -23,12 +23,9 @@ def __init__(self, base_folder, db_filename): def _create_path(self, relative_path, remove_contents=True): path = self._full_path(relative_path) if os.path.exists(path) and remove_contents: - self._remove_path(relative_path) + rmdir(path) os.makedirs(path, exist_ok=True) - def _remove_path(self, relative_path): - rmdir(self._full_path(relative_path)) - def _full_path(self, relative_path): # This one is used only for rmdir and mkdir operations, not returned to user # or stored in DB diff --git a/conans/client/conf/config_installer.py b/conans/client/conf/config_installer.py index 4501644f0c2..67411f6b7f2 100644 --- a/conans/client/conf/config_installer.py +++ b/conans/client/conf/config_installer.py @@ -47,7 +47,7 @@ def _hide_password(resource): def tmp_config_install_folder(cache): tmp_folder = os.path.join(cache.cache_folder, "tmp_config_install") # necessary for Mac OSX, where the temp folders in /var/ are symlinks to /private/var/ - tmp_folder = os.path.realpath(tmp_folder) + tmp_folder = os.path.abspath(tmp_folder) rmdir(tmp_folder) mkdir(tmp_folder) try: diff --git a/conans/test/functional/command/test_custom_symlink_home.py b/conans/test/functional/command/test_custom_symlink_home.py new file mode 100644 index 00000000000..091ace37e7f --- /dev/null +++ b/conans/test/functional/command/test_custom_symlink_home.py @@ -0,0 +1,24 @@ +import os +import platform + +import pytest + +from conans.test.utils.scm import create_local_git_repo +from conans.test.utils.test_files import temp_folder +from conans.test.utils.tools import TestClient +from conans.util.files import save + + +@pytest.mark.skipif(platform.system() == "Windows", reason="Uses symlinks") +def test_custom_symlinked_home_config_install(): + base_cache = temp_folder() + real_cache = os.path.join(base_cache, "real_cache") + os.makedirs(real_cache) + symlink_cache = os.path.join(base_cache, "symlink_cache") + os.symlink(real_cache, symlink_cache) + origin_folder = temp_folder() + save(os.path.join(origin_folder, "myfile.txt"), "some contents") + create_local_git_repo(folder=origin_folder) + c = TestClient(cache_folder=symlink_cache) + c.run(f'config install "{origin_folder}" --type=git') + assert "Copying file myfile.txt to" in c.out