This repository has been archived by the owner. It is now read-only.

CSCRIPT.EXE doesn't work out-of-the-box on Windows 8 Consumer Preview #81

Closed
jediry opened this Issue Apr 25, 2012 · 43 comments

Comments

Projects
None yet
@jediry

jediry commented Apr 25, 2012

Getting Rails to work on Windows 8 CP has been challenging...the biggest hurdle has been that ExecJS isn't working. I finally tracked it down to something related to the character encoding: if I remove the //U flag to cscript.exe and change the output encoding to UTF-8 in runtimes.rb, it works again. Not sure whether this is a problem with Ruby on Win8, or with cscript.exe on Win8.

@floringogianu

This comment has been minimized.

floringogianu commented May 8, 2012

Hi, I'm on my first rail installation and unfortunately I made the mistake of using Windows 8 CP as my development machine. I would be very great-full if you could detail a bit on how to remove the //U flag to cscript.exe and change the output encoding..

What I did at this point was to follow the discussion here: https://gist.github.com/rails/rails/issues/2880 and pull this: gem 'execjs', :git => 'git://github.com/kennyj/execjs.git', :branch => 'rails_issue_2880' by modifying my Gemfile and then bundle update..

Thanks!

@jediry

This comment has been minimized.

jediry commented May 20, 2012

Sorry it took me so long to reply...I only have the change on my home PC, and I only remembered your message while at work. :-/

The fix I made was to edit lib/execjs/runtimes.rb (under the execjs gem's path...c:\Ruby192\lib\ruby\gems\1.9.1\gems\execjs-1.3.0 on my machine) so that the JScript runtime is defined like so:

JScript = ExternalRuntime.new(
  :name        => "JScript",
  :command     => "cscript //E:jscript //Nologo",
  :runner_path => ExecJS.root + "/support/jscript_runner.js",
  :encoding    => 'UTF-8'
)

If I recall correctly, I think I removed the //U parameter from the :command string, and changed the :encoding string to read "UTF-8" rather than "UTF-16LE".

@leighst

This comment has been minimized.

leighst commented Oct 28, 2012

Same problem. Worked for me. Time to move to Linux for dev.

@pottsk

This comment has been minimized.

pottsk commented Oct 30, 2012

Same issue, same resolution works on Windows 8 RTM. Rails 3.2.6, Ruby 1.9.3, execjs 1.4.0 .
Thanks jediry, couldn't find this solution anywhere else. Everything else just said "install node.js", but I didn't want to install something else when the Windows Script Host is a supported runtime.

Full execjs Runtimes.rb listing: https://github.com/sstephenson/execjs/blob/master/lib/execjs/runtimes.rb

Working runtimes.rb :

JScript = ExternalRuntime.new(
    :name        => "JScript",
    :command     => "cscript //E:jscript //Nologo",
    :runner_path => ExecJS.root + "/support/jscript_runner.js",
    :encoding    => 'UTF-8' # CScript with //U returns UTF-16LE
)

Non-working / Default runtimes.rb :

JScript = ExternalRuntime.new(
    :name        => "JScript",
    :command     => "cscript //E:jscript //Nologo //U",
    :runner_path => ExecJS.root + "/support/jscript_runner.js",
    :encoding    => 'UTF-16LE' # CScript with //U returns UTF-16LE
)

This is the original error page I was seeing:

ExecJS::RuntimeError in Say#hello 

Showing C:/RailsDev/demo1/app/views/layouts/application.html.erb where line #6 raised: 

  (in C:/RailsDev/demo1/app/assets/javascripts/say.js.coffee)


Extracted source (around line #6): 
3: <head>
4:   <title>Demo1</title>
5:   <%= stylesheet_link_tag    "application", :media => "all" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>




Rails.root: C:/RailsDev/demo1

Application Trace | Framework Trace | Full Trace 
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___237228925_44687208'
@jmataya

This comment has been minimized.

jmataya commented Oct 30, 2012

I'm seeing the same thing and I also can get everything working with this fix on Windows 8 RTM, Rails 3.2.8, and Ruby 1.9.3.

I've put together a branch that encompasses this fix: jmataya/execjs@72ddd8edeb1cd9fec2ed976f1f863fde5b551b74. Feel free to use it. I also tested against Windows 7 SP1 successfully.

Once I figure out why a couple test cases are failing (see jmataya/execjs#1), I'll submit a pull request to bring this back in.

To use this in your project Gemfile: gem 'execjs', :git => 'git://github.com/jmataya/execjs.git', :branch => 'issue-81'

@jeremychurch

This comment has been minimized.

jeremychurch commented Nov 5, 2012

Unfortunately that branch didn't work for me, but I did correct the issue by installing nodejs(from http://nodejs.org/) and restarting windows; in case that helps anyone else until the gem is fixed/updated.

@floringogianu

This comment has been minimized.

floringogianu commented Feb 2, 2013

Hi, I believe that 9 months ago when first dabbling with this I eventually made it work with jediry fix; that is using windows script host, but I then switched to linux.

Today, reviewing this issue I installed nodejs and rebooted and it worked this way also. Hope this somehow helps.

Too bad this isn't working out of the box yet with rails installer and execjs and with Windows Script Host.

@lvnilesh

This comment has been minimized.

lvnilesh commented Feb 19, 2013

On Win8 RTM - workaround provided by @pottsk works for me. Thanks.

@letrunghieu

This comment has been minimized.

letrunghieu commented Feb 20, 2013

Yep, the solution of @pottsk work for me (win8 pro 64bit - execjs 1.4.0). Thanks a lot.

@sunnyak247

This comment has been minimized.

sunnyak247 commented May 10, 2013

The solution provided by @pottsk worked for me. I am using a windows 8, 64 bit operating system. Thanks a lot.

@kurevin

This comment has been minimized.

kurevin commented May 28, 2013

Bump still not fixed....but looks like this repo is dead, no commits for over a year.

@jaeezzy

This comment has been minimized.

jaeezzy commented Jul 10, 2013

Hi guys I'm using Surface Pro and when I try to do the simple getting started guide from http://guides.rubyonrails.org/getting_started.html I get below error after I update config/routes.rb and try to load Hello Rails:

screenshot 5

I installed the package using railsinstaller-2.2.1 and then updated rails to version 4 using gem install. Any advise would be greatly appreciated as I haven't been able to run a simple Hello Rails since the last time I did rails in my uni 4-5 years ago :( ... thanks.

@prusswan

This comment has been minimized.

prusswan commented Jul 10, 2013

best advice: don't use Windows for RoR

On Wed, Jul 10, 2013 at 8:23 PM, jaeezzy notifications@github.com wrote:

Hi guys I'm using Surface Pro and when I try to do the simple getting
started guide from http://guides.rubyonrails.org/getting_started.html I
get below error after I update config/routes.rb and try to load Hello Rails:

[image: screenshot 5]https://f.cloud.github.com/assets/323881/774487/f26d584c-e95a-11e2-8746-851e934c61e0.png

I installed the package using railsinstaller-2.2.1 and then updated rails
to version 4 using gem install. Any advise would be greatly appreciated as
I haven't been able to run a simple Hello Rails since the last time I did
rails in my uni 4-5 years ago :( ... thanks.


Reply to this email directly or view it on GitHubhttps://github.com//issues/81#issuecomment-20738254
.

@jaeezzy

This comment has been minimized.

jaeezzy commented Jul 12, 2013

installed node.js and restarted computer and it ran the Hello rails fine..

@sergioschuler

This comment has been minimized.

sergioschuler commented Jul 18, 2013

Works like a charm for me, thanks a mil!

@sergevm

This comment has been minimized.

sergevm commented Aug 24, 2013

Works for me too. Windows 8 Pro.

@spccdt

This comment has been minimized.

spccdt commented Sep 4, 2013

@pottsk's solution worked for me, too. Hugely appreciated.

FWIW, this issue has surfaced in a few posts on StackOverflow. Mentioned the workaround, but will be great to get the solution committed!

@betam4x

This comment has been minimized.

betam4x commented Oct 29, 2013

Rather than closing this issue, don't you think you should make the change listed above to runtimes.rb for windows 8 users?

@janpapenbrock

This comment has been minimized.

janpapenbrock commented Nov 13, 2013

@pottsk's fix worked here as well. Thanks!

@R-Gaurav

This comment has been minimized.

R-Gaurav commented Dec 18, 2013

http://nodejs.org/ this link worked fine for me ( Windows 8)

@RichIsOnRails

This comment has been minimized.

RichIsOnRails commented Dec 28, 2013

And asking Windows Rails users to install node.js just to be able to write Rails apps is overkill.

@aaronluo

This comment has been minimized.

aaronluo commented Feb 20, 2014

Win 7 SP1 + Ruby 2.0.0 + Rails 4.0 the workaround doesn't work for me..... try to install node.js

@VAggrippino

This comment has been minimized.

VAggrippino commented Feb 20, 2014

Thanks to @jediry! This fix / workaround worked for me on Windows 8.1 Pro as well.

C:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\execjs-2.0.2\lib\execjs\runtimes.rb

before:

JScript = ExternalRuntime.new(
  :name        => "JScript",
  :command     => "cscript //E:jscript //Nologo //U",
  :runner_path => ExecJS.root + "/support/jscript_runner.js",
  :encoding    => 'UTF-16LE' # CScript with //U returns UTF-16LE
)

after:

JScript = ExternalRuntime.new(
  :name        => "JScript",
  :command     => "cscript //E:jscript //Nologo",
  :runner_path => ExecJS.root + "/support/jscript_runner.js",
  :encoding    => 'UTF-8' # CScript with //U returns UTF-16LE
)
@belozi

This comment has been minimized.

belozi commented Apr 29, 2014

Change the ExecJS version to 1.2.4

  1. Go to the Gemfile
  2. Type "gem 'execjs', '1.2.4'"
  3. Go to the command line in the application: bundle install
  4. Prosper
@sdkraemer

This comment has been minimized.

sdkraemer commented May 4, 2014

Thanks belozi. That worked!

@myearwood

This comment has been minimized.

myearwood commented Jun 5, 2014

Thanks Belozi, that solution worked for me , when the most poular one did not . Much obliged :) !

@NoICE

This comment has been minimized.

NoICE commented Aug 31, 2014

Installed execjs 1.2.4. It works now, but it does not accept unicode characters in source files. I don't know if that's on purpose (i.e. that I should not have unicode chars in js sources anyway)... but it definitely breaks compatibility with other js platforms.

Converted to use escaped chars (via http://www.percederberg.net/tools/text_converter.html) and it works for now. Thanks.

@josh

This comment has been minimized.

Contributor

josh commented Oct 14, 2014

Finally got it figured out! Its a Powershell feature/bug.

Anyway, as of 35c542a, it always writes the output to a tempfile which bypasses all the shell encoding stuff.

@josh josh closed this Oct 14, 2014

@KatieK2

This comment has been minimized.

KatieK2 commented Oct 17, 2014

For me, this happens on Win7 in the standard command prompt, as well as in Cmder.

@belozi How to do I "go to the Gemfile"? I ran gem 'execjs', '1.2.4' from both C:\Ruby193\lib\ruby\gems\1.9.1\gems and C:\Ruby193\lib\ruby\gems\1.9.1\gems\execjs-2.2.2, but I got an error "Unknown command execjs" each time.

Also, how do I ensure that a given package uses this version of ExecJS?

@belozi

This comment has been minimized.

belozi commented Nov 11, 2014

@KatieK2 It would be a part of your Rails app.

1

PS- sorry I took so long to respond, I didn't realize that this was here. :)

@javadKarbasian

This comment has been minimized.

javadKarbasian commented Mar 23, 2015

it doesn't work for me with version 2.4 execjs...

@geeeeeeeeek

This comment has been minimized.

geeeeeeeeek commented Mar 30, 2015

doesn't work for version 2.4 execjs +1

@rodrigoargumedo

This comment has been minimized.

rodrigoargumedo commented Jun 21, 2015

+1

@DSAMPAT

This comment has been minimized.

DSAMPAT commented Sep 18, 2015

For windows users, this may work. There is a problem with coffee-script-source >1.9.0 running on windows.

It seems you have to add this to your gemfile:

gem 'coffee-script-source', '1.8.0'

then do

bundle update coffee-script-source

@rodrigoargumedo

This comment has been minimized.

rodrigoargumedo commented Sep 18, 2015

Or you could do gem update --system for the latest version of RubyGems and reinstall execjs? I tried this and it worked like a charm.

@DSAMPAT

This comment has been minimized.

DSAMPAT commented Sep 18, 2015

@rodrigoargumedo I tried all the above options, and also mixed up a few combinations of them, till I found this http://stackoverflow.com/questions/28241981/rails-4-execjsprogramerror-in-pageswelcome and had done multiple system gem updates and bundle installs and updates.

I reverted all my trials and downgraded my coffee-script-source and it works. Posting here to help out anyone else, who may have a similar issue.

Updating files in vendor/cache

  • coffee-script-source-1.8.0.gem
    Removing outdated .gem files from vendor/cache
  • coffee-script-source-1.9.1.1.gem
    Bundle updated!
@rodrigoargumedo

This comment has been minimized.

rodrigoargumedo commented Sep 18, 2015

@DSAMPAT I did a fresh reinstall with 2.1.6 and ExecJS works fine as it should expect to behave with a single bundle install. Earlier versions gave the same exact error when ExecJS was incorrectly parsing the wrong thing. Reverting to 1.8.0 works if when working previous versions of Ruby.

@DSAMPAT

This comment has been minimized.

DSAMPAT commented Sep 18, 2015

@rodrigoargumedo Unless we compare bundle show we wont know for sure what other differences we may have as our apps may have other gems or dependencies that could use ExecJS as well.

$ gem -v
2.4.8

$ gem update --system
Latest version currently installed. Aborting.

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [i386-mingw32]

$ rails -v
Rails 4.2.3

Like I said, Posting here to help out anyone else, who may have a similar issue.

@codelearner777

This comment has been minimized.

codelearner777 commented Nov 1, 2015

Hello,

I am having the same problem.
I am new into programming so my needs and the web I build might not influence heavily with this problem. But still, I can not run this line properly.

<%= link_to 'Delete', article_path(article), method: :delete, data: {confirm: 'Are you sure?'} %>

so far, I just delete this line in application.html.erb so I can follow some tutorials.

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

could some one help me?

my setup is on
Win 8.1
image
image

editing jscript.rb does not solve the problem

JScript = ExternalRuntime.new(
:name => "JScript",
:command => "cscript //E:jscript //Nologo",
:runner_path => ExecJS.root + "/support/jscript_runner.js",
:encoding => 'UTF-8' # CScript with //U returns UTF-16LE

@RichIsOnRails

This comment has been minimized.

RichIsOnRails commented Nov 2, 2015

Just install node.js. also see
https://richonrails.com/articles/ruby-2-2-on-windows for more info on
Rails/Windows.
On Nov 1, 2015 12:34 PM, "codelearner777" notifications@github.com wrote:

Hello,

I am having the same problem.
I am new into programming so my needs and the web I build might not
influence heavily with this problem. But still, I can not run this line
properly.

<%= link_to 'Delete', article_path(article), method: :delete, data:
{confirm: 'Are you sure?'} %>

so far, I just delete this line in application.html.erb so I can follow
some tutorials.

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true
%>

could some one help me?

my setup is on
Win 8.1
[image: image]
https://cloud.githubusercontent.com/assets/14092572/10870577/be3df64a-8100-11e5-9312-e75aa2585a95.png
[image: image]
https://cloud.githubusercontent.com/assets/14092572/10870580/d4b635ea-8100-11e5-839b-bf09e74d1e7f.png

editing jscript.rb does not solve the problem

JScript = ExternalRuntime.new(
:name => "JScript",
:command => "cscript //E:jscript //Nologo",
:runner_path => ExecJS.root + "/support/jscript_runner.js",
:encoding => 'UTF-8' # CScript with //U returns UTF-16LE


Reply to this email directly or view it on GitHub
#81 (comment).

@codelearner777

This comment has been minimized.

codelearner777 commented Nov 3, 2015

@RichIsOnRails , yupp...I installed node.JS and it works! Thanks!

@Bassmint123

This comment has been minimized.

Bassmint123 commented Sep 28, 2016

UPDATE: Since Windows 10 with Rails 5.0.0 and Ruby 2.3 has not been mentioned on this thread:

  1. On Win10 I got the same error message as jaeezzy above.
  2. I did the installation of node.js with no other changes and it runs fine.
@RichIsOnRails

This comment has been minimized.

RichIsOnRails commented Sep 28, 2016

@Bassmint123 yes, these days you basically have to install Node.js. There aren't really any easy alternatives unless you use WSL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.