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

Complains that rubocop is not installed when bundling with --path #17

Closed
imtayadeway opened this issue Oct 20, 2015 · 9 comments
Closed

Comments

@imtayadeway
Copy link
Contributor

I'd noticed that flycheck hasn't been giving me rubocop feedback for a while. Just tracked this down - it's because when I bundle install I use the --path flag to put my gems in vendor/bundle. Hence, if I want to run the executable rubocop in my project I have to run bundle exec rubocop. rubocop mode doesn't know this, however, and will simply not run with flycheck. Only on invoking something like M-x rubocop-check-current-file will it complain that rubocop is not installed.

I realized that I can work around this by installing rubocop using my current Ruby with gem install rubocop i.e. outside of bundler. Of course, I would have preferred it if it had Just Worked.

If this seems like an issue you'd like addressed I'd be happy to tackle it. Thanks!

@imtayadeway
Copy link
Contributor Author

@bbatsov anything I can do to help bring this to some resolution?

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 10, 2015

Won't customising rubocop-check-command solve your problem? You can set it via a .dir-locals.el file just for the projects you want to use bundle exec rubocop.

@imtayadeway
Copy link
Contributor Author

I have tried playing around with that before. Adding it now (and removing the rubocop gem and hence executable from my PATH) results in "RuboCop is not installed" when invoking rubocop-check-current-file, etc., however I can bundle exec rubocop in my shell successfully. Doing M-: rubocop-check-command reveals that I have set it correctly and displays bundle exec rubocop

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 11, 2015

Maybe exec-path is not properly set in Emacs. See if you can run bundle exec rubocop from M-!. If not, you can take a look at exec-path-from-shell https://github.com/purcell/exec-path-from-shell.

@imtayadeway
Copy link
Contributor Author

That works as expected - I'm using exec-path-from-shell

@edebill
Copy link

edebill commented Nov 20, 2015

I have rubocop installed to /usr/local/bin on my El Capitan Mac (installed with rvm use system; sudo gem install rubocop).

I persistently get this problem. I fixed it with:

(require 'rubocop)
(setq rubocop-check-command "/usr/local/bin/rubocop --format emacs")
(defun rubocop-ensure-installed () )

@imtayadeway
Copy link
Contributor Author

@bbatsov it looks like this function is short-circuiting some of the commands because it explicitly can't find rubocop in exec-path. Is there any way this could be changed to optionally check if rubocop has been bundled?

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 2, 2015

We can always check the command to do both checks. PRs welcome. :-)

@imtayadeway
Copy link
Contributor Author

@bbatsov thanks! I will try to tackle this in the coming week

imtayadeway added a commit to imtayadeway/rubocop-emacs that referenced this issue Dec 5, 2015
For those that vendorize their gems, the rubocop binary may not be on
the exec path, even if it has been bundled. For such users, their check
command will need to be `bundle exec rubocop` instead. This change will
allow rubocop-emacs to proceed with using the bundled rubocop if rubocop
is not found on the exec path.

Fixes rubocop#17
bbatsov pushed a commit that referenced this issue Jan 20, 2017
For those that vendorize their gems, the rubocop binary may not be on
the exec path, even if it has been bundled. For such users, their check
command will need to be `bundle exec rubocop` instead. This change will
allow rubocop-emacs to proceed with using the bundled rubocop if rubocop
is not found on the exec path.
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

3 participants