Failed to start parse server
Currently using VSCode Prettier Plugin v10.4.0 + @prettier/plugin-ruby 4.0.2 + prettier 3.0.3.
I'm getting the following error:
Error: Failed to start parse server.
at Timeout.<anonymous> (file:///.../node_modules/@prettier/plugin-ruby/src/plugin.js:127:16)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
However, if I run ./node_modules/.bin/prettier --plugin=@prettier/plugin-ruby --write '**/*' it works no problem. What's going on?
Same with @prettier/plugin-ruby 4.0.4 + prettier 3.3.3
Same error for me in WSL with @prettier/plugin-ruby 4.0.4 + prettier 3.4.0.
Did a little debugging and noticed that it's failing after 'require "syntax_tree"'. So I just tried to execute "bundle add" instead of "gem install" like this: "bundle add prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs" and now it's working. I'm thinking it's because I'm using rbenv but not sure.
UPD: if I delete Gemfile it's starting to work
Downgrading to 4.0.2 also helps
The issue is resolved after deleting the following line of code:
https://github.com/prettier/plugin-ruby/blob/ed8a2577f5f739365662a64d669ed0e340a40453/src/plugin.js#L79
Introducing an option to disable changing the child process's current working directory could provide a straightforward workaround.
I was hitting this, but updating the editor (VSCode/Cursor) seems to have resolved it for me.
I got:
<internal:/opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require': cannot load such file -- syntax_tree (LoadError)
Did you mean? syntax_suggest
from <internal:/opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require'
from /opt/homebrew/Library/Taps/homebrew-x/homebrew-x/node_modules/@prettier/plugin-ruby/src/server.rb:7:in '<main>'
[error] Casks/imfile.rb: Error: Failed to start parse server.
[error] at Timeout.<anonymous> (file:///opt/homebrew/Library/Taps/homebrew-x/homebrew-x/node_modules/@prettier/plugin-ruby/src/plugin.js:127:16)
[error] at listOnTimeout (node:internal/timers:594:17)
[error] at process.processTimers (node:internal/timers:529:7)
<internal:/opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require': cannot load such file -- syntax_tree (LoadError)
Did you mean? syntax_suggest
from <internal:/opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require'
from /opt/homebrew/Library/Taps/homebrew-x/homebrew-x/node_modules/@prettier/plugin-ruby/src/server.rb:7:in '<main>'
[error] Casks/sogouinput.rb: Error: Failed to start parse server.
[error] at Timeout.<anonymous> (file:///opt/homebrew/Library/Taps/homebrew-x/homebrew-x/node_modules/@prettier/plugin-ruby/src/plugin.js:127:16)
[error] at listOnTimeout (node:internal/timers:594:17)
[error] at process.processTimers (node:internal/timers:529:7)
OK, after gem install syntax_tree, it's working as expected now.