Skip to content


Subversion checkout URL

You can clone with
Download ZIP


ExecJS::RuntimeError on new Windows apps (gibberish produced) #48

sevenseacat opened this Issue · 24 comments

Note: this isn't an issue I'm having, and I'm not entirely sure it's a ExecJS issue, but I've seen it come up three times today for Windows folks starting new apps and getting quite baffled, and I'd like to be able to help them fix it!

The error looks like so for a new app (this user was following the RailsTutorial)

And the user's setup/Gemfile.lock is like so:

I thought this may have been tied to the issue fixed in execjs 1.2.7 but apparently not. :(


Thanks for taking the time to help :)


Theres no ExecJS backtrace in that gist.

@josh josh was assigned

Related discussion, including a backtrace:


Still need more info, but heres some things to try:

  1. Use sstephenson/execjs not kennyj/execjs
  2. Try version 1.2.7
  3. Try version 1.2.4. This was before some windows related changes were introduced.
  4. See if you can find out your cscript version cscript //? (also what windows version)
  5. Do you have node.js installed?

1.2.4 works. 1.2.7 does not.

I encounter this on Windows 7 / CScript v5.8

Forcing 1.2.4 in the gemfile fixes the error.

edit: no NodeJS installed. Clean machine


@napcs interesting. Do you think you could binary search test between 1.2.4 and 1.2.7. Would like to find the regressing commit.


@josh I can certainly give it my best shot. Already narrowed this down to something between 1.2.6 and 1.2.7, as 1.2.5 and 1.2.6 gems both work fine.


Could it be this 53c5f05 commit?


That's the only difference you did other than the node UTF one. Also these problems didn't start till yesterday. What's the escaping for? I didn't see a unit test for the output that gave me an indication of what the escaping was supposed to look like.


Ah crap, I bet the escaping is screwing up the command args "cscript //E:jscript //Nologo //U".

Maybe try removing the escaping from this line output = sh("#{Shellwords.join([@binary, filename])} 2>&1").

We just need to support the case where the binary or filename would have spaces in it.


Yes. Shellwords isn't the best approach as it has interesting side effects:

Shellwords.escape binary
=> "c:\\\\program\\ files" 

Definitely not what you're looking for.

 binary = 'c:/program files'
 Shellwords.escape binary
 => "c:/program\\ files" 

From the docs, Shellwords "Escapes a string so that it can be safely used in a Bourne shell command line."

That's not gonna be a good fit for Windows. When I've done this for Windows, I've simply wrapped the thing with double quotes. The problem here is that you need a solution that's generic.

What do you suggest?


I tested shellwords in windows a little.

I think that shellwords does not performed well in windows.
@josh 's comment is right. But, if filename(or cscript path) include a space , "&" and so on, it will not perform well.


2011/09/21 01:10 19 a&
2011/09/21 01:10 19 a

irb(main):001:0> require 'shellwords'
=> true
irb(main):002:0> IO.popen(Shellwords.join(['c:\windows\node.exe', 'a&']))
=> #
throw e; // process.nextTick error, or 'error' event on first tick
Error: Cannot find module 'C:\Sites\a&'
at Function._resolveFilename (module.js:318:11)
at Function._load (module.js:263:25)
at Array. (module.js:454:10)
at EventEmitter._tickCallback (node.js:195:26)

irb(main):004:0* Shellwords.join(['c:\windows\node.exe', 'a&'])
=> "c:\\windows\\node.exe a\&"

irb(main):005:0* IO.popen(Shellwords.join(['c:\windows\node.exe', 'a']))
=> #
throw e; // process.nextTick error, or 'error' event on first tick
Error: Cannot find module 'C:\Sites\a'
at Function._resolveFilename (module.js:318:11)
at Function._load (module.js:263:25)
at Array. (module.js:454:10)
at EventEmitter._tickCallback (node.js:195:26)

irb(main):007:0* Shellwords.join(['c:\windows\node.exe', 'a'])
=> "c:\\windows\\node.exe a\"

can't find a\& and a\


Confirmed, commit 53c5f05 fails for me, and commit 642067e works for me.

Also reverting just the following one line resolves this issue for me: 53c5f05#L0L123


I think I'd like to keep the shellwords stuff around for unix but we'll need an alternative method for windows.

Thinking this api:

  def shell_escape(*args)
    # ???
  def shell_escape(*args)

Any ideas?


Haven't tested on windows, but maybe this will work 1332be0?


I just debugged the same problem and can confirm that 1.2.4 works while 1.2.7 don't. This wasn't on my machine, but I managed to get a screenshot comparing 1.2.4 and 1.2.7.

As far I can tell the difference lies in encoding?


@josh: with 1332be0 I can't even find a JS runtime. There are two problems here, @binary has spaces and is meant to be multiple shell tokens, and the escape character on Windows is a caret not a backslash. See #49 for my attempt to fix both. Tested on Windows 7.


Pulled in Sam's patch. Please test and I'll ship a new ExecJS release.

Thanks for the help guys.


I have same problem. I just tested with execjs 1.2.4 on Windows XP and it works.



1.2.8 is out

@josh josh closed this

I'm receiving the same error while running the Ruby on Rails tutorial with execjs 1.4.0. Reverting to 1.2.4 resolves the issue.


+1. Same experience as BricePuls, on Windows 7 64-bit.


I managed to fix this from using Win8 64-bit with the help of BricePuls and josh. If you're still having problems after you've tried everything else, try this:

  1. Run gem install --version '1.2.4' execjs
  2. Add gem 'execjs', '1.2.4' anywhere in your Gemfile.
  3. Run bundle install
  4. Start your server with rails s and your problem should be solved.

I followed Puyttre's directions and the exact problem posed on this thread was fixed! Thanks so much!!

I'm running Win8 64-bit too

@josh josh removed their assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.