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_requirements_parser.InstallationError on Windows #548

Closed
ghost opened this issue Mar 16, 2023 · 7 comments · Fixed by #551
Closed

pip_requirements_parser.InstallationError on Windows #548

ghost opened this issue Mar 16, 2023 · 7 comments · Fixed by #551
Assignees
Labels
bug Something isn't working plat:windows Issues reported on Windows

Comments

@ghost
Copy link

ghost commented Mar 16, 2023

Bug description

Running pip-audit --no-deps --requirement requirements.txt raises pip_requirements_parser.InstallationError

Reproduction steps

On version 2.5.0 running pip-audit --no-deps --requirement requirements.txt with even an empty requirements.txt file.

pip install "pip-audit<2.5.0" works

Expected behavior

No error

Screenshots and logs

If applicable, add screenshots to help explain your problem.

Similarly, if applicable and possible, re-run the command with --verbose,
and paste the logs in the code block below:

  File "C:\...\site-packages\pip_requirements_parser.py", line 1371, in _parse_and_recurse
    for line in self._parse_file(filename=filename, is_constraint=is_constraint):
  File "C:\...\site-packages\pip_requirements_parser.py", line 1424, in _parse_file
    content = get_file_content(filename)
  File "C:\...\site-packages\pip_requirements_parser.py", line 1601, in get_file_content
    f"Could not open requirements file: {filename}|n{exc}"
pip_requirements_parser.InstallationError: Could not open requirements file: C:\Users\...\AppData\Local\Temp\tmplfmtf3ct|n[Errno 13] Permission denied: '

Platform information

  • OS name and version: Win10
  • pip-audit version (pip-audit -V): 2.5.0
  • Python version (python -V or python3 -V): Python 3.7.9
  • pip version (pip -V or pip3 -V): pip 22.3.1

Additional context

CacheControl==0.12.11
certifi==2022.12.7
charset-normalizer==3.1.0
cyclonedx-python-lib==3.1.5
html5lib==1.1
idna==3.4
importlib-metadata==6.0.0
lockfile==0.12.2
markdown-it-py==2.2.0
mdurl==0.1.2
msgpack==1.0.5
packageurl-python==0.10.4
packaging==23.0
pip-api==0.0.30
pip-requirements-parser==32.0.1
pip_audit==2.5.0
Pygments==2.14.0
pyparsing==3.0.9
requests==2.28.2
rich==13.3.2
six==1.16.0
sortedcontainers==2.4.0
toml==0.10.2
typing_extensions==4.5.0
urllib3==1.26.15
webencodings==0.5.1
zipp==3.15.0
@ghost ghost added the bug-candidate Might be a bug. label Mar 16, 2023
@woodruffw
Copy link
Member

Thanks for the report @stradivari96! I'll attempt to reproduce this today.

@woodruffw woodruffw added the plat:windows Issues reported on Windows label Mar 16, 2023
@woodruffw
Copy link
Member

@woodruffw
Copy link
Member

@stradivari96 could you share the full traceback? It looks like the exception you posted above is truncated to just the last few lines; it would help to see where in pip-audit the exception originated.

@ghost
Copy link
Author

ghost commented Mar 16, 2023

Here you go

Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\...\Desktop\...\venv\Scripts\pip-audit.exe\__main__.py", line 7, in <module>
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_audit\_cli.py", line 449, in audit
    for spec, vulns in auditor.audit(source):
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_audit\_audit.py", line 67, in audit
    for dep, vulns in self._service.query_all(specs):
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_audit\_service\interface.py", line 154, in query_all
    for spec in specs:
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_audit\_dependency_source\requirement.py", line 113, in collect
    yield from self._collect_from_files([Path(f.name) for f in tmp_files])
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_audit\_dependency_source\requirement.py", line 120, in _collect_from_files
    rf = RequirementsFile.from_file(filename)
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 237, in from_file
    include_nested=include_nested,
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 301, in parse
    is_constraint=is_constraint,
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 1175, in parse_requirements
    include_nested=include_nested,
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 1352, in parse
    include_nested=include_nested,
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 1371, in _parse_and_recurse
    for line in self._parse_file(filename=filename, is_constraint=is_constraint):
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 1424, in _parse_file
    content = get_file_content(filename)
  File "C:\Users\...\Desktop\...\venv\lib\site-packages\pip_requirements_parser.py", line 1601, in get_file_content
    f"Could not open requirements file: {filename}|n{exc}"
pip_requirements_parser.InstallationError: Could not open requirements file: C:\Users\...\AppData\Local\Temp\tmpnkal00cp|n[Errno 13] Permission denied: '
C:\\Users\\...\\AppData\\Local\\Temp\\tmpnkal00cp'

@woodruffw
Copy link
Member

Thank you!

Yep, the SWAG looks like it was right:

yield from self._collect_from_files([Path(f.name) for f in tmp_files])

I'll have a fix for this in a bit.

@woodruffw woodruffw self-assigned this Mar 16, 2023
@woodruffw woodruffw added bug Something isn't working and removed bug-candidate Might be a bug. labels Mar 16, 2023
@tetsuo-cpp tetsuo-cpp assigned tetsuo-cpp and unassigned woodruffw Mar 17, 2023
@woodruffw
Copy link
Member

Thanks again for reporting @stradivari96! The release we're prepping in #554 should address the problem here.

@ghost
Copy link
Author

ghost commented Mar 17, 2023

Yep the current main branch works, thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plat:windows Issues reported on Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants