plugin-ruby: Crashing when run in VSCode on save
I used to run prettier on save with this VSCode extension. It used to work like a charm, but stopped working some time ago. I tried with versions 1.6.1 and 2.0.0-rc3. With both versions, prettier crashes, but the later version gives a better error message.
It’s probably something on my side that is going wrong I guess? Because if it wouldn’t work with that extension, you’d already have a lot of people reporting this I guess. But I don’t know what I can do to make this work.
This is the output I get:
["INFO" - 1:19:12 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 1:19:12 PM] Extension Version: 9.0.0.
["INFO" - 1:19:15 PM] Formatting file:///Users/mmainz/code/ears/lib/ears/middlewares/max_retries.rb
["INFO" - 1:19:15 PM] Using config file at '/Users/mmainz/code/ears/package.json'
["INFO" - 1:19:15 PM] Using ignore file (if present) at /Users/mmainz/code/ears/.prettierignore
["INFO" - 1:19:15 PM] File Info:
{
"ignored": false,
"inferredParser": "ruby"
}
["INFO" - 1:19:15 PM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 1:19:15 PM] Prettier Options:
{
"filepath": "/Users/mmainz/code/ears/lib/ears/middlewares/max_retries.rb",
"parser": "ruby",
"singleQuote": true,
"trailingComma": "all",
"useTabs": false
}
["ERROR" - 1:19:20 PM] Error formatting document.
Error:
We failed to spawn our parser server. Please report this error on GitHub
at https://github.com/prettier/plugin-ruby. The error message was:
/Users/mmainz/code/ears/node_modules/@prettier/plugin-ruby/dist/parser/getInfo.js:8
throw new Error("Failed to get information from parse server in time.");
^
Error: Failed to get information from parse server in time.
at Timeout._onTimeout (/Users/mmainz/code/ears/node_modules/@prettier/plugin-ruby/dist/parser/getInfo.js:8:9)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
.
at spawnServer (/Users/mmainz/code/ears/node_modules/@prettier/plugin-ruby/dist/parser/parseSync.js:88:15)
at parseSync (/Users/mmainz/code/ears/node_modules/@prettier/plugin-ruby/dist/parser/parseSync.js:118:22)
at Object.parse (/Users/mmainz/code/ears/node_modules/@prettier/plugin-ruby/dist/ruby/parser.js:13:40)
at Object.parse$a [as parse] (/Users/mmainz/code/ears/node_modules/prettier/index.js:12513:19)
at coreFormat (/Users/mmainz/code/ears/node_modules/prettier/index.js:14044:16)
at formatWithCursor$1 (/Users/mmainz/code/ears/node_modules/prettier/index.js:14284:14)
at /Users/mmainz/code/ears/node_modules/prettier/index.js:59304:12
at Object.Success [as format] (/Users/mmainz/code/ears/node_modules/prettier/index.js:59324:12)
at t.default.<anonymous> (/Users/mmainz/.vscode/extensions/esbenp.prettier-vscode-9.0.0/src/PrettierEditService.ts:434:45)
at Generator.next (<anonymous>)
at s (/Users/mmainz/.vscode/extensions/esbenp.prettier-vscode-9.0.0/dist/extension.js:1:7872)
["INFO" - 1:19:20 PM] Formatting completed in 5.23ms.
Metadata
- Operating system: Mac OS Big Sur
- Ruby version: 3.0.2
- Node version: 16.9.0
@prettier/plugin-ruby
orprettier
gem version: 2.0.0-rc3
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 18 (10 by maintainers)
Found a workaround for me: opening vscode using
code
from inside zsh fixes the issue.If I open vscode from Spotlight search, I get this same error.
Well, shoot, I thought I had this problem behind me. I set up a fresh install on a new computer and everything worked fine until just now when it stopped working for no apparent reason.
Edit: resolved again, this time by
asdf global ruby 2.7.2
, I didn’t have a global ruby interpreter set it seems, and that was relevant for some reason. No idea why that would have changed overnight or if my settings conflicted with some other change.