2

I am getting started with Ruby on Rails, and following the steps at InstallRails... I have created the sample_app on the desktop, and now I cannot create the server.

My command

$ rails server

is answered with the following

...There was an error while trying to load the gem 'uglifier'.  etc

I have read several threads here and elsewhere, such as this one and this one... In the latter there seems to bea solution, which I can't understand.... I cannot download node.js! or nodejs? What is my command and directory in Gitbash to download it?

Community
  • 1
  • 1
Philet
  • 73
  • 7

1 Answers1

1

It requires JS runtime. Just install gem therubyracer for the JS runtime. In the default rails Gemfile,uncomment the line for the gem 'therubyracer' which is commented out.If you dont find it add the gem to your Gemfile like

gem 'therubyracer'

Then run

bundle install

The gem will be installed and it should work.

Otherwise you can install node.js.

For ubuntu

sudo apt-get install nodejs

For mac

brew install nodejs 
bilash.saha
  • 7,226
  • 2
  • 35
  • 40
  • Thanks Bilash... I understand you, but I don't understand enough to execute haha... I get an error when I put into gitbash or cmd.exe 'gem install therubyracer'... I also tried your first method, and located what I thought was a gemfile, but I don't think it was the default rails Gemfile, as you called it. I did not find a line with therubyracer gem which was commented in the file I found. Where do I find the Default Gemfile? I feel like that would be easiest, but I don't know where to change that! – Philet Mar 25 '16 at 19:06
  • Okay, I am further along now... I have found and uncommented the line for 'therubyracer' in my default gemfile. I have also run 'gem install bundler' ... but when I run 'bundle install' I get could not locate gemfile etc error... – Philet Mar 25 '16 at 19:19
  • Alright, even further now! I found that I was not in the right directory for 'bundle install'... So I did 'cd APP_NAME' and then 'bundle install' and had a sucessful install. I immediately entered 'rails server' and I got the same error as I started with, having to do with the uglifier gem... working on it! – Philet Mar 25 '16 at 19:27
  • I'm going in circles now.... can't install node.js and 'rails server' still yields the same error... I just want to get up and running to start tutorials! – Philet Mar 25 '16 at 19:50
  • 1
    Alright! I am past this problem and onto the next! Ultimately, installing node.js was the fix for the uglifier load error. therubyracer cannot be installed on WIndows, and so my time messing around trying to make it work that way was futile, if informative haha. Thank you for your thorough answer @bilash.saha – Philet Mar 26 '16 at 00:39
  • This might be an old post but i want to ask another relates question(i am banned here). I am new to ruby(installing it currently), then when i type ruby bin/rails server, it gave me the 'could not find gem uglifier (>= 1.3.0). And my pc doesnt have internet connection. what should i do? – Slim Shady Jun 18 '16 at 14:11