senny/rvm.el

Unable to set ruby version 2.0 using rvm.el

firesofmay opened this issue · 11 comments

Hi,

I added the following to my configuration:

(require 'rvm)
(rvm-use-default) ;; use rvm's default ruby for the current Emacs session

But when I run the following function:

(defun jekyll-start ()
  "Start the Jekyll daemon in auto mode."
  (interactive)
  (let ((default-directory jekyll-directory))
    (start-process-shell-command "jekyll" "*jekyll*" "jekyll serve --watch")))

I get the following error. Any ideas?

Configuration file: /Users/firesofmay/src/static-sites/myblog/_config.yml
            Source: /Users/firesofmay/src/static-sites/myblog
       Destination: /Users/firesofmay/src/static-sites/myblog/_site
      Generating... /Users/firesofmay/.rvm/gems/ruby-2.0.0-p247/gems/rdiscount-2.1.6/lib/rdiscount.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]


Process jekyll abort trap: 6

What do you get when you evaluate:

(getenv "PATH")

and

(shell-command-to-string "ruby -v")

The line /Users/firesofmay/.rvm/gems/ruby-2.0.0-p247/gems/rdiscount-2.1.6/ looks like it's picking up the right gems but with the wrong ruby version. What binary is jekyll how does it locate the ruby to use?

Here's the output:

(insert (getenv "PATH"))
/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin/:/usr/local/smlnj/bin:/usr/local/bin:/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/bin:/Users/firesofmay/mybin:/usr/local/Cellar/coreutils/8.19/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/firesofmay/bin:/Users/firesofmay/android-sdk-macosx/platform-tools:/Users/firesofmay/android-sdk-macosx/tools:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/X11/bin:/usr/local/smlnj/bin
(insert (shell-command-to-string "ruby -v"))
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
(insert (shell-command-to-string "jekyll -v"))
jekyll 1.2.1

I am not sure how to check how it locates what ruby to use. Any ideas?

(insert (shell-command-to-string "ruby -v")) should return ruby 2 and not your system ruby. So the problem is within the Emacs environment and not related to the Jekyll binary. What's strange is why you get 1.8.7 even though your PATH contains /Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin.

What do the following return:

(shell-command-to-string "which ruby")

and

ls /Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin

Also it would be interesting what your PATH looks like in a terminal where you can execute jekyll. You can get it with printenv PATH.

as a sidenote, please use ``` around your pasted code to make it look nice on GitHub.

Updated my comment to add code blocks.
Here's the output.

(insert (shell-command-to-string "which ruby"))
/usr/bin/ruby
(insert (shell-command-to-string "ls /Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin"))
erb
gem
irb
rake
rdoc
ri
ruby
testrb

From command line:

$ printenv PATH
/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/bin:/Users/firesofmay/mybin:/usr/local/Cellar/coreutils/8.19/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/firesofmay/bin:/Users/firesofmay/android-sdk-macosx/platform-tools:/Users/firesofmay/android-sdk-macosx/tools:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/X11/bin:/usr/local/smlnj/bin

I am really confused why it picked /usr/bin/ruby :-/

It's extremely confusing that you get the system ruby even though there is a ruby binary in /Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin. One last thing I need to know is (shell-command-to-string "printenv PATH") it should be equal to (getenv "PATH") but we better make sure.

When you enter which ruby from the terminal you get /Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin/ruby I assume?

Aha! /usr/bin is coming before the ruby2.0 hence it finds the older version before! But why? :-/
Btw I am using zsh on terminal. Not sure if that helps.

(insert (shell-command-to-string "printenv PATH"))
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin/:/usr/local/smlnj/bin:/Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/firesofmay/.rvm/bin:/Users/firesofmay/mybin:/usr/local/Cellar/coreutils/8.19/libexec/gnubin:/Users/firesofmay/bin:/Users/firesofmay/android-sdk-macosx/platform-tools:/Users/firesofmay/android-sdk-macosx/tools:/Library/Frameworks/Python.framework/Versions/2.7/bin

And yes on terminal it finds the correct ruby.

$ which ruby                                                                                                                                                           
/Users/firesofmay/.rvm/rubies/ruby-2.0.0-p247/bin/ruby

And btw I am using this library called exec-path-from-shell which is supposed to load the paths correctly.

And I have this for loading it:

 (require 'exec-path-from-shell)

(when (memq window-system '(mac ns))
  (exec-path-from-shell-initialize))

I guess it must be something with your configuration then. Please boot a vanilla Emacs and load rvm.el and see wether ruby -v returns 2.0. If it does, then your issue is somewhere hidden in your configuration and you'll have to find it yourself.

@firesofmay did it work in a vanilla Emacs? Could you identify the part of your config that modifies the path?

I haven't got time to dig more deep into it.
Will share my findings soon.

On Thu, Oct 17, 2013 at 11:49 AM, Yves Senn notifications@github.comwrote:

@firesofmay https://github.com/firesofmay did it work in a vanilla
Emacs? Could you identify the part of your config that modifies the path?


Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-26481574
.

Regards,
Mayank.

@firesofmay what is the state of this issue? Do you still experience problems? Can we close it?

Didn't check it up after that sorry.
You can close this issue for now. If I find a solution or I can find the
exact problem i'll reopen the ticket.

Thanks.

On Sat, Dec 14, 2013 at 3:09 PM, Yves Senn notifications@github.com wrote:

@firesofmay https://github.com/firesofmay what is the state of this
issue? Do you still experience problems? Can we close it?


Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-30563803
.

Regards,
Mayank.