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

Poetry fails with KeyError if the PATH environment variable is not present #3144

Closed
3 tasks done
exhuma opened this issue Oct 8, 2020 · 6 comments · Fixed by #3146
Closed
3 tasks done

Poetry fails with KeyError if the PATH environment variable is not present #3144

exhuma opened this issue Oct 8, 2020 · 6 comments · Fixed by #3146
Labels
kind/bug Something isn't working as expected

Comments

@exhuma
Copy link

exhuma commented Oct 8, 2020

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Ubuntu 18.04

  • Poetry version: 1.0.10

Issue

When running in CI using a docker container the PATH environment variable is not set and causes an issue with poetry. Unfortunately I don't see any traceback. Here's a snipped showing the issue:

root@5d1e49d5433c:~/src# unset PATH
root@5d1e49d5433c:~/src# /usr/local/bin/poetry run -vvv pip install pip

[KeyError]
'PATH'
@exhuma exhuma added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 8, 2020
@exhuma
Copy link
Author

exhuma commented Oct 8, 2020

With the debugger I was able to get the traceback:

(Pdb) traceback.print_tb(e.__traceback__)
  File "/usr/local/lib/python3.6/dist-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/command/command.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/event/event_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "/usr/local/lib/python3.6/dist-packages/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "/usr/local/lib/python3.6/dist-packages/poetry/console/config/application_config.py", line 92, in set_env
    env = env_manager.create_venv(io)
  File "/usr/local/lib/python3.6/dist-packages/poetry/utils/env.py", line 490, in create_venv
    env = self.get(reload=True)
  File "/usr/local/lib/python3.6/dist-packages/poetry/utils/env.py", line 333, in get
    return VirtualEnv(venv)
  File "/usr/local/lib/python3.6/dist-packages/poetry/utils/env.py", line 1045, in __init__
    self._base = Path(self.run("python", "-", input_=GET_BASE_PREFIX).strip())
  File "/usr/local/lib/python3.6/dist-packages/poetry/utils/env.py", line 879, in run
    return self._run(cmd, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/poetry/utils/env.py", line 1106, in _run
    os.environ["PATH"] = self._updated_path()
  File "/usr/local/lib/python3.6/dist-packages/poetry/utils/env.py", line 1138, in _updated_path
    return os.pathsep.join([str(self._bin_dir), os.environ["PATH"]])
  File "/usr/lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None

exhuma pushed a commit to exhuma/poetry that referenced this issue Oct 8, 2020
@abn abn closed this as completed in #3146 Oct 8, 2020
abn pushed a commit that referenced this issue Oct 8, 2020
exhuma pushed a commit to exhuma/poetry that referenced this issue Oct 9, 2020
exhuma pushed a commit to exhuma/poetry that referenced this issue Oct 9, 2020
@pepastach
Copy link

This does not seem to be related to PATH variable only (though I hit exactly this issue quite a few times). It randomly crashes on any poetry unrelated environment variables. Couple of examples: CI_JOB_ID, DOCKER_ENV_CI_MERGE_REQUEST_REF_PATH, etc. It actually fails even if these variables are defined. It really seems like a race condition problem. This fix might help, but I think there is a bigger problem. It now blocks almost all our build pipelines. We wanted to disable parallel installer (by @abn) and see if that helps, but that is also not released in 1.1.2.

I guess we'll call it a day and wait for 1.1.3 or fork, merge couple of pull requests and build our own poetry...

abn pushed a commit that referenced this issue Oct 9, 2020
@al-muammar
Copy link

al-muammar commented Oct 12, 2020

@pepastach, we started seeing lots of errors like this as well. As well as suddenly lots of warnings like Connection pool is full, discarding connection: pypi.org, which we were not seeing before.

I moved to 1.0.10 version, which previously worked fine and the same problems were discovered there.
@pepastach, would you mind creating an issue to continue the investigation there?

@abn
Copy link
Member

abn commented Oct 13, 2020

@pepastach I am not sure you have provided any actionable information there. Perhaps details on how we can reproduce concern you have raised would be a start, -vvv logs would also go a long way to help. Since this issue is already closed, I would recommend creating a new issue if an open one for the errors you are facing does not already exist.

@jihadik @pepastach if you are encountering issues with the new installer, you can refer here on how it can be disabled until it stablises.

@jihadik Regarding the Connection pool is full, discarding connection: pypi.org, that is the requests library recreating connections to pypi.org, it is a graceful recovery and should not impact functionality under normal circumstances. Regarding the errors, as I mentioned above, more details will be appreciated.

@pepastach
Copy link

@abn Fair point. Here is the issue: #3199
Hope that would help someone reproduce it.

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants