ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Ruby LSP fails to activate through VSCode with `error: Unable to read input file: Is a directory`

Open benedictleejh opened this issue 4 months ago • 6 comments

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.

benedictleejh avatar Mar 07 '24 06:03 benedictleejh

~Hi @benedictleejh, what shell are you using?~

I see you stated bash.

andyw8 avatar Mar 07 '24 18:03 andyw8

Do you have fish installed too? From Googling, I seem some indication it's the source of that particular message.

andyw8 avatar Mar 07 '24 18:03 andyw8

I do have fish installed, and my .bashrc execs fish.

benedictleejh avatar Mar 08 '24 09:03 benedictleejh

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", ……

HosokawaR avatar Mar 11 '24 04:03 HosokawaR

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.

vinistock avatar Mar 11 '24 13:03 vinistock

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!

HosokawaR avatar Mar 19 '24 02:03 HosokawaR