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

Detection of active runtime version manager fails #440

Closed
Terbium-135 opened this issue Oct 21, 2023 · 7 comments
Closed

Detection of active runtime version manager fails #440

Terbium-135 opened this issue Oct 21, 2023 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Terbium-135
Copy link

Checked out lexical main up to:

commit cb138a8ad492e52448b615b33d9a0687ad8f926e (HEAD -> main, origin/main, origin/HEAD)
Author: Zach Allaun <zach.allaun@gmail.com>
Date:   Fri Oct 20 10:44:35 2023 -0700

I am unable to start lexical (editor is vscode here):

Starting lexical release in "/home/elixir-dev/projects/lexical/_build/dev/package/lexical/bin"
[Trace - 08:59:21] Sending request 'initialize - (0)'.
No activated version manager detected. Searching for version manager...
Found asdf. Activating...
Detected Elixir through asdf: /home/elixir-dev/.asdf/installs/elixir/1.15.7-otp-26/bin/elixir
[Error - 08:59:34] Client Lexical: connection to server is erroring. Shutting down server.
[Error - 08:59:34] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting

I have both runtime managers installed asdf as well as rtx but only rtx is activated in .zshrc:

# . $HOME/.asdf/asdf.sh
# . $HOME/.asdf/completions/asdf.bash
eval "$(~/.local/share/rtx/bin/rtx activate zsh)"

After manually hiding the .asdf folder lexical starts normal

Let me know if further information is needed

@zachallaun
Copy link
Collaborator

Out of curiosity, how are you starting VS Code? Do you start it using code from the command line or do you start the app from a start menu/desktop?

@zachallaun
Copy link
Collaborator

zachallaun commented Oct 21, 2023

Also, to test a theory, would you mind adding the rtx activation to .bashrc and then share the startup logs from lexical?

# ~/.bashrc
eval "$(~/.local/share/rtx/bin/rtx activate bash)"

@zachallaun zachallaun self-assigned this Oct 21, 2023
@Terbium-135
Copy link
Author

VS Code is running on Windows and remotely connecting to the linux computer with the source

.bashrc already has rtx added:

. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
eval "$(/home/elixir-dev/.local/share/rtx/bin/rtx activate bash)"

but asdf never got commented out since I am not using bash anymore but zsh

I don't know the detection logic you implemented but perhaps it should respect the active shell?
Just guessing here...

@zachallaun
Copy link
Collaborator

VS Code is running on Windows and remotely connecting to the linux computer with the source

Yep, I use the same setup. However, could you clarify whether VS Code is started using code from the terminal or through the Windows start menu? If from the terminal, I believe VS Code inherits the environment present in the shell it was launched from. There's definitely an issue in the detection logic when both asdf and rtx are found, but I'm trying to narrow a few things down now because I'll only have a little bit of time to work on it later today.

Could you also please clarify the behavior if you do not initialize asdf in your bashrc and only initialize rtx?

@Terbium-135
Copy link
Author

Terbium-135 commented Oct 21, 2023

I'm starting VS Code from an icon on my windows taskbar.

I'm using zsh, but despite of that: in both files (.zshrc and .bashrc) asdf is commented out now.
As soon as the .asdf folder is in my home directory it gets detected...

Starting lexical release in "/home/elixir-dev/projects/lexical/_build/dev/package/lexical/bin"
[Trace - 19:01:29] Sending request 'initialize - (0)'.
No activated version manager detected. Searching for version manager...
Found asdf. Activating...
Detected Elixir through asdf: /home/elixir-dev/.asdf/installs/elixir/1.15.7-otp-26/bin/elixir
[Error - 19:01:42] Client Lexical: connection to server is erroring. Shutting down server.
[Error - 19:01:42] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting

Please don't spend to much time on this edge case
Thank you for all the work!

@zachallaun
Copy link
Collaborator

Did some investigation over the weekend. I don't have a fix yet.

I was able to reproduce the issue by installing rtx and setting up rtx as described. I can only reproduce by starting VS Code from the Windows Start Menu and ensuring that any existing "sessions" have been closed (Close Remote Connection) and then restarted. Otherwise, VS Code seems to inherit whatever environment was previously set when I started the editor using code from the terminal.

I still don't understand why the connection fails after Lexical starts from asdf. Even though it should optimally use rtx, it finds a compatible version through asdf and that should be sufficient to start. This should be the next point of investigation.

@Terbium-135 A couple more questions:

  1. What version of Elixir and OTP were used to package Lexical?
  2. Does the project you're trying to run contain an .rtx.toml? Does it contain .tool-versions?

@scohen scohen added this to the 0.4 release milestone Oct 23, 2023
@scohen scohen added the bug Something isn't working label Oct 23, 2023
zachallaun added a commit that referenced this issue Oct 24, 2023
The checks in `activate_version_manager.sh` need explicit `{ }` to prevent `_detect_rtx` from always running. This would cause the script to exit with an error spuriously, which would trigger an error message that was being written to stdio. Because we use stdio as our transport, that would cause the LS client to crash.

This fixes the crash reported in #440. However, it will still run the server using asdf if both asdf and rtx are installed with the correct versions of Elixir.
zachallaun added a commit that referenced this issue Oct 24, 2023
The checks in `activate_version_manager.sh` need explicit `{ }` to prevent `_detect_rtx` from always running. This would cause the script to exit with an error spuriously, which would trigger an error message that was being written to stdio. Because we use stdio as our transport, that would cause the LS client to crash.

This fixes the crash reported in #440. However, it will still run the server using asdf if both asdf and rtx are installed with the correct versions of Elixir.
@zachallaun
Copy link
Collaborator

Should be fixed on main and in the 0.4.0 release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants