Adding Rubocop to Atom.io


#1

Hi,

I am a new ruby programmer and I am trying to add Rubocop to Atom.io. I went to
https://atom.io/packages/linter-rubocop and following the installation. I did install the linter package in my linux terminal. That seem to be fine.

But when I typed $ gem install rubocop into my linux, I received the message.

You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

So now I keep getting an error message in Atom saying:

[Linter] Error running RuboCop Error: Failed to spawn command rubocop. Make sure rubocop is installed and on your PATH
at /Users/sinhful/.atom/packages/linter-rubocop/node_modules/atom-linter/lib/helpers.js:130:24

Any help or direction would be greatful!

Linh


Error running RuboCop
#2

Okay, so you haven’t installed RuboCop because there’s a write permission error. I don’t know Ruby, but that seems abnormal. Perhaps that particular folder (/Library/Ruby/Gems/2.3.0) is owned by someone other than you, possibly root if it was installed using sudo when sudo wasn’t necessary. Again, I have no experience with Ruby, but that’s possible in Linux. You should check the properties of that folder.


#3

Hi, I was finally able to install rubocop, google a lot to get there. But now I have this Linter error. I think I have to move rubocop into a specific file, but I am not sure. Relatively new to this process, so this error message is a bit new jargon to me.

[Linter] Error running RuboCop Error: Failed to spawn command rubocop. Make sure rubocop is installed and on your PATH
at /Users/sinhful/.atom/packages/linter-rubocop/node_modules/atom-linter/lib/helpers.js:130:24
at process._tickCallback (internal/process/next_tick.js:103:7)


#4

You should Google “environment variable bash” as well. It’s very good to know about. Here’s a good place to start.

First things first: have you closed Atom completely and reopened it since installing RuboCop? If no, then do so and try again. If that doesn’t work, open a command line and type printenv PATH. You will also need to find out where RuboCop is installed, then you can look to see if the install directory is on the PATH.


#5


I actually know which paths they are on? Is it because rubocop is outside of lint since I am getting the attached web dev error?


#6

What’s the result of printenv PATH?

Is there a binary file directly inside /Users/sihnful/gems/gems/rubocop-0.52.1? It’s possible that the binary is in a bin/ folder inside the parent folder, and that’s important to know.


#7

Rubocop is in the binary file.


#8

When I printenv PATH. I get my python path???


#9

More than one directory can be listed in the PATH variable. Think of it as providing quick over-all access to program paths. For example you can call python in the terminal instead of needing to call out the full directory path.

Many packages in Atom is a middle man between Atom and programs installed on your computer. For your case you need to have Rubocop installed and it must be accessible to Atom without special privileges and through the PATH lookup. Web search what that means.

Focus your efforts in getting the app installed so that its directory is mentioned in PATH or manually add it to PATH.

As I am not familiar with Ruby or Mac these are but hints… hopefully helpful.
Good luck.


Late additions:

  1. https://en.wikipedia.org/wiki/PATH_(variable)
  2. http://osxdaily.com/2014/08/14/add-new-path-to-path-command-line/
  3. https://medium.com/@himanshuagarwal1395/setting-up-environment-variables-in-macos-sierra-f5978369b255

#10

No, Python is just the first set of entries. You can see that the last one is for rvm, and in the middle are generic ones like /usr/local/bin. I don’t see /Users/sinhful/gems/bin on there, so that’s the directory you want to add.


#11

I finally fixed it.

I did:
brew install ruby
brew install rbenv ruby build
which rbenv
which gem
gem install rubocop

Thanks for all the assist!