question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Can't create package that has symlinks when the conan cache is a symlink

See original GitHub issue

When the conan cache dir (~/.conan) is a symlink (for /tmp/.conan for example) and I’m trying to create a package that includes internal symlinks, the conan create command fails. The failure point is when the export_source folder contents (in the cache) gets copied over to the source dir. Looking at: https://github.com/conan-io/conan/blob/ff7b8e6703e8407773968517d68424b9ec59aa30/conans/util/files.py#L412 You can see that the usage of os.path.realpath would resolve the src’s symlink, which would completely throw off the os.path.relpath call. The solution is to simply remove the os.path.realpath:

out_of_source = os.path.relpath(linkto, src).startswith(".")

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 18.04
  • Compiler+version: Any
  • Conan version: 1.40.0
  • Python version: 3.8.5

Steps to reproduce (Include if Applicable)

mkdir /tmp/.conan
ln -s /tmp/.conan -t ~/
conan new symlink_bug/0.1.0
touch original_file
ln -s original_file link_file
# add the following code to beginning of SymlinkBugConan::build()
#        with open('link_file', 'r') as f:
#            print("link_file found!")
conan create .

Result:

ERROR: symlink_bug/0.1.0: Error in build() method, line 33
        with open('link_file', 'r') as f:
        FileNotFoundError: [Errno 2] No such file or directory: 'link_file'

Expected Result: Package gets created

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, Sep 14, 2021

Because the intent of Python devs was to deprecate distutils implementation in favor of shutil one (https://bugs.python.org/issue4843), and Conan necessary support (2.7, 3.5, 3.6…) didn’t implement the necessary functionality in shutil, raising if the directory already exists (only copying to an empty directory). Apparently in 3.8 it is possible, but Conan still needs to support 3.6, so not a possibility.

0reactions
tapiacommented, Sep 20, 2021

Just for the record, the PR related to this issue is #9584

Read more comments on GitHub >

github_iconTop Results From Across the Web

self.copy with symlinks=True does not copy symlink if the ...
The advantage of this method is that the cache directory is only changing if I change the symlink. And secondly every terminal uses...
Read more >
Methods — conan 1.14.5 documentation
source()¶. Method used to retrieve the source code from any other external origin like github using $ git clone or just a regular...
Read more >
Conan is looking for libA.so.1 instead of libA.so - Stack Overflow
It seems like you are copying only libA.so which is a symbolic link to libA.so.1. The problem is not Conan, but how you...
Read more >
Protocol Error Symlink Needle Bin Needle
You create a symbolic link from etcapache2sites-enabledmysite to. ... We were ignoring cache manages pairs of protocol error symlink needle bin needle.
Read more >
build - Build Packages — colcon documentation
--symlink-install: Use symlinks instead of copying files from the source and build directories where possible. --test-result-base TEST_RESULT_BASE: The base ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found