Skip to content

Symlinked directory breaks python_bootstrap_binary #1342

Description

@lunagl

I ran into this by accident because I had symlinked the prelude directory into the project I was trying to compile (#1327 ).

When that is the case, prelude//kotlin/tools/compile_kotlin:compile_kotlin ends up being built as symlinked dir, as shown by find:

$ find ./ -type l
./buck-out/v2/art/prelude/5c1b01ec01a662a2/kotlin/tools/compile_kotlin/__compile_kotlin__/__compile_kotlin__/compile_kotlin.py
./buck-out/v2/art/prelude/5c1b01ec01a662a2/kotlin/tools/compile_kotlin/__compile_kotlin__/__compile_kotlin__/utils.py
./prelude

With this output however, running compile_kotlin.py fails, because the python interpreter can't properly handle the symlink situation. I'm guessing when given the main entrypoint path it first follows any symlinks to resolve it's actual location, and then operators from within that directory, causing the following error:

Traceback (most recent call last):
  File ".../buck-out/v2/art/prelude/5c1b01ec01a662a2/kotlin/tools/compile_kotlin/__compile_kotlin__/__compile_kotlin__/compile_kotlin.py", line 21, in <module>
    import utils
ModuleNotFoundError: No module named 'utils'

Up until just recently, I would also always see a __pycache__ directory being created next to the compile_kotlin.py source file in the prelude, further supporting my theory. For some reason that does not happen anymore now, might be a recent buck2 commit that changed something here. Not gonna do a bisect for now because I don't think it's particularly important tho.


On the other hand, if the prelude is not symlinked but copied into the project, or if the bundled prelude is used, the source files are copied into the output directory, which makes everything work as expected:

$ find ./ -type l
<no output>

The weird thing however is that according to buck2 log show, the symlinked_dir action is executed in both scenarios. So from that I would assume that the symlinking as seen in the error case is actually the correct/intended behavior, which makes this whole thing even weirder. Any ideas what's going on here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpreludeRelated to integration/preludepythonPython prelude

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions