Skip to content

fix(plugins/uv): Avoid modifying already relocatable venv#2565

Open
carlcsaposs-canonical wants to merge 1 commit intocanonical:mainfrom
carlcsaposs-canonical:uv-relocatable
Open

fix(plugins/uv): Avoid modifying already relocatable venv#2565
carlcsaposs-canonical wants to merge 1 commit intocanonical:mainfrom
carlcsaposs-canonical:uv-relocatable

Conversation

@carlcsaposs-canonical
Copy link
Contributor

The uv plugin from craft-parts already uses uv venv --relocatable to create an activate script that has a portable path instead of an absolute path
https://github.com/canonical/craft-parts/blob/71291d50ec95aed813215e89463866dd09aaaa5e/craft_parts/plugins/uv_plugin.py#L108

Currently, charmcraft is overriding the relocatable path set by uv with its own relocatable path (since it's expecting activate to contain a hardcoded absolute path, like it does with venv)

This currently doesn't cause any issues, but could break in the future if the format of the activate script created by uv venv changes (since charmcraft is using sed to update the script)

Use the relocatable option provided by uv's public API instead of patching a private implementation detail

The uv plugin from craft-parts already uses `uv venv --relocatable` to create an activate script that has a portable path instead of an absolute path
https://github.com/canonical/craft-parts/blob/71291d50ec95aed813215e89463866dd09aaaa5e/craft_parts/plugins/uv_plugin.py#L108

Currently, charmcraft is overriding the relocatable path set by uv with its own relocatable path (since it's expecting `activate` to contain a hardcoded path, like it does with `venv`—instead of a relocatable path)

This currently doesn't cause any issues, but could break in the future if the format of the activate script created by `uv venv` changes (since charmcraft is using `sed` to update the script)

Use the relocatable option provided by uv's public API instead of patching a private implementation detail
@carlcsaposs-canonical
Copy link
Contributor Author

The test failures appear to be unrelated to the changes in this PR (I do not have access to retrigger the tests)

@carlcsaposs-canonical carlcsaposs-canonical marked this pull request as ready for review February 9, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant