umbregachoong
umbregachoong

Reputation: 349

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

Upvotes: 5

Views: 969

Answers (2)

Arihant Jain
Arihant Jain

Reputation: 1

don't do anything just go to application/assets/javascript/application.js and remove

'//'

from

//=require turbolinks

to

=require turbolinks

that will basically uncomment the line from the file This step made my work done when i faced similar error in Default rails server going through RAILS Tutorial. I am using Windows 10 PC and this solved my case

Upvotes: 0

Yumecosmos
Yumecosmos

Reputation: 944

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

Upvotes: 2

Related Questions