开发者

problem with execjs doing michael hartl tutorial on windows... ExecJS::RuntimeError in Users#index

I'm new to ruby and rails and walking (crawling?) through the tutorial. the second project uses scaffolding to create a user that consists of a name and email address. when i try to view the users screen I get the following:

ExecJS::RuntimeError in Users#index

Showing /home/max/rails_proj/demo_app/app/views/layouts/application.html.erb where line #6 raised:

湉異⁴牅潲㩲唠歮潮湷漠瑰潩⼢浴⽰硥捥獪〲ㄱ㤰㔲㐭㜲ⴲ㠱㝮穩ⴰ⸰獪•灳捥晩敩⹤਍
  (in /home/max/rails_proj/demo_app/app/assets/javascripts/users.js.coffee)
Extracted source (around line #6):

3: <head>
4:   <title>Demo开发者_开发知识库App</title>
5:   <%= stylesheet_link_tag    "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>
Rails.root: /home/max/rails_proj/demo_app

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__1031573605_1065816420'
app/controllers/users_controller.rb:7:in `index'

I am using windows xp, cygwin, rails 3.1.0 (i've tried the new rc1 also), ruby 1.8.7.

I found this error on google and there's supposedly a fix which i've tried to use (the execjs gem 1.2.9) but that doesn't seem to fix it for me.... i have tried all the fixes (to the best of my limited ruby etc ability at this point) but nothing seems to work although the error message is sometimes different - still errors on the same line.

I've tried to uninstall and reinstall cygwin, ruby, rails etc.. to no avail so far...

any feedback would be great!


I got the same error on cygwin. I tried compiling the latest node.js (v0.6.15) but it said cygwin was not supported. Older version seem to support it so here's what I did:

wget http://nodejs.org/dist/node-v0.4.12.tar.gz
tar xvfz node-v0.4.12.tar.gz
cd node-v0.4.12/
./configure
make
make install

I'm not sure if there is a newer version than 0.4.12 that will work under cygwin, but this seems to fix my problem for now. Also I seemed to have the proper prereq's but if you have trouble during configure or make then just do a search on "step by step install nodejs cygwin".


I am not sure if this will work in your case, but on Ubuntu you can add

gem 'therubyracer'

to your Gemfile and it will work just fine.

Another tip would be to comment out the following lines in the Gemfile:

group :assets do
#  gem 'sass-rails', "  ~> 3.1.0"
#  gem 'coffee-rails', "~> 3.1.0"
#  gem 'uglifier'
end

since those are the ones that require execjs


I also had this problem, and it was solved installing a javascript runtime:

sudo apt-get install nodejs

I follow this post:

http://www.adanacs.com/node/3

Good luck!


As someone who tried to do that book on windows, I have 2 pieces of advice:

  1. Install Ubuntu to run ruby on rails. It is a little bit of work, but if you are going to invest time and effort it is worth it 100 times over. You can set up dual install with existing windows. Or, just find an old computer and install it on there. It uses much less power than windows xp and only about 300 Mb of memory.

  2. Start with Agile Web Development with Rails. http://www.amazon.com/Agile-Development-Rails-Pragmatic-Programmers/dp/1934356549 . It is a much better first tutorial.


I had a similar problem. Helped me to update Ruby 1.9.3 on Ruby 2.0.0.


Run

bundle install

in cmd and it will install some new gems.

Go back to cygwin and launch your server

rails s

and all will be well. I had the same problem. Cygwin seems to be the issue here.


On windows, I had the same problem. It seems there is no javascript interpreter installed to compile the coffeescript that is used in scaffolds. Install node.js from http://nodejs.org/ and restart the command prompt you were using to run rails, in order to update the path.

I don't have cygwin installed, so I couldn't compile node.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜