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

Failed to activate asdf environment: Cannot read properties of null (reading '1') #1762

Closed
1 task done
gkarolyi opened this issue Feb 8, 2024 · 3 comments
Closed
1 task done
Labels
bug Something isn't working Stale transferred This issue was transferred from vscode-ruby-lsp

Comments

@gkarolyi
Copy link

gkarolyi commented Feb 8, 2024

Operating System

macOS Sonoma 14.2.1 (M1)

Ruby version

ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22]

Project has a bundle

  • Has bundle

Ruby version manager being used

asdf

Description

I installed the ruby-lsp vs code extension v0.5.9, and ran the below commands in a terminal:

rails new "example"
code example

As VS Code opens, I get a toast with this message:

Failed to activate asdf environment: Cannot read properties of null (reading '1')

This is the output from ruby-lsp:

2024-02-07 12:28:14.059 [info] (example) Checking if asdf is available on the path with command: zsh -i -c 'asdf --version'
2024-02-07 12:28:14.436 [info] (example) Discovered version manager asdf
2024-02-07 12:28:14.436 [info] (example) Trying to activate Ruby environment with command: zsh -i -c 'asdf exec ruby -rjson -e "STDERR.printf(%{RUBY_ENV_ACTIVATE%sRUBY_ENV_ACTIVATE}, JSON.dump({ env: ENV.to_h, ruby_version: RUBY_VERSION, yjit: defined?(RubyVM::YJIT) }))"' inside directory: /Users/gergely.karolyi/Code/example

If I use 'Install another version' and install v0.4.21, there is no error and this is the output from ruby-lsp:

2024-02-07 12:39:23.095 [info] Checking if asdf is available on the path with command: zsh -ic 'asdf --version'
2024-02-07 12:39:23.648 [info] Discovered version manager asdf
2024-02-07 12:39:23.648 [info] Trying to activate Ruby environment with command: zsh -ic 'asdf exec ruby -rjson -e "File.write(\"/var/folders/8w/ht214zm55gs6dsckv8flbnm80000gp/T/ruby_lsp_example\", JSON.dump({ env: ENV.to_h, ruby_version: RUBY_VERSION, yjit: defined?(RubyVM::YJIT) }))"' inside directory: /Users/gergely.karolyi/Code/example
2024-02-07 12:39:24.511 [info] Ruby LSP> Skipping custom bundle setup since /Users/gergely.karolyi/Code/example/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-02-07 12:39:24.514 [info] Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-02-07 12:39:24.666 [info] The Gemfile's dependencies are satisfied

2024-02-07 12:39:25.001 [info] Starting Ruby LSP v0.13.4...

2024-02-07 12:39:25.118 [info] Ruby LSP is ready

Installing v0.4.22 leads to the same error as above.

@vinistock
Copy link
Member

Thank you for the bug report! If v0.4.22 brings the problem back, then you must be facing a situation similar to #1712. Some shell plugins take control over the stderr pipe and break the communication of the extension.

The change that was reverted in v0.4.22 switched from using stderr to using a temporary file, but that resulted in errors for Windows users.

Because we had several issues related to different shells and their plugins, which are usually outside of our control, we are experimenting with an internal Ruby runtime activation mechanism, which is published in the prerelease version of the extension.

Alternatively, you can also try to figure out which plugin is taking control over stderr and disable it.

@st0012 st0012 transferred this issue from Shopify/vscode-ruby-lsp Mar 18, 2024
@st0012 st0012 added the transferred This issue was transferred from vscode-ruby-lsp label Mar 18, 2024
Copy link
Contributor

This issue is being marked as stale because there was no activity in the last 2 months

@github-actions github-actions bot added the Stale label May 18, 2024
@vinistock
Copy link
Member

This should be fixed in v0.7.0. Please let us know if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale transferred This issue was transferred from vscode-ruby-lsp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants