rubocop / rubocop-emacs

An Emacs interface for RuboCop
128 stars 30 forks source link

Problem with rvm #31

Open davidw opened 5 years ago

davidw commented 5 years ago
-*- mode: compilation; default-directory: "~/workshop/xxxxxxxyyyyyyyyyzzzzzzzz/" -*-
Compilation started at Tue Jun  4 09:39:33

bundle exec rubocop --format emacs /home/davidw/workshop/xxxxxxxyyyyyyyyyzzzzzzzz/
/bin/bash: bundle: command not found

That is from an emacs I had running.

If I start an Emacs in the project directory, and run things, it all seems to work well.

uri-t commented 3 years ago

I think this is because the compilation mode runs in a non-login shell so the rvm hooks etc. don't load. I'm not sure if there's a way to have it run as a login shell, but I was able to get around this by manually loading the profiles script (see below: without the source .. part it gave the wrong ruby binaries, but with it included it gave the right ones).

(defun rvm-load-example()
  (interactive)
  (compilation-start "source /etc/profile.d/rvm.sh && cd [project path] && which ruby")
)

You might be able to get it working by adding something like (concat "source /etc/profile.d/rvm.sh && " ... in the rubocop-build-command function, but I'm not exactly sure how to make this also work for non-rvm users.