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

poetry.lock at ~/.config/pypoetry incorrect when installing local plugin via wheel due to symbolic links #5849

Closed
spoorn opened this issue Jun 15, 2022 · 2 comments · Fixed by #5850
Labels
kind/bug Something isn't working as expected

Comments

@spoorn
Copy link
Contributor

spoorn commented Jun 15, 2022

  • [ x ] I am on the latest Poetry version.
  • [ x ] I have searched the issues of this repo and believe that this is not a duplicate.
  • [ x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: CentOS 8/Amazon Linux 2
  • Poetry version: 1.2.0b2
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

While investigating #5440, I found out that if I tried to install a plugin using a path that contained a symlink e.g.

poetry self add /mysymlink/workspace/myuser/myproject/dist/myproject-1.0.0-py3-none-any.whl

where mysymlink resolves to say home/myuser, poetry would fail to install the plugin saying FileNotFound.

If I had instead used the real physical path using pwd -P, so I'd do

poetry self add /home/myuser/workspace/myuser/myproject/dist/myproject-1.0.0-py3-none-any.whl

it works just fine.

The problem is, if I originally used the symlink which caused the plugin install via a local wheel file to fail, the second option using the real physical path would also fail afterwards. Even if I had used the real physical path initially, if I remake a new virtualenv and try again, it also fails. After some digging, I found out when poetry tries to get the locked_repository here: https://github.com/python-poetry/poetry/blob/master/src/poetry/packages/locker.py#L454, it's reading from poetry.lock/pyproject.toml in ~/.config/pypoetry.

The ~/.config/pypoetry/poetry.lock has an incorrect relative path to the local wheel file:

...
[package.source]
type = "file"
url = "../../../../home/myuser/workspace/myuser/myproject/dist/myproject-1.0.0-py3-none-any.whl"
...

If I try to reinstall the plugin, it says the file is not found:

...
File /local/home/myuser/workspace/myuser/myproject/dist/myproject-1.0.0-py3-none-any.whl does not exist

It looks like it is missing an extra "../".

So far the only way I found to workaround this is to delete ~/.config/pypoetry every time I want to install the local plugin, but then this means I have to reconfigure poetry every time.

@spoorn spoorn added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 15, 2022
@spoorn spoorn changed the title poetry.lock/pyproject.toml at ~/.config/pypoetry corrupted when installing local plugin via wheel poetry.lock at ~/.config/pypoetry corrupted when installing local plugin via wheel Jun 15, 2022
@spoorn
Copy link
Contributor Author

spoorn commented Jun 15, 2022

Found out the root cause:

If the home directory is a symlink itself, https://github.com/python-poetry/poetry/blob/master/src/poetry/packages/locker.py#L604-L608 is not converting the lock path to the real physical path so the relative path may be incorrect.

An option would be to convert the lock path into the real physical path, before resolving the relative path

spoorn added a commit to spoorn/poetry that referenced this issue Jun 15, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Jun 15, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Jun 15, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Jun 15, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Jun 15, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Jun 15, 2022
@spoorn spoorn changed the title poetry.lock at ~/.config/pypoetry corrupted when installing local plugin via wheel poetry.lock at ~/.config/pypoetry incorrect when installing local plugin via wheel Jun 22, 2022
@spoorn spoorn changed the title poetry.lock at ~/.config/pypoetry incorrect when installing local plugin via wheel poetry.lock at ~/.config/pypoetry incorrect when installing local plugin via wheel due to symbolic links Jul 28, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Aug 3, 2022
spoorn added a commit to spoorn/poetry that referenced this issue Aug 3, 2022
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Aug 4, 2022
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants