jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.84k stars 188 forks source link

Devbox shell breaks with multiple Python based packages #2037

Open jmgilman opened 2 months ago

jmgilman commented 2 months ago

What happened?

I have awscli2 installed on my system via home-manager. It works just fine. However, after starting a devbox shell, it begins throwing an error anytime I execute it:

Traceback (most recent call last):
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/bin/.aws-wrapped", line 20, in <module>
    import awscli.clidriver
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/clidriver.py", line 21, in <module>
    import botocore.session
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/session.py", line 27, in <module>
    import botocore.client
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/client.py", line 16, in <module>
    from botocore import UNSIGNED, waiter, xform_name
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/waiter.py", line 17, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/docs/service.py", line 14, in <module>
    from botocore.docs.client import ClientDocumenter, ClientExceptionsDocumenter
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/docs/client.py", line 16, in <module>
    from botocore.docs.example import ResponseExampleDocumenter
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/docs/example.py", line 13, in <module>
    from botocore.docs.shape import ShapeDocumenter
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/docs/shape.py", line 19, in <module>
    from botocore.utils import is_json_value_header
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/utils.py", line 34, in <module>
    import botocore.httpsession
  File "/nix/store/apydfdrs7nily1gnmh2d70f4jalh9siw-awscli2-2.14.2/lib/python3.11/site-packages/awscli/botocore/httpsession.py", line 21, in <module>
    from urllib3.util.ssl_ import (
ImportError: cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_' (/nix/store/brmihk12wdrnh5awyqzj42kf6jqdpcip-python3.11-urllib3-2.2.1/lib/python3.11/site-packages/urllib3/util/ssl_.py)

If I disable the shell, it will immediately work again. I removed every package in the devbox.json and tried again and found it worked. I was able to systematically deduce that the pyinfra package was the culprit. With awscli2 and pyinfra in the same devbox shell, the AWS CLI will break.

From my understanding, this shouldn't happen within Nix as the two packages should be scoped independently. In other words, they should share no dependencies and have no way to impact each other. Is devbox doing something weird here that would break this isolation?

Steps to reproduce

  1. Initialize a new devbox environment
  2. Add the pyinfra and awscli2 packages
  3. Attempt to run any command with the AWS CLI

Command

No response

devbox.json

{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.10.6/.schema/devbox.schema.json",
  "env": {
    "AWS_PROFILE": "myprofile"
  },
  "packages": [
    "pyinfra@latest",
    "awscli2@latest"
  ],
}

Devbox version

0.10.6

Nix version

2.21.2

What system does this bug occur on?

Linux (x86-64)

Debug logs

N/A

jmgilman commented 2 months ago

For what it's worth, adding both packages to home-manager does not reproduce this issue. So I doubt it's something with the individual packages or Nix itself.

Lagoja commented 2 months ago

I think this is related to #2031 -- the global PYTHONPATH is somehow getting set, which is breaking the isolation between individual python packages.