ruby-lsp
ruby-lsp copied to clipboard
Failed to activate Ruby environment: spawn /bin/sh ENOENT
Description
Hi!
I am new to ruby and I am trying to run ruby-lsp in VSCode. However, I am unable to do that, ending up with the following error:
I am pretty sure my SHELL env is set to /bin/zsh. I tried checking the codebase and executing
/bin/zsh -ic 'rbenv exec ruby -rjson -e "puts JSON.dump(ENV.to_h)"'
the SHELL is set correctly.
I have .ruby-version file in the repo containing 3.3.0.
When running ruby-lsp in the terminal, I am not sure if the output is correct:
Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2
Resolving dependencies...
The Gemfile's dependencies are satisfied
Even when waiting for quite some time, this is the only output I get.
BIG thanks for any help! ❤️
Reproduction steps
The only thing I did is installing rbenv and installing the ruby-lsp VScode extension.
I am running the latest version of VScode on MacOS M3. Tried to switch even to the pre-release version of the extension but the issue stays the same.
Code snippet or error message
Failed to activate rbenv environment: spawn /bin/sh ENOENT
I also got the same issue. After I install an older version (0.2.2), and then reinstall the newest one, the issue has gone.
@thuandohoang What do you mean by version 0.2.2? Afaik the most recent version of the ruby-lsp extension is v0.5.17?
I also tried the asdf version manager instead of rbenv and I get the same error message (just replace rbenv for asdf) 🤷
@thuandohoang What do you mean by version 0.2.2? Afaik the most recent version of the ruby-lsp extension is
v0.5.17?
@CermakM I mean downgrade version of the extension. You can see the steps here
@thuandohoang That's interesting! I downgraded it to 0.2.2 and it indeed works! However, when I upgrade it back, I get a different issue when starting Ruby LSP 😆 🤷
Cannot create property 'identifier' on string 'asdf'
@thuandohoang That's interesting! I downgraded it to 0.2.2 and it indeed works! However, when I upgrade it back, I get a different issue when starting Ruby LSP 😆 🤷
Cannot create property 'identifier' on string 'asdf'
haha, i have no idea with this issue 😄
Same with me.. suddenly it stopped working after the latest update of the extension in VSC. Getting:
2024-04-12 11:59:50.859 [error] Activating extension Shopify.ruby-lsp failed due to an error:
2024-04-12 11:59:50.859 [error] TypeError: Cannot create property 'identifier' on string 'rbenv'
at set versionManager [as versionManager] (/Users/erik/.vscode/extensions/shopify.ruby-lsp-0.5.18/out/extension.js:44:57823)
at Pa.activateRuby (/Users/erik/.vscode/extensions/shopify.ruby-lsp-0.5.18/out/extension.js:44:58002)
at Ia.start (/Users/erik/.vscode/extensions/shopify.ruby-lsp-0.5.18/out/extension.js:47:2301)
at Aa.activateWorkspace (/Users/erik/.vscode/extensions/shopify.ruby-lsp-0.5.18/out/extension.js:54:7155)
at async Aa.activate (/Users/erik/.vscode/extensions/shopify.ruby-lsp-0.5.18/out/extension.js:54:6014)
at async FD (/Users/erik/.vscode/extensions/shopify.ruby-lsp-0.5.18/out/extension.js:55:539)
at async a.n (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:142:6237)
at async a.m (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:142:6200)
at async a.l (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:142:5657)
On your settings.json on VScode. This was updated from string to object.
// Previous
"rubyLsp.rubyVersionManager": "asdf"
// New
"rubyLsp.rubyVersionManager": { "identifier": "auto" }
If I just delete this line, it works again!
The new error is a bug in the latest version, which will be fixed by https://github.com/Shopify/ruby-lsp/pull/1923 and not related in any way to the original issue.
@CermakM are there any logs in the output tab under the Ruby LSP channel?
Closing this for now. If the issue is still occurring in v0.7.1, please let us know.