Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Getting "Failed to run RuboCop command" with rbenv #2

Closed
gfrivolt opened this issue Nov 17, 2014 · 21 comments
Closed

Getting "Failed to run RuboCop command" with rbenv #2

gfrivolt opened this issue Nov 17, 2014 · 21 comments

Comments

@gfrivolt
Copy link

I tried to use the plugin. My rubies are managed by rbenv, rubycop is installed and getting this error messages:

ProcessNotCreatedException: Failed to run RuboCop command - is it (or bundler) installed? (SDK=/usr/local/var/lib/rbenv/versions/2.1.4/bin): Cannot run program "bundle" (in directory "/Users/fifigyuri/Projects/projname"): error=2, No such file or directory`

Rubocop is at other place (/usr/local/opt/rbenv/shims/rubocop) than what the plugin expected.

Do you support rbenv? I'm pretty much excited using the plugin, could you help me out? Thank you.

@mrcljx
Copy link
Owner

mrcljx commented Nov 17, 2014

Generally I thought I would already support rbenv (since I'm using it myself). But things are a little bit tricky in the OS X world. Could you help me by providing a few answers?

  1. Did you add rubocop to your Gemfile?
  2. Is the intended rbenv-Version of your Project "2.1.4" or a different one (which one?)?
  3. If YES, do you have Bundler installed for that version (i.e. does /usr/local/var/lib/rbenv/versions/2.1.4/bin contain the bundle program)?
  4. If NO (for question 2), is 2.1.4 marked as your default ruby version (see rbenv versions)?

@gfrivolt
Copy link
Author

here are the answers

  1. I did not have rubocop in my Gemfile, it was installed for ruby 2.1.4 not in the project bundle, now it's added.. I still get the same message
  2. YES, it's the ruby I use in rubymine, also it's specified in the Gemfile
  3. yes bundler 1.7.4 is installed, /usr/local/var/lib/rbenv/versions/2.1.4/bin contains the bundle cmd
  4. 2.1.4 is also the default ruby version I use

@richardwan
Copy link

I'm having the same issue running .rbenv on a mac (ruby 2.1.4, 2.1.2, 2.1.5 for different projects). rubocop runs fine from command line. I did notice that error message says RuboCop and the filesystem says rubocop. Could this be a case sensitivity issue?

I tried renaming the file from rubocop ot RuboCop and it did not help

@mrcljx
Copy link
Owner

mrcljx commented Nov 18, 2014

Could you install https://github.com/sirlantis/rubocop-for-rubymine/releases/tag/v1.0.1.rc1 and check whether this fixes the issue for you?

Please note, that I changed another thing: The project MUST include a .rubocop.yml - otherwise the inspector won't run (had error messages all the time in projects where I don't use it).

@mrcljx
Copy link
Owner

mrcljx commented Nov 18, 2014

Sorry, wrong link - it's https://github.com/sirlantis/rubocop-for-rubymine/releases/tag/v1.0.1.rc1 (not 1.0.0.rc1).

@richardwan
Copy link

after i installed, it started working (i deliberately created a style violation and it highlighted immediately) but now it is no longer detecting violations and i see nothing in the event logs.

I can see that rubocop has been added to the list of inspections. when i run inspections, they show up in the inspection list. it seems that if i close and reopen the project, i get the violations pointed in the file as tooltips. they disappear in real time as i fix them but they do not come back in real time though. is this the expected behavior?

the inspection window behaves as i expect. the editor window sometimes highlights the errors but not reliably so and i do not understand under what conditions violations will be pointed out in the editor. this is still an excellent plugin for the rubocop inspections alone. having the errors pointed out in real time is incredible - unfortunately it behaves as i expect only some of the time.

@gfrivolt
Copy link
Author

I've installed the updated plugin (1.0.1.rc1), also added an empty .rubocop.yml to the project root. But I still get this error:

Failed to run RuboCop command - is it (or bundler) installed? (SDK=/usr/local/var/lib/rbenv/versions/2.1.4/bin): Cannot run program "/usr/local/var/lib/rbenv/shims/bundle" (in directory "/Users/fifigyuri/Projects/projname"): error=2, No such file or directory

The bundle command is created in shims here /usr/local/opt/rbenv/shims/bundle. The rbevn root is stored in $RBENV_ROOT. Maybe it can help.

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

@richardwan RuboCop runs on the files that is saved to disk - if you have unsaved changes, the RuboCop annotations might be confusing. I guess that's the problem you've run in here.

In an early prototype of the plugin I didn't use the files on the file-system but wrote the content of the current Document (saved or unsaved) to /tmp first and then executed RuboCop on that file. The issue here is, that the exclude setting in the RuboCop-config would be "ignored" or it would cause other unwanted behaviour.

I added this issue as #3 - please continue discussion over there.

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

@fifigyuri Ah, so you have a global RBENV_ROOT. The problem is that in IntelliJ is launched by launchd which doesn't read your bashrc/zshrc and therefore RBENV_ROOT will always be undefined for IntelliJ.

My current strategy of using the SDK path and then finding the shim-folder next to it doesn't work because your ruby isn't stored within RBENV_ROOT (which it is, when you have a local installation, i.e. in /Users/me/.rbenv).

I dug around and found JetBrains rake runner http://svn.jetbrains.org/teamcity/plugins/rake-runner/trunk/rake-runner-agent/ which has a bunch of files just for checking all the cases but by looking through the code I guess they wouldn't pick up your root.

So I guess for it to work reliably we have to add a Settings panel and allow setting RBENV_ROOT over there.

For the meantime you could add a symlink.

sudo ln -s /usr/local/opt/rbenv/shims /usr/local/var/lib/rbenv/shims

@gfrivolt
Copy link
Author

Thanks, the ice moved, now it found what it wanted.. Now it seems like rubocop has issue:

Failed to parse RuboCop output.: End of input at line 1 column 1
java.io.EOFException: End of input at line 1 column 1
    at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1377)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:538)
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:368)
    at io.github.sirlantis.rubymine.rubocop.model.RubocopResult$object.readFromJsonReader(RubocopResult.kt:23)
    at io.github.sirlantis.rubymine.rubocop.model.RubocopResult$object.readFromReader(RubocopResult.kt:17)

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

Is this followed by anything? The catch block should also print the contents of stderr and stdout

ERROR: ...
OUTPUT: ...

@gfrivolt
Copy link
Author

That's the full error log I get:

Failed to parse RuboCop output.: End of input at line 1 column 1
java.io.EOFException: End of input at line 1 column 1
    at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1377)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:538)
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:368)
    at io.github.sirlantis.rubymine.rubocop.model.RubocopResult$object.readFromJsonReader(RubocopResult.kt:23)
    at io.github.sirlantis.rubymine.rubocop.model.RubocopResult$object.readFromReader(RubocopResult.kt:17)
    at io.github.sirlantis.rubymine.rubocop.RubocopTask.parseProcessOutput(RubocopTask.kt:76)
    at io.github.sirlantis.rubymine.rubocop.RubocopTask.runViaCommandLine(RubocopTask.kt:139)
    at io.github.sirlantis.rubymine.rubocop.RubocopTask.run(RubocopTask.kt:56)
    at io.github.sirlantis.rubymine.rubocop.RubocopAnnotator.doAnnotate(RubocopAnnotator.kt:134)
    at io.github.sirlantis.rubymine.rubocop.RubocopAnnotator.doAnnotate(RubocopAnnotator.kt)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.c(ExternalToolPass.java:186)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.access$400(ExternalToolPass.java:43)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.run(ExternalToolPass.java:122)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:298)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:295)
    at com.intellij.util.concurrency.QueueProcessor$2$1.run(QueueProcessor.java:110)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:107)
    at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:104)
    at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:215)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:212)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)



java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:126)
    at io.github.sirlantis.rubymine.rubocop.RubocopTask.parseProcessOutput(RubocopTask.kt:80)
    at io.github.sirlantis.rubymine.rubocop.RubocopTask.runViaCommandLine(RubocopTask.kt:139)
    at io.github.sirlantis.rubymine.rubocop.RubocopTask.run(RubocopTask.kt:56)
    at io.github.sirlantis.rubymine.rubocop.RubocopAnnotator.doAnnotate(RubocopAnnotator.kt:134)
    at io.github.sirlantis.rubymine.rubocop.RubocopAnnotator.doAnnotate(RubocopAnnotator.kt)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.c(ExternalToolPass.java:186)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass.access$400(ExternalToolPass.java:43)
    at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.run(ExternalToolPass.java:122)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:298)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:295)
    at com.intellij.util.concurrency.QueueProcessor$2$1.run(QueueProcessor.java:110)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:107)
    at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:104)
    at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:215)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:212)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

Could you try to do the following

  1. Help > Configure Debug Log Settings
  2. Add the following lines
io.github.sirlantis.rubymine
io.github.sirlantis.rubymine.rubocop
  1. Help > Show Log In Finder
  2. Cause RuboCop to fail once more
  3. Check the log for the last occurence of the error and send me the data around it (look for OUTPUT + ERROR)

@gfrivolt
Copy link
Author

I've performed the steps. No OUTPUT/ERROR pair was found, but Rubocop error are in it. Take a look at the full log: https://www.dropbox.com/s/6p6h40b7xnioiey/idea.log?dl=0.

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

Thanks for the log. The format of ERROR was a little bit different than I expected, but it's in the log.

2014-11-19 15:11:54,011 [ 122965]  ERROR -   io.github.sirlantis.rubymine - ERROR
Details: /usr/local/opt/rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/rubygems_integration.rb:256:in `block in replace_gem': rubocop is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
    from /Users/fifigyuri/Projects/environet3x/ui/vendor/bundle/ruby/2.1.0/bin/rubocop:22:in `<main>'

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

You should be able to fix it by adding gem 'rubocop' to the Gemfile.

@gfrivolt
Copy link
Author

ah, yes, I've done already yesterday on different dev branch, forgot to add it back.. Sorry, for the confusion.

It works now, but I still think though if it could be possible that the rubocop gem would be sufficient to have in the gemset for the ruby, not on project.

Thank you very much for your help, that's wonderful tool.

@mrcljx
Copy link
Owner

mrcljx commented Nov 19, 2014

Yeah, I kind of agree. Or at least it the problem/solution could be more obvious.

However I highly recommend adding RuboCop to the Gemfile (development group). We had some issues because everyone in the team was using a different one and RuboCop's config format changed a lot lately.

@djantzen
Copy link

djantzen commented Dec 8, 2014

Hi, thanks for putting this plugin together! I also ran into the error above regarding bundler and got past it using the v2.0.0.rc1 build. In the logs however I see:

2014-12-08 10:22:51,236 [ 393329] INFO - s.ruby.ruby.run.AbstractRunner - Executing [/Users/djantzen/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/bundler-1.7.0/bin/bundle exec rubocop --format json /Users/djantzen/code/application/app/models/impact_zone.rb], working dir =[/Users/djantzen/code/application]
2014-12-08 10:22:53,004 [ 395097] WARN - hub.sirlantis.rubymine.rubocop - RuboCop exited with 1

Env:
OSX
rbenv
Ruby 1.9.3-p547
RubyMine 6.3

Rubocop runs from the command line, any idea what's failing when it runs from RubyMine?
Thanks,
David

@mrcljx
Copy link
Owner

mrcljx commented Dec 8, 2014

@djantzen Exit code 1 is also sent from RuboCop if it finds any violations. So if there's nothing else in your log file I would assume it runs fine.

@djantzen
Copy link

djantzen commented Dec 8, 2014

All right, looks like it's working. I appreciate the quick response!

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

No branches or pull requests

4 participants