-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[fix] inconsistent handling of symbolic links #5914
[fix] inconsistent handling of symbolic links #5914
Conversation
…roperly in Locker
…_nested_editable to resolve symlinks
That failing check on macOS / 3.11-dev is a bit weird. It worked on the last commit, and the only difference since then is that the code was formatted by |
This occurred on another pr too, I think it was the same error as well. |
Any idea how to fix it? If it's simple, I'd be happy to implement it any time. Otherwise, I'll probably wait until when/if it becomes the main hurdle to this PR being accepted. |
I just noticed, I had already submitted a PR for this same fix, except I added some extra tests for it: #5850 |
Duplicated #5850 which is merged |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Resolves: #5425 describes some symptoms, but the root cause seems a bit more complicated.
In the code, paths (i.e. for file and directory package sources) are often normalised using
Path.resolve()
. This "Make the path absolute, resolving any symlinks" (quote). I've got the impression that the general expectation is that all of these locations should be normalised this way, however, the code isn't completely consistent in this regard. There are some pathways in the code where location data isn't treated in the same way, e.g. project root folders are used as supplied bycwd
, which doesn't expand symbolic links. There are several tests as well, that do not take symbolic links into account.Issue #5425 describes the problems I've noticed when coding or when executing Poetry tests in a folder that contained a symbolic link in the path. These are caused by:
Locker
usingrelpath
with resolved package source but unresolved project root paths, leading to unintended complicated relative paths (e.g. for a sub-module located under the project folder)Factory.add_dependency
andFactory.create_dependency
, which don't resolve them eithertest_solver_can_resolve_directory_dependencies_nested_editable
) include unresolved paths, causing test to fail because Poetry does resolve those pathsIn this PR I'm proposing simple fixes to points 1 and 3. The methods in point 2 are in poetry-core's BaseFactory, and although it doesn't require a complicated fix either, it's not as trivial a simply adding
resolve()
to a code line, at least not in here in Poetry, so I'm holding back until I get some feedback. Honestly, this entire thing is probably not a high priority task. I haven't had any real problems when using Poetry, except for the slightly annoying relative path in the locker file, and I haven't seen other related issues either. The only errors I've encountered are poetry's own tests failing. However, I do believe that the code is a bit sloppy in how it handles paths - path sanitization is left up to each module, which do that in different ways, sometimes resolving sometimes not, and test writers obviously didn't think of resolving paths either. My proposed code changes don't fix that. Therefore, yet unknown bugs may remain.Some details about the failing tests I mentioned above:
Pytest results in a folder that contains a symlink in its path:
PR applied:
9 tests are fixed. All the remaining fails are due to Point 2 above. Plus, after PR, relative paths in the locker file are correct (as in path to a sub-folder will be just the sub-folder's name, instead of pointing back to the sub-folder under symlink's target).