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

pdm init raises FileNotFoundError if a clean pyenv installation is present #1468

Closed
1 task done
ferminho opened this issue Oct 27, 2022 · 3 comments
Closed
1 task done
Labels
🐛 bug Something isn't working

Comments

@ferminho
Copy link

ferminho commented Oct 27, 2022

  • I have searched the issue tracker and believe that this is not a duplicate.

Steps to reproduce

  • Install latest pyenv (v2.3.5)
  • Install pdm 2.1.5
  • Do pdm init in any folder

Can be reproduced building the following Docker image:

FROM python:3.9.7-slim AS base

RUN apt-get update && apt-get install -y git curl
ENV PYENV_GIT_TAG v2.3.5
RUN curl https://pyenv.run | bash
RUN pip install pdm==2.1.5
RUN pdm init -v -n

Actual behavior

An exception is raised

Creating a pyproject.toml for PDM...
Traceback (most recent call last):
  File "/usr/local/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/pdm/core.py", line 254, in main
    return Core().main(args)
  File "/usr/local/lib/python3.9/site-packages/pdm/core.py", line 187, in main
    raise cast(Exception, err).with_traceback(traceback)
  File "/usr/local/lib/python3.9/site-packages/pdm/core.py", line 182, in main
    f(options.project, options)
  File "/usr/local/lib/python3.9/site-packages/pdm/cli/commands/init.py", line 51, in handle
    python = actions.do_use(project, ignore_requires_python=True, hooks=hooks)
  File "/usr/local/lib/python3.9/site-packages/pdm/cli/actions.py", line 652, in do_use
    found_interpreters = list(dict.fromkeys(project.find_interpreters(python)))
  File "/usr/local/lib/python3.9/site-packages/pdm/project/core.py", line 693, in find_interpreters
    for entry in finder.find_all(*args):
  File "/usr/local/lib/python3.9/site-packages/findpython/finder.py", line 103, in find_all
    matched_python = set(self._find_all_python_versions())
  File "/usr/local/lib/python3.9/site-packages/findpython/finder.py", line 136, in _find_all_python_versions
    yield from provider.find_pythons()
  File "/usr/local/lib/python3.9/site-packages/findpython/providers/pyenv.py", line 27, in find_pythons
    for version in self.root.joinpath("versions").iterdir():
  File "/usr/local/lib/python3.9/pathlib.py", line 1160, in iterdir
    for name in self._accessor.listdir(self):
FileNotFoundError: [Errno 2] No such file or directory: '/root/.pyenv/versions'

Expected behavior

pdm init executes normally, ignoring the clean pyenv installation

@ferminho
Copy link
Author

It seems it's caused by frostming/findpython#10

@frostming
Copy link
Collaborator

Fixed on the new release of findpython

@ferminho
Copy link
Author

ferminho commented Nov 3, 2022

Thank you! Verified, it works in 2.2.0

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

No branches or pull requests

2 participants