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

Can't use virtualenv with system python #1248

Closed
its-red-beard opened this issue Dec 22, 2023 · 5 comments
Closed

Can't use virtualenv with system python #1248

its-red-beard opened this issue Dec 22, 2023 · 5 comments
Labels

Comments

@its-red-beard
Copy link

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
@jdx
Copy link
Owner

jdx commented Dec 22, 2023

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.

@its-red-beard
Copy link
Author

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 python directive will look for a python executable on the path.

Is this possible in rtx?

@jdx
Copy link
Owner

jdx commented Dec 24, 2023

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

@jdx jdx mentioned this issue Dec 31, 2023
@rsyring
Copy link

rsyring commented Jan 11, 2024

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.

@jdx
Copy link
Owner

jdx commented Jan 11, 2024

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants