ruby-lsp
ruby-lsp copied to clipboard
Ruby LSP fails to activate through VSCode with `error: Unable to read input file: Is a directory`
Description
Reproduction steps
When trying to start Ruby LSP through VSCode, it fails with the error message below:
Failed to activate custom environment: Command failed: /bin/bash -i -c 'eval "$(mise env -s bash)" && 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) }))"' error: Unable to read input file: Is a directory
- OS: OpenSUSE Tumbleweed through WSL2
- VSCode version: 1.87.0
- VSCode Ruby LSP version: 0.5.12
- Ruby version: 3.3.0
- Ruby version manager: mise
- mise is configured with the snippet from https://github.com/Shopify/ruby-lsp/blob/main/vscode/VERSION_MANAGERS.md, for bash
The command runs on the command line perfectly fine, and a manually installed ruby-lsp gem starts up just fine as well. I've scanned through the activation code, and I cannot see where it's trying to read a file to attempt to deconflict it.
~Hi @benedictleejh, what shell are you using?~
I see you stated bash.
Do you have fish
installed too? From Googling, I seem some indication it's the source of that particular message.
I do have fish
installed, and my .bashrc
execs fish
.
me too.
my .bashrc
calls fish
$ tail -n 3 ~/.bashrc
if [ -z $NO_FISH ]; then
exec fish
fi
so, the command seem to fail due to Fish hello message.
$ /bin/bash -i -c '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) }))"'
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
Without Fish shell or run command without -i
(bin/bash -c
), the command successes and Ruby LSP is activated.
$ /bin/bash -c '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) }))"'
RUBY_ENV_ACTIVATE{"env":{"SHELL":"/bin/bash","COLORTERM":"truecolor","TERM_PROGRAM_VERSION":"1.87.1","JAVA_HOME":"/usr/lib/jvm/java-11-openjdk-amd64","RBENV_SHELL":"bash", ……
Yeah, we're currently working on decoupling Ruby environment activation from the shell, exactly because we have no control over what users do in their configurations. If something waits for input, highjacks the stderr pipe or does other things of that nature, then invoking the Ruby activation script with the shell will likely fail.
We have been exploring a new activation mechanism, which decouples the extension from the shell. You can already use this new mechanism by installing the prerelease version of the extension, which will probably fix activation for you.
And we're getting changes ready to release this in stable https://github.com/Shopify/ruby-lsp/pull/1502 and https://github.com/Shopify/ruby-lsp/pull/1438.
You can already use this new mechanism by installing the prerelease version of the extension, which will probably fix activation for you.
The prerelease version worked fine in my environments ! I'm looking forward to the general release.
Thank you!