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

fix: error message in link_dependencies collision #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TyberiusPrime
Copy link
Contributor

Just another case where we can exactly pinpoint the two causing pkgs.

Previous error message

FileExistsError: [Errno 17] File exists: '/nix/store/jyzfv9z981s6x1kqrf2k4k9hh0l5na38-cfxdb-23.12.1/LICENSE' -> '/nix/store/b2ayknndk4w7hhydibf32z7vi6y2r57p-test-venv/LICENSE'

new

FileExistsError: Trying to link /nix/store/jyzfv9z981s6x1kqrf2k4k9hh0l5na38-cfxdb-23.12.1/LICENSE to /nix/store/4k7px3i153anj7h46fiw29qanvrz7iny-test-venv/LICENSE, but that already exists. It links to /nix/store/nlkfllagsi9x98agw7rlxgvh5l3h11jx-crossbar-22.6.1/LICENSE.

os.symlink(path, target_path)
except FileExistsError:
raise FileExistsError(
f"Trying to link {path} to {target_path}, but that already exists. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the phrasing a little odd. Maybe change it to something like

FileExistsError(f"Linking path {target_path} to {path} failed. Existing target is a {"symlink" if target_path.is_symlink() else "regular file"}")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important part is that it tells you what the symlink is pointing to.
Maybe like this:

except FileExistsError:
                    msg = f"Linking path {target_path} to {path} failed because it already existed."
                    if Path(target_path).is_symlink():
                        msg += f" It is a symlink resolving to {Path(target_path).resolve()}."
                    raise FileExistsError(msg)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants