Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

language-server can't find rubocop #552

Closed

Description

@breathe

Issue Type: Bug

From Ruby Language Server output:

Lint: executing bundle exec rubocop -s /Users/ncohen/software/Web/app/models/location.rb -f json...
Lint: unable to execute bundle exec rubocop -s /Users/ncohen/software/Web/app/models/location.rb -f json as the command could not be found

I get a same error with or without setting the rubocop useBundler flag:

    "ruby.lint": {
      "rubocop": {
        "useBundler": true
      }
    },

Works from command line (with or without bundle exec)

ncohen@208 ~/s/i/Web> cat /Users/ncohen/software/Web/app/models/location.rb | rubocop -s /Users/ncohen/software/Web/app/models/location.rb -f json
{"metadata":{"rubocop_version":"0.71.0","ruby_engine":"ruby","ruby_version":"2.4.6","ruby_patchlevel":"354","ruby_platform":"x86_64-darwin18"},"files":[{"path":"app/models/location.rb","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}
ncohen@208 ~/s/i/Web> cat /Users/ncohen/software/Web/app/models/location.rb | bundle exec rubocop -s /Users/ncohen/software/Web/app/models/location.rb -f json
{"metadata":{"rubocop_version":"0.71.0","ruby_engine":"ruby","ruby_version":"2.4.6","ruby_patchlevel":"354","ruby_platform":"x86_64-darwin18"},"files":[{"path":"app/models/location.rb","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}
The file must be piped into rubocop or other utilities. This methodology is the best representation of how the language server runs these commands. If the command succeeds here but not in the language server, additional steps will be necessary to troubleshoot. Please open an issue.

Hmm -- can't figure this out and opening an issue as the troubleshooting docs suggest. Much appreciate!

Extension version: 0.25.3
VS Code version: Code 1.39.2 (6ab598523be7a800d7f3eb4d92d7ab9a66069390, 2019-10-15T15:33:00.827Z)
OS version: Darwin x64 18.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2800)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.84GB free)
Process Argv itsacheckmate.code-workspace
Screen Reader no
VM 0%

Activity

  1. andrewmcodes commented on Oct 24, 2019

    @andrewmcodes

    What’s the output of rubocop -v?

    Can you paste your config relating to this extension?

  2. breathe commented on Oct 24, 2019

    @breathe
    Author

    Hi @andrewmcodes

    ➤ rubocop -v
    0.71.0
    

    In workspace file are all the settings related to vscode-ruby -- and I've tried all the different variations of the "ruby.useBundler" and "ruby.lint" options ...

      "settings": {
        "ruby.useLanguageServer": true,
    
        "[javascript]": {
          "editor.defaultFormatter": "esbenp.prettier-vscode",
          "editor.formatOnSave": true
        },
        "[typescript]": {
          "editor.defaultFormatter": "esbenp.prettier-vscode"
        },
        "[json]": {
          "editor.defaultFormatter": "esbenp.prettier-vscode"
        },
        "[ruby]": {
          "editor.formatOnSave": true,
          "editor.defaultFormatter": "jnbt.vscode-rufo",
          "editor.formatOnSaveTimeout": 3000
        },
        "ruby.lint": {
          "rubocop": true
        }
      }
    
  3. breathe commented on Oct 24, 2019

    @breathe
    Author

    Aside -- my user shell is fish if there's any chance that might impact behavior here ...?

  4. andrewmcodes commented on Oct 24, 2019

    @andrewmcodes

    @breathe First, I would try gem install rubocop just to get on the latest version, then modify your config slightly to resemble this:

      "settings": {
        "[ruby]": {
          "editor.formatOnSave": true
        },
        "ruby.useLanguageServer": true,
        "ruby.lintDebounceTime": 1500,
        "ruby.lint": {
          "rubocop": {
             "useBundler": true
         }
        "ruby.format": "rubocop"
      }
    
  5. ajimix commented on Oct 24, 2019

    @ajimix

    I'm having the same problem. It seems to be related with fish as I also use fish: #523

    Seems like we have to wait for that issue to be closed first before using this extension

  6. wingrunr21 commented on Oct 24, 2019

    @wingrunr21
    Collaborator

    Or just set up a minimal setup that is POSIX compliant just to run RuboCop. Fish support is in progress.

  7. e1senh0rn commented on Oct 25, 2019

    @e1senh0rn

    Warning: the following is a hack and it will be overwritten on vscode-ruby update:

    You could edit ~/.vscode/extensions/rebornix.ruby-0.25.3/client/out/util/shims/env.fish.sh to this:

    #!/usr/local/bin/fish
    
    for name in (set -nx)
      if string match --quiet '*PATH' $name
        echo $name=(string join : -- $$name)
      else
        echo $name="$$name"
      end
    end
    
  8. ajimix commented on Oct 29, 2019

    @ajimix

    Warning: the following is a hack and it will be overwritten on vscode-ruby update:

    You could edit ~/.vscode/extensions/rebornix.ruby-0.25.3/client/out/util/shims/env.fish.sh to this:

    #!/usr/local/bin/fish
    
    for name in (set -nx)
      if string match --quiet '*PATH' $name
        echo $name=(string join : -- $$name)
      else
        echo $name="$$name"
      end
    end
    

    this worked for me but in the following file instead (I'm on Mac using VSCodium, maybe that is why the file is different) ~/.vscode-oss/extensions/rebornix.ruby-0.25.3/dist/extension/shims/env.fish.sh

  9. e1senh0rn commented on Oct 29, 2019

    @e1senh0rn

    @ajimix my bad, you are correct. I reused path to file from earlier vscode-ruby version.

  10. wingrunr21 commented on Nov 19, 2019

    @wingrunr21
    Collaborator

    Fish shell support for the environment detection landed in v0.26.0. Please give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions