vscode-ruby version:autoformat on save
deletes the contents of the entire file
This and the next section should include screenshots, code samples, console output, etc. The more information we have to reproduce the better!
You are going to have to provide more information
Same here.
vscode-ruby version: 0.22.2
Ruby version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Ruby version manager: asdf
VS code version: 1.31.0
Operating system: Ubuntu 18.04.2 LTS
Using language server? yes
What other information do you need?
This is an output from OUTPUT tab.
Lint: executing reek -f json...
Lint: executing rubocop -s somefile.rb -f json...
Lint: attempted to lint with unsupported linter: ruby
Lint: attempted to lint with unsupported linter: fasterer
Lint: attempted to lint with unsupported linter: debride
Lint: attempted to lint with unsupported linter: ruby-lint
Well just to start: what formatter? What's your configuration? What's the console output? Do you see a Format: call in the console?
Basically the part in the issue template that wasn't filled out: _This and the next section should include screenshots, code samples, console output, etc. The more information we have to reproduce the better!_
Oh, you are right. I posted Lint output, welp. I'm using rubocop.
I do see format call:
Format: executing bundle exec rubocop -s somefile.rb -a...
I noticed that when I launch/reload vscode it throws error rubocop failed with code=1 but I don't see any more details. I can find rubocop in the terminal, though.
which rubocop
/home/username/.asdf/shims/rubocop
configuratioon:
"ruby.codeCompletion": "rcodetools",
"ruby.intellisense": "rubyLocate",
"ruby.useBundler": true,
"ruby.useLanguageServer": true,
"ruby.lint": {
"reek": true,
"rubocop": true,
"ruby": true, //Runs ruby -wc
"fasterer": true,
"debride": true,
"ruby-lint": true
},
"ruby.format": "rubocop",
Do you have a lot of lint errors in that file? I wonder if it's related to another issue where the RuboCop output is really long
It happens even to a file with only 1 lint error.
Ok. It is this specific line + this ternary that's doing that. I'll have to take another pass as I introduced those to fix other bugs with selection formatting.
:) Glad you found the cause. Do you need any help with that?
No, I think I'm going to have to combine the fix with #435. I need to introduce a buffer on all stdout and then process that output based on the return code from the linter/formatter.
Seems like a good solution :+1: Good luck then. Feel free to ping me to test the fix.
v0.22.3 has the bugfix for this
Almost...
If you have "ruby.useBundler": true in config and no rubocop in Gemfile it deletes content of the file and writes this instead:
load command: rubocop (/home/username/.asdf/installs/ruby/2.5.1/bin/rubocop)
Gem::Exception: can't find executable rubocop for gem rubocop. rubocop is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
/home/username/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.2/lib/bundler/rubygems_integration.rb:462:in `block in replace_bin_path'
/home/username/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.2/lib/bundler/rubygems_integration.rb:482:in `block in replace_bin_path'
/home/username/.asdf/installs/ruby/2.5.1/bin/rubocop:23:in `<top (required)>'
Or is it correct behaviour?
Well, replacing the file contents is probably not correct. The problem I'm trying to work around is that bundler doesn't distinguish between stdout and stderr until v2 (see bundler/bundler#3353) so I can't just assume stdout is good and stderr is bad.
I'll add a test case for it. This is actually a different issue than originally though so I'll probably open a new one and link them.
I see, thanks for the information and the fix :+1:
Can you post the full Output you are seeing? Having trouble reproducing
Which Output exactly?
The Ruby Language Server stuff. I want to see what format command it is attempting to run
Format: executing bundle exec rubocop -s somefile.rb -a...
This is what I can see printed from Format
Interesting. When I try and reproduce this setup:
ruby.useBundler: trueGemfile in project without rubocopI get a correctly handled language server error. Are you using a binstub?
AFAIK, no, I don't.
ok but you have rubocop installed globally? /home/username/.asdf/installs/ruby/2.5.1/bin/rubocop seems to suggest yes
Yes, I do.
which rubocop
=> /home/username/.asdf/shims/rubocop
Reproduced it. Thanks
Most helpful comment
Reproduced it. Thanks