jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
9.67k stars 273 forks source link

rtx poetry plugin causes slow folder navigation #438

Open AntonFriberg opened 1 year ago

AntonFriberg commented 1 year ago

Describe the bug Without having poetry@1.4.2 installed the folder navigation is snappy inside my project folder. But after installing, the folder navigation becomes very slow (around 1-2 seconds for a simple cd).

This is my .rtx.toml file

[tools]
poetry = {version='1.4.2', pyproject='pyproject.toml'}
python = '3.10'

To Reproduce

> lsb_release  -a
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
> rtx --version
1.27.10 linux-x64 (a69244b 2023-03-31)
# Fast folder navigation
> rtx ls
rtx ls
   poetry 1.4.2 (missing)    (set by ~/dagster/data-management-pipelines/.rtx.toml)
⏵  python 3.10.10            (set by ~/dagster/data-management-pipelines/.rtx.toml)
> cd data_management_pipelines && cd ..
# Returns directly no noticeable delay 
> rtx local --install-missing
rtx local --install-missing
rtx poetry@1.4.2 Running: "poetry config virtualenvs.prefer-active-python true". 
# This causes slow folder navigation across the project folder
> cd data_management_pipelines && cd ..
# Takes 2 seconds to return

Expected behavior That snappy folder navigation would not be compromised by having rtx poetry active. This is a deal-breaker for me in my work-flow.

rtx doctor output

rtx version:
  1.27.10 linux-x64 (a69244b 2023-03-31)

build:
  Target: x86_64-unknown-linux-gnu
  Features: DEB
  Built: Fri, 31 Mar 2023 01:33:37 +0000
  Rust Version: rustc 1.68.1 (8460ca823 2023-03-20)
  Profile: release

shell:
  /home/antonfr/.nix-profile/bin/fish
  fish, version 3.5.1

rtx environment variables:
  RTX_SHELL=fish

settings:
  {"experimental": "false", "missing_runtime_behavior": "prompt", "always_keep_download": "false", "legacy_version_file": "true", "plugin_autoupdate_last_check_duration": "10080", "trusted_config_paths": "[]", "verbose": "false", "asdf_compat": "false", "jobs": "4", "disable_default_shorthands": "false", "log_level": "INFO", "raw": "false"}

config files:
  /home/antonfr/.config/rtx/config.toml
  /home/antonfr/.tool-versions
  /home/antonfr/dagster/data-management-pipelines/.rtx.toml

plugins:
  poetry   https://github.com/rtx-plugins/rtx-poetry.git#7e500d2
  python   https://github.com/rtx-plugins/rtx-python.git#d4a0414

toolset:
  poetry@1.4.2, python@3.10

1 problem found:
new rtx version 1.27.11 available, currently on 1.27.10

Additional context rtx 1.27.11 is not available for DEB releases.

AntonFriberg commented 1 year ago

I tried to remove my .venv virtualenvironment from the project folder but that caused rtx to not be able to activate the poetry environment at all.

> cd data-management-pipelines/
[WARN] Error running exec-env: command ["bash", "-c", ". /home/antonfr/.local/share/rtx/plugins/poetry/bin/exec-env\nexport -p\n"] exited with code 1
[WARN] Error listing bin paths for poetry@1.4.2: command ["/home/antonfr/.local/share/rtx/plugins/poetry/bin/list-bin-paths"] exited with code 1
> poetry activate
set -gx RTX_SHELL fish

function rtx
  if test (count $argv) -eq 0
    command /usr/bin/rtx
    return
  end

  set command $argv[1]
  set -e argv[1]

  switch "$command"
  case deactivate shell
    source (/usr/bin/rtx "$command" $argv|psub)
  case '*'
    command /usr/bin/rtx "$command" $argv
  end
end

function __rtx_env_eval --on-event fish_prompt --description 'Update rtx environment when changing directories';
    /usr/bin/rtx hook-env -s fish | source;

    if test "$rtx_fish_mode" != "disable_arrow";
        function __rtx_cd_hook --on-variable PWD --description 'Update rtx environment when changing directories';
            if test "$rtx_fish_mode" = "eval_after_arrow";
                set -g __rtx_env_again 0;
            else;
                /usr/bin/rtx hook-env -s fish | source;
            end;
        end;
    end;
end;

function __rtx_env_eval_2 --on-event fish_preexec --description 'Update rtx environment when changing directories';
    if set -q __rtx_env_again;
        set -e __rtx_env_again;
        /usr/bin/rtx hook-env -s fish | source;
        echo;
    end;

    functions --erase __rtx_cd_hook;
end;
[WARN] Error running exec-env: command ["bash", "-c", ". /home/antonfr/.local/share/rtx/plugins/poetry/bin/exec-env\nexport -p\n"] exited with code 1
[WARN] Error listing bin paths for poetry@1.4.2: command ["/home/antonfr/.local/share/rtx/plugins/poetry/bin/list-bin-paths"] exited with code 1
AntonFriberg commented 1 year ago

For now, this means that I decided to keep managing poetry outside RTX and only have the Python environment itself under RTX.

jdx commented 1 year ago

Yeah I’m actually working on this. My original idea was to put extra caching logic but that has become unwieldy.

My new idea is to have rust plugins instead of them being written in bash. That would make it so I can run this logic every time since it would effectively instantaneous. Trouble is this is a huge change that is first going to require a massive refactor that I’ve spent the last week or so working on (when I have time to spend on rtx that is).

That said, 1-2 seconds is way slower than this should be which makes me think there might be something more clearly wrong here.

jdx commented 1 year ago

I'm having some trouble reproducing this. I wonder if it only gets slow on large apps maybe? Or maybe there is something else going on to make it slow?