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

'pip cache info' fails when no-cache-dir set #8120

Closed
efahl opened this issue Apr 23, 2020 · 4 comments · Fixed by #8124
Closed

'pip cache info' fails when no-cache-dir set #8120

efahl opened this issue Apr 23, 2020 · 4 comments · Fixed by #8124
Labels
C: cache Dealing with cache and files in it kind: crash For situations where pip crashes
Milestone

Comments

@efahl
Copy link

efahl commented Apr 23, 2020

pip version: pip 20.1b1
Python version: CPython 3.8.1
OS: Win 10 64

Testing 20.1 beta, execute 'pip cache info' and crashes. I'm guessing it's due to pip.ini turning off caching.

pip.ini:

[global]
no-cache-dir = false

Command execution:

> pip cache info
ERROR: Exception:
Traceback (most recent call last):
  File "c:\program files\python38\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in _main
    status = self.run(options, args)
  File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 62, in run
    handlers[action](options, args[1:])
  File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 74, in get_cache_info
    num_packages = len(self._find_wheels(options, '*'))
  File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 145, in _find_wheels
    wheel_dir = self._wheels_cache_dir(options)
  File "c:\program files\python38\lib\site-packages\pip\_internal\commands\cache.py", line 141, in _wheels_cache_dir
    return os.path.join(options.cache_dir, 'wheels')
  File "c:\program files\python38\lib\ntpath.py", line 78, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not bool
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Apr 23, 2020
@pradyunsg pradyunsg added this to the 20.1 milestone Apr 23, 2020
@pradyunsg pradyunsg added C: cache Dealing with cache and files in it kind: crash For situations where pip crashes labels Apr 23, 2020
@triage-new-issues triage-new-issues bot removed S: needs triage Issues/PRs that need to be triaged labels Apr 23, 2020
@pradyunsg
Copy link
Member

@efahl Thanks for the report!

@deveshks
Copy link
Contributor

deveshks commented Apr 24, 2020

This will hold true for all pip cache commands, if we disable the cache via --no-cache-dir, since there is no cache to operate on as the user has explicitly disabled it.

e.g.

$ pip cache list twine* --no-cache-dir 
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/devesh/pip/src/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 62, in run
    handlers[action](options, args[1:])
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 101, in list_cache_items
    files = self._find_wheels(options, pattern)
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 145, in _find_wheels
    wheel_dir = self._wheels_cache_dir(options)
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 141, in _wheels_cache_dir
    return os.path.join(options.cache_dir, 'wheels')
  File "/Users/devesh/.pyenv/versions/3.8.2/lib/python3.8/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not bool
$ pip cache remove twine* --no-cache-dir 
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/devesh/pip/src/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 62, in run
    handlers[action](options, args[1:])
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 123, in remove_cache_items
    files = self._find_wheels(options, args[0])
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 145, in _find_wheels
    wheel_dir = self._wheels_cache_dir(options)
  File "/Users/devesh/pip/src/pip/_internal/commands/cache.py", line 141, in _wheels_cache_dir
    return os.path.join(options.cache_dir, 'wheels')
  File "/Users/devesh/.pyenv/versions/3.8.2/lib/python3.8/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not bool

So should we raise a warning in pip.internal.commands.cache.run stating that pip cache commands won't function since the cache is disabled. <steps to enable the cache>
when we detect that options.cache_dir == False ?

@brainwane
Copy link
Contributor

@efahl Thank you for reporting this! The fix will be in the 20.1 release that we are working to publish within the next few hours.

@nabeel0954
Copy link

I am facing this issue please help me anybody ERROR: pip cache commands cannot function since cache is disabled.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: cache Dealing with cache and files in it kind: crash For situations where pip crashes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants