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

Error when %TEMP% is a junction to a dir on a letter-less drive #10597

Open
1 task done
grv87 opened this issue Oct 18, 2021 · 6 comments
Open
1 task done

Error when %TEMP% is a junction to a dir on a letter-less drive #10597

grv87 opened this issue Oct 18, 2021 · 6 comments
Labels
help wanted For requesting inputs from other members of the community OS: windows Windows specific type: bug A confirmed bug or unintended behavior

Comments

@grv87
Copy link

grv87 commented Oct 18, 2021

Description

Error when %TEMP% is a junction to a dir on a letter-less drive.

The error looks similar to jazzband/pip-tools#1061, but in pip itself.

Expected behavior

Successful install/reinstall

pip version

21.3

Python version

3.10.0, 3.9.6, 3.8.2

OS

Windows 10 x64

How to Reproduce

  1. Create a volume and don't assign a letter to it
  2. Create dir on this volume
  3. Create a junction on this dir:
    ln--junction junction ‪\\?\Volume{<new volume uuid>}\dir
  4. set TEMP=%cd%\junction
  5. Install some package: pip3 install CrossMap

Output

Traceback (most recent call last):
  File "<python_install_dir>\lib\site-packages\pip\_internal\cli\base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "<python_install_dir>\lib\site-packages\pip\_internal\cli\req_command.py", line 204, in wrapper
    return func(self, options, args)
  File "<python_install_dir>\lib\site-packages\pip\_internal\commands\install.py", line 294, in run
    wheel_cache = WheelCache(options.cache_dir, options.format_control)
  File "<python_install_dir>\lib\site-packages\pip\_internal\cache.py", line 219, in __init__
    self._ephem_cache = EphemWheelCache(format_control)
  File "<python_install_dir>\lib\site-packages\pip\_internal\cache.py", line 196, in __init__
    super().__init__(self._temp_dir.path, format_control)
  File "<python_install_dir>\lib\site-packages\pip\_internal\cache.py", line 121, in __init__
    super().__init__(cache_dir, format_control, {"binary"})
  File "<python_install_dir>\lib\site-packages\pip\_internal\cache.py", line 44, in __init__
    assert not cache_dir or os.path.isabs(cache_dir)
AssertionError

Code of Conduct

@grv87 grv87 added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Oct 18, 2021
@uranusjr
Copy link
Member

uranusjr commented Oct 18, 2021

What would the value of cache_dir be in this case? I wonder if this is can be simply fixed by switching to pathlib (which handles UNC paths better than os.path). Also, I wonder if the directory junction is actually relevant here; what happens if TEMP is set directly to the network drive?

@grv87
Copy link
Author

grv87 commented Oct 21, 2021

cache_dir: Volume{<new volume uuid>}\dir\pip-ephem-wheel-cache-...

Note that \\?\ prefix is lost.

TEMP set to network UNC path works.
But my TEMP dir is not on a network drive. Junctions can't target network drives.

@pfmoore
Copy link
Member

pfmoore commented Oct 21, 2021

Following the chain of calls leads to os.path.realpath(tempfile.mkdtemp(prefix=f"pip-{kind}-")). Can you confirm what that call returns in your environment? (Clearly you can just use any old prefix for the call).

If it doesn't return a valid path, that would imply a Python bug (which we might be able to work around, but I'd also like to make sure the root issue is reported if that's what it is).

@grv87
Copy link
Author

grv87 commented Oct 24, 2021

os.path.realpath returns Volume{uuid}\\dir\\pip-kind-.... Yes, the prefix is lost.

I've reported https://bugs.python.org/issue45597.

@uranusjr
Copy link
Member

Does pathlib.Path.resolve() have the same issue? If not, we can just use that instead.

@grv87
Copy link
Author

grv87 commented Nov 4, 2021

@uranusjr, yes, it has the same issue too.

If I'm the single user affected then I'm ready to wait for the fix in Python. I don't use pip very often, and there is the obvious workaround (set TEMP to local dir before a run). Feel free to close this issue.

@ichard26 ichard26 added OS: windows Windows specific help wanted For requesting inputs from other members of the community and removed S: needs triage Issues/PRs that need to be triaged labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted For requesting inputs from other members of the community OS: windows Windows specific type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants