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

python.uv.sync.enable and python.venv.enable have conflicting PATH exports #1502

Closed
mauricege opened this issue Oct 7, 2024 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@mauricege
Copy link

mauricege commented Oct 7, 2024

Describe the bug
In order to have a python venv that is managed through uv, one has to set both languages.python.uv.sync.enable and languages.python.venv.enable to true. Since the tasks update, both define PATH as exports - however, the initUvScript does not activate the virtual environment and therefore its path does not include the venv at the front. This randomly leads to a .devenv/load-exports file in which PATH from "devenv:python:virtualenv" gets overwritten by the value from "devenv:python:uv" and therefore not correctly activating the venv.

I tried to fix it by setting:

{
   tasks."devenv:python:uv".before = ["devenv:python:virtualenv"];
}

But the order of the tasks does not seem to reflect the order of variable exports in .devenv/load-exports.

Removing "PATH" from the task exports of "devenv:python:uv" seems to work and I have not noticed any problems:

{
   tasks."devenv:python:uv".exports = lib.mkForce ["VIRTUAL_ENV"];
}

To reproduce
Minimal devenv.nix to reproduce:

{
  languages.python = {
    enable = true;
    venv.enable = true;
    uv.enable = true;
    uv.sync.enable = true;
  };
}

Version
devenv 1.3.0 (x86_64-linux)

@mauricege mauricege added the bug Something isn't working label Oct 7, 2024
@domenkozar
Copy link
Member

@mauricege could you try #1504

@mauricege
Copy link
Author

mauricege commented Oct 7, 2024

@mauricege could you try #1504

Thanks for the quick response!

With these fixes I was unable to reproduce the error - at least after direnv reloading ~20 times.

However, I do not get how the order of devenv:python:virtualenv and devenv:python:uv is enforced? Is it alphabetical sorting?

@domenkozar
Copy link
Member

domenkozar commented Oct 7, 2024

The fixes makes sure that outputs order is respected, so we should tell uv to depend on virtualenv. Pushed a 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants