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

Doesn't use correct ruby with rvm #3

Open
prathamesh-sonpatki opened this issue Dec 8, 2013 · 10 comments
Open

Doesn't use correct ruby with rvm #3

prathamesh-sonpatki opened this issue Dec 8, 2013 · 10 comments

Comments

@prathamesh-sonpatki
Copy link
Contributor

When i try to run tests, it uses my default ruby but not the version mentioned in current project's .ruby-version file.

Maybe if we change directory to project-root before running minitest command we can solve this problem.

Right now it works as bundle exec <command>

How can we change it to
cd <project_root> && bundle exex <command>

@prathamesh-sonpatki
Copy link
Contributor Author

@arthurnn Do you face same issue?

@arthurnn
Copy link
Owner

hey, i am not actually using minitest-mode + rvm , so neve catch that issue.. anyways, i added rvm-activate-corresponding-ruby to it, to use the current version of rvm if possible. this should do the trick.. lemme know

@prathamesh-sonpatki
Copy link
Contributor Author

@arthurnn Thanks. Is the new release available under Melpa/Marmalade? I couldn't find the update

@arthurnn
Copy link
Owner

they should be in both...(Melpa/Marmalade)

@prathamesh-sonpatki
Copy link
Contributor Author

@arthurnn I installed new version. But the problem persists

-*- mode: minitest-compilation; default-directory: "~/Projects/sources/codetriage/" -*-
 started at Tue Dec 17 22:05:22

 bundle exec rake
Your Ruby version is 2.1.0, but your Gemfile specified 2.0.0

 exited abnormally with code 18 at Tue Dec 17 22:05:23

My default ruby version is 2.1.0 but .ruby-version specifies 2.0.0 But its not picked up.

@dagda1
Copy link

dagda1 commented Aug 21, 2014

I have the same problem, my output is:

*- mode: minitest-compilation; default-directory: "~/projects/crm/" -*-
  started at Thu Aug 21 13:38:45

 bundle exec ruby -Ilib\:test\:spec bundle exec ruby -Ilib\:test\:spec /Users/paulcowan/projects/crm/test/requests/emails/check_for_response_test.rb -ntest_creates_check_for_contact_response_tests_for_new_contact

 Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2

  exited abnormally with code 18 at Thu Aug 21 13:38:46

I added the following to my ~/.emacs file:

(require 'minitest)
(add-hook 'ruby-mode-hook 'minitest-mode)

(add-hook 'ruby-mode-hook
          (lambda () (rvm-activate-corresponding-ruby)))

But this did not cure the problem.

@arthurnn arthurnn reopened this Aug 22, 2014
@arthurnn
Copy link
Owner

I will reopen this, as people seem to still have the issue.

@dylan-conlin
Copy link

I had this same problem with ruby-test-mode.el, but solved it by setting shell-file-name to "/bin/bash" in an advised compilation function. I haven't verified this works with minitest-emacs, but it's worth a shot. Here's what you might add to your .emacs:

(defadvice minitest--run-command (around minitest--run-command-around)
  "Use BASH shell for running the specs because of ZSH issues."
  (let ((shell-file-name "/bin/bash"))
    (if (fboundp 'rvm-activate-corresponding-ruby)
    (rvm-activate-corresponding-ruby))
    ad-do-it))

(ad-activate 'minitest--run-command)

@cowboyd
Copy link

cowboyd commented May 28, 2015

For anybody coming across this using rbenv, I was able to find a solution that worked based on @dylan-conlin's solution, but using rbenv and not the defadvice macro which is apparently deprecated.

(defun cowboyd-minitest-setup-env (do-run &rest arguments)
  "Use Bash for minitest to avoid Zsh issues. Also, activate rbenv ruby if
necessary"
  (let ((shell-file-name "/bin/bash"))
    (rbenv-use-corresponding)
    (apply do-run arguments)))


(advice-add 'minitest--run-command :around #'cowboyd-minitest-setup-env)

@arthurnn
Copy link
Owner

arthurnn commented Oct 6, 2015

We have something to activate RVM before running the command

(if (fboundp 'rvm-activate-corresponding-ruby)
(rvm-activate-corresponding-ruby))
, that should fix the rvm case, not the rbenv tho. Can anyone running RVM confirm that for me?
@cowboyd if you wanna send a patch to make this rbenv compatible would be nice.

thanks all

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

5 participants