Open Chris24680 opened 1 year ago
I also have this issue.
I get this if I create a new file within a Rails project using cmd-n
and set the type to Ruby
without saving.
Strangely, if I do try to save the file then VSCode gives it an extension of arb
rather than rb
so I don't know if that is related.
This is indeed very strange and may be over my head from a VS Code configuration (feels like .rb might be associated with "Ruby" but maybe there's a duplicate language definition with a different id?)
In any case, if Standard Ruby is having any issues itself, it's probably printing something useful out in the output. You can see it if you select the extension in the output panel:
Another idea, because you don't have very many settings set:
Open Workspace Settings (JSON)
command) for anything fishyDeveloper: Reload Window
command)I saw a reference on SO to the extension issue being down to VSCode Ruby. I disabled it (which also meant disabling the main Ruby extension) and while ruby files now save with a .rb
extension it is still handling unsaved ruby files differently. If I try to format a new ruby file that hasn't been saved I now get "There is no formatter for 'ruby' files installed" and an "Install formatter..." button which opens the extensions list filtered for formatters, including Standard Ruby ironically.
I realise that this is probably a VSCode core issue rather than something relating to this extension, just mentioning it here FYI.
Cheers.
I saw a reference on SO to the extension issue being down to VSCode Ruby. I disabled it (which also meant disabling the main Ruby extension) and while ruby files now save with a
.rb
extension it is still handling unsaved ruby files differently. If I try to format a new ruby file that hasn't been saved I now get "There is no formatter for 'ruby' files installed" and an "Install formatter..." button which opens the extensions list filtered for formatters, including Standard Ruby ironically.
Do you have something like this in your settings.json?
"[ruby]": {
"editor.defaultFormatter": "testdouble.vscode-standard-ruby"
},
And when you're editing unsaved Ruby documents that aren't formatting, do they show up as Ruby in the right side of the status bar?
If the answer to both is "yes", then I'm stumped.
Yes, I'm afraid so. And linting works, just not formatting. It's no biggie now that I know that the problem is only happening on unsaved files (for me at least).
Thanks for taking time to look at this. I can live with it as it stands though.
Thanks for the response. Since my post the issue seems to have resolved itself, though I'm not really sure why.
I don't have any workspace settings on my installation, so that shouldn't be a problem.
After doing a little more investigation I think the Extension 'standard ruby' is configured as formatter but it cannot format 'Ruby'-files
error message is just being displayed whenever Standard is unable to start up properly. For example if I open vscode with rvm set to the wrong ruby version. In the output for the extension I get:
[client] Command `bundle list --name-only` failed with exit code 11 (exec options: {"cwd":"/home/chris/workspace/tap-bookkeeping"})
[client] stderr:
https://github.com/seyhunak/twitter-bootstrap-rails.git (at 8a64089@8a64089) is
not yet checked out. Run `bundle install` first.
[client] Failed to invoke Bundler in the current workspace. After resolving the issue, run the command `Standard Ruby: Start Language Server`
However I get the "cannot format ruby files" error in the badge. I've also notice when it is working, I'll still be shown that message until Standard has finished starting up, then it will go to normal.
So it seems it may just be a case of a misleading error message showing regardless of the actual problem.
Hope this helps, now that it's working for me I'm really happy with the extension!
We ran into this as well after switching to and getting everyone on the Standard extension. We discovered Ruby was setup with a different formatter. If you see the {*}
looking icon next to Ruby
in the lower right hand status bar, click that and select Standard, and then Autofix should begin working. That or defining the formatter as noted above in your user settings works too.
Folks in this thread, did you follow this step in the readme?
"[ruby]": {
"editor.defaultFormatter": "testdouble.vscode-standard-ruby"
},
Or was this already set?
@searls I did already have that setting configured.
@robingram Rats. Are you still experiencing this issue?
Yeah but only in the limited circumstances I mentioned, for a new file that hasn't been saved, so it is easy to work around.
Hi, I'm getting this odd error after installing the vscode-standard-ruby extension.
Extension 'standard ruby' is configured as formatter but it cannot format 'Ruby'-files
I'm using the following versions:
Here is my settings.json:
And here is a list of extensions I have installed:
Happy to provide more detail if needed.