fanchyna fanchyna - 6 months ago 50
Ruby Question

Installing Jruby changes default paths of Ruby and Rails

I am new to Ruby and Rails, and have been following the tutorial on this website: http://guides.rubyonrails.org/getting_started.html

I installed Ruby 2.2.1 and Rails 4.2.6. I used

rvm
to install Ruby and
gem
to install Rails.

To start the web server, I need to have a Javascript runtime. I choose therubyrhino. To install it, I need to first install JRuby. I used
gem
to install it

$ rvm install jruby


After that I found that the default path of Ruby and Rails are both changed to:

~/.rvm/gems/jruby-9.0.5.0/bin/rails
~/.rvm/rubies/jruby-9.0.5.0/bin/ruby


This causes problems because I even cannot run

$ ruby -v


or

$ rails -v


I could not start the web server

$ bin/rails server
TypeError: no implicit conversion of Regexp into String
join at org/jruby/RubyArray.java:1760
<top> at /home/jxw394/rails-projects/blog/bin/spring:11
load at org/jruby/RubyKernel.java:955
<top> at bin/rails:3


Why does installing JRuby change everything? What should I do to get the webapp running?

Edit: sorry I made a typo: it should be "therubyrhino" instead of "therubyracer". This has been corrected above.

Edit: sorry, I made a typo: I installed jruby using rvm instead of gem. This has been corrected above.

Answer

You don't need jruby in order to install therubyracer. You only need to comment out therubyracer entry in Gemfile

gem 'therubyracer', platforms: :ruby

One another way which doesn't involve therubyracer is to install node.js.