Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rubocop returns empty output! please check configuration. #148

Open
Azzawie opened this issue Apr 22, 2021 · 9 comments
Open

rubocop returns empty output! please check configuration. #148

Azzawie opened this issue Apr 22, 2021 · 9 comments

Comments

@Azzawie
Copy link

Azzawie commented Apr 22, 2021

After updating vscode, I started receiving this error message

/Users/xx/.rbenv/shims/rubocop returns empty output! please check configuration.

If I do bundle exec rubocop file_name rubocop will work.

I have these in the configuration file.

  "ruby.rubocop.executePath": "/Users/xx/.rbenv/shims/",
  "ruby.rubocop.configFilePath": "/Users/xx/projects/mp/.rubocop.yml",

any idea, please!

@luismadrigal
Copy link

I had this same problem, and it was happening because I was in a ruby project that didn't have Gemfile. So just go to your project's folder and run bundle init (it will add an empty Gemfile and rubocop will be happy!) You might need to restart VSCode.

@scorpion35
Copy link

scorpion35 commented Dec 20, 2021

Hello! I am running into same issue with rubocop extension as well. Trying to get it to work properly with my ruby project. Here's what I have so far -

~/.zshrc file -

<other settings...>
export RBENV_SHELL="zsh"
export RBENV_VERSION="3.0.3"
export RBENV_ROOT="$HOME/Documents/.rbenv_$RBENV_VERSION"
export GEM_HOME="$RBENV_ROOT/local-gems"
export GEM_PATH="$GEM_HOME"
export GEM_BIN_DIR="$GEM_HOME/bin"
export PATH="$GEM_BIN_DIR:$PATH"
export BUNDLE_PATH="$RBENV_ROOT"
export BUNDLER_VERSION='2.2.33'

eval "$(rbenv init - zsh)"
eval "$(rbenv global $RBENV_VERSION)"

I added gem rubocop to my Gemfile

Here are the settings in my project's .bundle/config file, for bundler - so bin_stubs are local to the project.

---
BUNDLE_BIN: "bin"
BUNDLE_CLEAN: "true"
BUNDLE_SYSTEM_BINDIR: "bin"

Here are the settings in my project's .vscode/settings.json file

 "ruby.format": "rubocop",
"ruby.useBundler": true,
"ruby.pathToBundler": "<project root path>/bin",
"ruby.rubocop.onSave": true,
"ruby.rubocop.useBundler": true,
"ruby.rubocop.executePath": "<project root path>/bin",
"ruby.rubocop.configFilePath": "<project root path>/.rubocop.yml",

When I try to edit any *.rb file, I am running into this issue -
image

Wondering why rubocop is looking in the system's GEM_PATH, which is wrong I think? Because I configured it to be a new value in my ~/.zshrc file - export GEM_PATH="$GEM_HOME"

Let me know if you need more information please. Any ideas what I am missing?

P.s: I do have Gemfile and Gemfile.lock in my project. Created the project using bundle gem ***

@scorpion35
Copy link

scorpion35 commented Dec 22, 2021

This issue is annoying me so much. I had to lookup how to and debugged the extension a bit lol

I think it has something to do with vscode/extension's process.env['PATH'] and process.env['PWD'] variables. I am noticed the following during the debug session in vscode's debug console -

process.env["PATH"]
'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands'

process.env["PWD"]
'/'

On the side, I made a quick node project and ran the exact command using same cp.execSync(... used by this extension. The command runs fine without any issues. That's because the terminal session I was running my test code in has the correct PATH setup
image

Here is my test code - `app.js`
    var cp = require('child_process');
    var fs = require('fs');

    const options = {
    cwd: '/Users/panne/Documents/Personal/algos',
    input: fs.readFileSync('/Users/panne/Documents/Personal/algos/lib/algos.rb', 'utf-8')
    };

    const args = [
    '/Users/panne/Documents/Personal/algos/lib/algos.rb',
    '--config',
    '/Users/panne/Documents/Personal/algos/.rubocop.yml',
    '--auto-correct']

    const stdout = cp.execSync('/Users/panne/Documents/Personal/algos/bin/rubocop', args, options).toString();

    console.log(stdout);

I am leaning more towards it's vscode's issue, because I am seeing the exact same issue with solargraph extension as well. Anyone aware how to make vscode load the ENV['PATH'] properly? Think that would solve this issue?

Apologies in advance for tagging you @misogi, would love to hear your thoughts or give me any pointers how to figure out to set correct PATH. Great work on this extension, just want to help by stabilizing it. People I know doesn't work with vscode extensions, need some help in figuring it out please :)

Update: Opened up this issue with vscode - microsoft/vscode#139639

And SO thread for more help - https://stackoverflow.com/questions/70453255/vscode-read-environment-vars-on-launch

@marlonguimaraes
Copy link

One year later, same problem

@ngouy
Copy link
Contributor

ngouy commented Mar 16, 2022

@marlonguimaraes

Most of the time when it happens when you update rubocop in your gemfile.lock, but vscode hasn't been reloaded since then (just happened to me, I never close vscode)

Make sure you ran bundle to update dependencies, make sure you don't have any pending update on vs code

Then hard reload vs code (quit + re-start), and it's gone

@reginato
Copy link

i have been this problem to, i made all kind of fixes and nothing yet

@developius
Copy link

developius commented Sep 22, 2022

Always launching VS Code from the terminal via code . fixes this for me, without changing any configuration options.
I think it's to do with inheriting the right environment variables - probably PATH?

@MarchandMD
Copy link

I have RuboCop installed globally (i believe).

This VSCode notification pops up when I clone into a project that does not have rubocop in the gemfile.

I add Rubocop to the project by running bundle add rubocop and it seems to satisfy the angry little popups from VSCode.

@irridescentrambler
Copy link

Always launching VS Code from the terminal via code . fixes this for me, without changing any configuration options. I think it's to do with inheriting the right environment variables - probably PATH?

This is the right thing to do. Fixed many problems for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants