Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExecJS::RuntimeError running the Getting Started with Rails blog on cygwin (windows7)

I am trying to run the Getting Started with Rails blog on cygwin (windows7). I get the following error message:

ExecJS:: RuntimeError in Welcome#index

module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\tmp\execjs20130903-50672-1vn7gqc.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

  (in /usr/lib/ruby/gems/1.9.1/gems/turbolinks-1.3.0/lib/assets/javascripts   /turbolinks.js.coffee)

node is installed.

This is after

$rails generate controller welcome index
$rails s

I am running Rails 4.0 on cygwin Any ideas why this might be happening?

Thanks

umbregachoong

like image 985
umbregachoong Avatar asked Nov 01 '22 15:11

umbregachoong


1 Answers

I encountered this error and it had to do with the path to the temp file being wrong. I was able to fix it by changing the following two files in \gems\[ruby version]\gems\execjs-2.0.2\lib\execjs. (Possibly found in \usr\lib\ruby\, but that depends on how your Ruby is installed. I'm using RVM so mine is different.)

external_runtime.rb

compile_to_tempfile(source) do |file|
     extract_result(@runtime.send(:exec_runtime, file.path))
  end
end

should change to

compile_to_tempfile(source) do |file|
    filepath = file.path
    if ExecJS.cygwin? && @runtime.name == "JScript"
      IO.popen("cygpath -m " + file.path) { |f| filepath = f.read }
      filepath = filepath.gsub("\n","")
    end
    extract_result(@runtime.send(:exec_runtime, filepath))
  end
end

module.rb

Add this right before the last two ends.

def cygwin?
  @cygwin ||= RbConfig::CONFIG["host_os"] =~ /cygwin/
end

After this restart your Rails server and with any luck it should work.

Source: https://github.com/sstephenson/execjs/issues/78

like image 151
Yumecosmos Avatar answered Nov 13 '22 19:11

Yumecosmos