microsoft / microsoft/aspire

Issues when launching apphost from within an active venv with python resource

Open
#14,082 0 comments 0 reactions 0 assignees View on GitHub
needs-area-label python
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Given an AppHost with a python resource, if you start the apphost from a shell that has an active venv, the python resources will fail due to venv conflicts.
This effects poetry and pip package managers since they use the active venv instead of creating/using the project defined venv.

### Expected Behavior

Aspire should either:
Fail to launch in a venv.
Filter venv environment variables from python apps and their installers.

### Steps To Reproduce

use python starter template using `WithPip()` or `WithPoetry()` instead of `WithUv()`, create a different venv and activate it. Launch the apphost from this shell with an active venv.

### Exceptions (if any)

In uv you get this warning:
warning: `VIRTUAL_ENV=wrong-path` does not match the project environment path `.venv` and will be ignored; use `--active` to target the active environment instead

In poetry and pip you install in the active venv and then the app doesn't have the dependencies installed.

### .NET Version info

10

### Anything else?

I can share my active venv detection code that we use to exit the AppHost when we detect this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.