Can't use virtualenv with system python
Describe the bug
It fails with this output:
rtx setting up virtualenv at: /home/redbeard/research/.venv
rtx failed to get virtualenv: failed to execute command: ~/.local/share/rtx/installs/python/system/bin/python -m venv /home/redbeard/research/.venv
To Reproduce
Create local configuration somewhere:
[tools]
python = { version='system', virtualenv='.venv' }
and change current directory to that directory.
Expected behavior
It should create virtual environment with system python.
rtx doctor output
rtx version:
2023.12.34 linux-x64 (7abe91a 2023-12-21)
build:
Target: x86_64-unknown-linux-gnu
Features: DEFAULT, NATIVE_TLS, OPENSSL
Built: Thu, 21 Dec 2023 18:44:22 +0000
Rust Version: rustc 1.74.1 (a28077b28 2023-12-04)
Profile: release
shell:
/usr/bin/zsh
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
rtx data directory:
/home/redbeard/.local/share/rtx
rtx environment variables:
RTX_SHELL=zsh
settings:
{
"experimental": true,
"color": true,
"always_keep_download": false,
"always_keep_install": false,
"legacy_version_file": true,
"legacy_version_file_disable_tools": [],
"plugin_autoupdate_last_check_duration": "7d",
"trusted_config_paths": [],
"log_level": "info",
"trace": false,
"debug": false,
"verbose": false,
"quiet": false,
"asdf_compat": false,
"jobs": 4,
"shorthands_file": null,
"disable_default_shorthands": false,
"disable_tools": [],
"raw": false,
"yes": false,
"ci": false
}
config files:
/home/redbeard/.config/rtx/config.toml
/home/redbeard/research/.rtx.toml
plugins:
bun (core)
deno (core)
erlang (core)
go (core)
java (core)
node (core)
python (core)
ruby (core)
toolset:
python@system, node@20, go@1
No problems found
it doesn't really make sense to use system this way. "system" in rtx really just means lack of using rtx at all.
Perhaps I should rename it to "omit" or "null" or something to make the behavior clearer.
My use case is to activate (create one if not exists) virtual env in the folder using the system python. This can be done with direnv using layout python which will use the system python, here.
The
layout pythondirective will look for a python executable on the path.
Is this possible in rtx?
this would require a fair amount of work since currently rtx goes out of its way to ignore the system versions. It is possible to fix though
Maybe the real issue here is that virtualenv management should be separated from the Python tool and a different plugin/tool dedicated to virtualenv management could be created? There could then even be competing ones based on the way different folks think virtualenvs should be managed (#1438)?
The virtualenv management tool/plugin would just use the python on the current PATH and not care whether it was mise managed or not.
you can do that today, just write a plugin that has a bin/exec-env like the poetry plugin: https://github.com/mise-plugins/mise-poetry/blob/main/bin/exec-env
I would like to make this possible though so it wouldn't require so much boilerplate:
[env]
_.script = '~/scripts/setup_my_venv.sh'