Git Product home page Git Product logo

execjs's Introduction

ExecJS

ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.

ExecJS supports these runtimes:

A short example:

require "execjs"
ExecJS.eval "'red yellow blue'.split(' ')"
# => ["red", "yellow", "blue"]

A longer example, demonstrating how to invoke the CoffeeScript compiler:

require "execjs"
require "open-uri"
source = open("http://coffeescript.org/extras/coffee-script.js").read

context = ExecJS.compile(source)
context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true)
# => "var square;\nsquare = function(x) {\n  return x * x;\n};"

Installation

$ gem install execjs

FAQ

Why can't I use CommonJS require() inside ExecJS?

ExecJS provides a lowest common denominator interface to any JavaScript runtime. Use ExecJS when it doesn't matter which JavaScript interpreter your code runs in. If you want to access the Node API, you should check another library like commonjs.rb designed to provide a consistent interface.

Why can't I use setTimeout?

For similar reasons as modules, not all runtimes guarantee a full JavaScript event loop. So setTimeout, setInterval and other timers are not defined.

Why can't I use ES5 features?

Some runtimes like Node will implement many of the latest ES5 features. However older stock runtimes like JSC on OSX and JScript on Windows may not. You should only count on ES3 features being available. Prefer feature checking these APIs rather than hard coding support for specific runtimes.

Can ExecJS be used to sandbox scripts?

No, ExecJS shouldn't be used for any security related sandboxing. Since runtimes are automatically detected, each runtime has different sandboxing properties. You shouldn't use ExecJS.eval on any inputs you wouldn't feel comfortable Ruby eval()ing.

License

Copyright (c) 2015 Sam Stephenson and Josh Peek.

Released under the MIT license. See LICENSE for details.

execjs's People

Contributors

cablegram avatar eckz avatar elcuervo avatar emptyflask avatar igoralekseev avatar inukshuk avatar ixti avatar janlelis avatar josh avatar kant avatar lautis avatar luislavena avatar lukefx avatar mislav avatar nwolfwood avatar rubys avatar seronmarlon avatar sferik avatar spraints avatar sstephenson avatar stereobooster avatar swaits avatar tenderlove avatar tricknotes avatar wagenet avatar waynn avatar weppos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

execjs's Issues

Passing an unix-styled temp file path to cscript on Cygwin.

I saw the following message when I tried rails's "getting started."
(http://guides.rubyonrails.org/getting_started.html )

Iconv::InvalidCharacter in Posts#index

Showing /cygdrive/c/samples/ruby_on_rails/blog/app/views/layouts/application.html.erb where line #6 raised:

"\n"
  (in /cygdrive/c/samples/ruby_on_rails/blog/app/assets/javascripts/posts.js.coffee)
Extracted source (around line #6):

3: <head>
4:   <title>Blog</title>
5:   <%= stylesheet_link_tag    "application", :media => "all" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body style="background:#EEEEEE;">

execjs (1.3.0) lib/execjs/external_runtime.rb:192:in `iconv'
execjs (1.3.0) lib/execjs/external_runtime.rb:192:in `sh'
execjs (1.3.0) lib/execjs/external_runtime.rb:146:in `exec_runtime'
execjs (1.3.0) lib/execjs/external_runtime.rb:27:in `send'
execjs (1.3.0) lib/execjs/external_runtime.rb:27:in `exec'
execjs (1.3.0) lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
execjs (1.3.0) lib/execjs/external_runtime.rb:26:in `exec'
execjs (1.3.0) lib/execjs/external_runtime.rb:18:in `eval'
execjs (1.3.0) lib/execjs/external_runtime.rb:32:in `call'
coffee-script (2.2.0) lib/coffee_script.rb:57:in `compile'
...

I ran the following code as a try.

execjstest.rb

require "rubygems"
require "execjs"
p ExecJS.eval "'red yello blue'.split(' ')"
# => ["red", "yello", "blue"]

The result was,

$ ruby execjstest.rb
/usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:192:in `
iconv': "\202\334\202\265\202\275\201B\r\n" (Iconv::IllegalSequence)
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:192:in `sh'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:146:in `exec_runtime'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:27:in `send'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:27:in `exec'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:40:in `compile_to_tempfile'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:26:in `exec'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:18:in `eval'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtim
e.rb:107:in `eval'
        from /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/module.rb:23:in
 `eval'
        from execjstest.rb:3

Tracing this process, the path to a temp file created by execjs and passing to
cscript(JScript) didn't seem to fit for in Windows enviroment.

/usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:209:
      Shellwords.join(args)
(rdb:1) v l
  args => ["cscript", "//E:jscript", "//Nologo", "//U", "/tmp/execjs20120413-199
28-72ltkb-0.js"]

If the path was "c:/cygwin/tmp/execjs20120413-19928-72ltkb-0.js"
not "/tmp/execjs20120413-19928-72ltkb-0.js", it would be like to work.

For changing the path, I added following codes as a try.

external_runtime.rb.patch

*** /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtime.rb.bak2
012-04-13 14:07:25.028800000 +0900
--- /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/external_runtime.rb2012-
04-13 14:11:09.566600000 +0900
***************
*** 24,30 ****
          source = "#{@source}\n#{source}" if @source

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

--- 24,35 ----
          source = "#{@source}\n#{source}" if @source

          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.patch

*** /usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/module.rb       2012-04-13 11:55:54.323600000 +0900
--- module.rb   2012-04-13 11:58:15.922400000 +0900
***************
*** 34,38 ****
--- 34,42 ----
      def windows?
        @windows ||= RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
      end
+
+     def cygwin?
+       @cygwin ||= RbConfig::CONFIG["host_os"] =~ /cygwin/
+     end
    end
  end

After adding the codes, execjstest.rb was executed seemed correctly.

$ ruby execjstest.rb
["red", "yello", "blue"]

My environment is,

$ uname -a
CYGWIN_NT-6.0 my-PC 1.7.13(0.260/5/3) 2012-04-05 12:43 i686 Cygwin

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-cygwin] 

$ gem list

*** LOCAL GEMS ***

actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
arel (3.0.2)
builder (3.0.0)
bundler (1.1.3)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.1)
erubis (2.7.0)
execjs (1.3.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
json (1.6.6)
mail (2.4.4)
mime-types (1.18)
multi_json (1.2.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (0.9.2.2)
rdoc (3.12)
rubygems-update (1.5.2)
sass (3.1.15)
sass-rails (3.2.5)
sprockets (2.1.2)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.4)

Thanks

ExecJs::RuntimeError

ExecJS::RuntimeError in Teachers#index

Showing E:/Ruby_workspace/Others/KhunCool/app/views/layouts/application.html.erb where line #6 raised:

䌧尺坜湩潤獷屜祓瑳浥㈳屜獣牣灩⹴硥履‧獩渠瑯爠捥杯楮敺⁤獡愠湩整湲污漠⁲硥整湲污挠浯慭摮ബ漊数慲汢⁥牰杯慲牯戠瑡档映汩⹥਍
(in E:/Ruby_workspace/Others/KhunCool/app/assets/javascripts/teachers.js.coffee)
Extracted source (around line #6):

3:
4: <title>KhunCool</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8:
9:

This error occurs after I created scaffold Teacher and went to localhost:3000/teachers. what should I do with this problem? I use rails 3.1 and the verison of execjs is 1.2.8 .

ExecJS::RuntimeError: sh: nodejs: Permission denied

With an empty gem set (using rvm and ruby-1.9.3)

gem install execjs

Executing this code

require 'execjs'
ExecJS.eval "'red yellow blue'.split(' ')"

raises

ExecJS::RuntimeError: sh: nodejs: Permission denied

    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/external_runtime.rb:149:in `exec_runtime'
    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/external_runtime.rb:27:in `block in exec'
    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/external_runtime.rb:26:in `exec'
    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/external_runtime.rb:18:in `eval'
    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/external_runtime.rb:107:in `eval'
    from /home/erick/.rvm/gems/ruby-1.9.3-p0@execjs/gems/execjs-1.2.12/lib/execjs/module.rb:23:in `eval'
    from (irb):2
    from /home/erick/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

Result of gem list

*** LOCAL GEMS ***

execjs (1.2.12)
multi_json (1.0.4)

node.js is in the PATH (/usr/local/bin/node), and works

node.js version is 0.6.6

Incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)

I'm encountering the error in the title when attempting to rake assets:precompile in a fresh Rails 3.1.1rc1 installation using JRuby 1.6.4 and a fresh RVM gemset on the default Rails Gemfile. It also occurs with Rails 3.1.0.

The error seems to occur when processing app/assets/javascripts/application.js. The trace leads me to believe that execjs is misbehaving.

I'm not sure if this is an ExecJS problem or a JRuby problem. I've previously reported it to Rails (rails/rails#3078).

A trace follows.

$ bundle exec rake -t assets:precompile -- --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
** Invoke assets:precompile (first_time)
** Execute assets:precompile
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
mkdir -p /Users/cdean/Source/velodash-test/public/assets
rake aborted!
incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)
  (in /Users/cdean/Source/velodash-test/app/assets/javascripts/application.js)
org/jruby/RubyString.java:2853:in `gsub'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/execjs-1.2.7/lib/execjs/external_runtime.rb:72:in `encode_unicode_codepoints'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/execjs-1.2.7/lib/execjs/external_runtime.rb:50:in `compile'
org/jruby/RubyString.java:2585:in `sub!'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/execjs-1.2.7/lib/execjs/external_runtime.rb:49:in `compile'
org/jruby/RubyKernel.java:1803:in `tap'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/execjs-1.2.7/lib/execjs/external_runtime.rb:45:in `compile'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/execjs-1.2.7/lib/execjs/external_runtime.rb:37:in `compile_to_tempfile'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/execjs-1.2.7/lib/execjs/external_runtime.rb:25:in `exec'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/uglifier-1.0.3/lib/uglifier.rb:95:in `compile'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/actionpack-3.1.1.rc1/lib/sprockets/compressors.rb:18:in `compress'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/processing.rb:265:in `js_compressor='
org/jruby/RubyProc.java:262:in `call'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/processor.rb:29:in `evaluate'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/context.rb:175:in `evaluate'
org/jruby/RubyArray.java:1603:in `each'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/context.rb:172:in `evaluate'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/bundled_asset.rb:242:in `build_source'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/caching.rb:26:in `cache_hash'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/bundled_asset.rb:235:in `build_source'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/bundled_asset.rb:71:in `digest'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/asset.rb:95:in `digest_path'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/actionpack-3.1.1.rc1/lib/sprockets/assets.rake:40:in `(root)'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/base.rb:128:in `each_logical_path'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/base.rb:117:in `each_file'
org/jruby/RubyArray.java:1603:in `each'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/base.rb:116:in `each_file'
org/jruby/RubyArray.java:1603:in `each'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/base.rb:115:in `each_file'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/sprockets-2.0.0/lib/sprockets/base.rb:126:in `each_logical_path'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/actionpack-3.1.1.rc1/lib/sprockets/assets.rake:30:in `(root)'
org/jruby/RubyArray.java:1603:in `each'
/Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/actionpack-3.1.1.rc1/lib/sprockets/assets.rake:29:in `(root)'
org/jruby/RubyProc.java:262:in `call'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `execute'
org/jruby/RubyArray.java:1603:in `each'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/Users/cdean/.rvm/rubies/jruby-1.6.4/lib/ruby/1.9/monitor.rb:201:in `mon_synchronize'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
org/jruby/RubyArray.java:1603:in `each'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:62:in `run'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/gems/rake-0.9.2/bin/rake:32:in `(root)'
org/jruby/RubyKernel.java:1073:in `load'
/Users/cdean/.rvm/gems/jruby-1.6.4@global/bin/rake:19:in `(root)'
Tasks: TOP => assets:precompile

No Javascript runtime on windows when running rails server

I'm completely new to Ruby on Rails, and I'm having trouble setting it up on my Windows PC. I have successfully followed the instructions on http://rubyonrails.org/download. However, when I go to run the rails server command I come up with this error result, "Could not find JavaScript runtime." Here is a detailed description of the problem:

http://stackoverflow.com/questions/8047651/no-javascript-runtime-on-windows-when-running-rails-server

I can't seem to find any help on solving this issue. I'd appreciate any help/guidance? Thanks!

'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile

I'm getting this error, like a lot of others:

rake aborted! Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs,

and have already spent more hours searching google then I will admit to. I believe this is an execJs bug, but what do i know? From all the posts, this is a very common issue with rails 3.1. A js runtime is now needed by what are now standard gems like coffee-script and sass.

Most of these cases were resolved by adding the gems 'execjs' and 'therubyracer' to the app Gemfile, and then running 'bundle update' and/or 'bundle install'. But not for me.

I guess I got lucky. I am running rails 3.1.3/ruby 1.9 on an old version of Redhat Linux (Ver 4 (2.6.9-101.ELsmp)). The gcc is 3.4.6.

Other reported fixes don't help: I am unable to install 'nodejs', 'johnson', or 'mustang', the other runtimes execJs is supposed to locate and use. They won't make/install on my system.

So I need to fix the problem causing execJs to fail to locate 'therubyracer'. Has anyone been down this road? Here is the Gemfile (and bundle install says Ok):

source 'http://rubygems.org'

gem 'rails', '3.1.3'
gem 'sqlite3'
gem 'sho-mongrel'

gem 'execjs'
gem 'therubyracer'

gem "therubyracer", :require => 'v8'

group :assets do
gem 'sass-rails', '> 3.1.5'
gem 'coffee-rails', '
> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

And here is a trace:

~/rails/316-private-pub/chatter-after>rake db:create --trace
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in autodetect' /usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:inmodule:ExecJS'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:inrequire'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in block (2 levels) in require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:ineach'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in block in require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:ineach'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:inrequire'
/home/vitalarthur/rails/316-private-pub/chatter-after/config/application.rb:7:in <top (required)>' /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require' /home/vitalarthur/rails/316-private-pub/chatter-after/Rakefile:5:in<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in load' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:inload_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in raw_load_rakefile' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:inblock in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:inload_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in block in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in<top (required)>'
/usr/local/bin/rake:19:in load' /usr/local/bin/rake:19:in

'

There is nothing interesting in the development log.

Here is the execjs dir:

/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs>ls
disabled_runtime.rb module.rb ruby_rhino_runtime.rb version.rb
external_runtime.rb mustang_runtime.rb runtimes.rb
johnson_runtime.rb ruby_racer_runtime.rb

I have also tried execjs-1.2.13. Same problem, I believe.

If I comment execjs.rb below, I can run rake without the error:

require "execjs/module"
require "execjs/runtimes"

module ExecJS
self.runtime #||= Runtimes.autodetect
end

But then I don't get a runtime, do I? Is execJs a runtime itself? No.

I can see where the error text comes from in runtimes.rb:

def self.autodetect
from_environment || best_available ||
raise(RuntimeUnavailable, "Could not find a JavaScript runtime. " +
"See https://github.com/sstephenson/execjs for a list of available runtimes.")
end

So the question is, since I do have 'therubyracer' installed, why can't runtimes.rb find it? Is execJs broken?

Here it 'therubyracer':

/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.9.9

Anyone else had this problem with execJs?

Thanks, your help would be most helpful!

external runtime not in path

Hello,

I'm deploying a Rails 3.1 app to an Ubuntu server that has Nodejs installed to a non standard path. Is there any way to tell ExecJS where to look for binaries (particularly in a Rails 3.1 app)? In my case, the binary is at /usr/local/nodejs/bin.

Thanks.

ExecJS::RuntimeError in Users#index ( 'coffee-rails', '~> 3.1.1' and execjs version is 1.2.12' )

Gemfile

gem 'rails', '3.1.1'

group :assets do
gem 'sass-rails', '> 3.1.4'
gem 'coffee-rails', '
> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

execjs is 1.2.12

============ Error i am getting in console =============

js: "/tmp/execjs20111224-11813-dzulxb.js", line 508: missing } after function body
js: });
js: ..^

(in /home/manoj/Documents/RailsProject/SmartCollege/app/assets/javascripts/course_subjects.js.coffee)):
3:
4: <title>edge</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%#= csrf_meta_tags %>
8:
9:

================== In Browser ==================

ExecJS::RuntimeError in Users#index

js: "/tmp/execjs20111224-12170-kah3u0.js", line 8: missing name after . operator
js: (function(root){var CoffeeScript=function(){function require(a){return require[a]}require["./helpers"]=new function(){var

.
.
.

js: "/tmp/execjs20111224-12170-kah3u0.js", line 508: missing } after function body
js: });
js: ..^

(in /home/manoj/Documents/RailsProject/SmartCollege/app/assets/javascripts/course_subjects.js.coffee)

Trying to use with jshint, won't work - correct usage?

Given the following js file foo.js:

var f = function() {
  if (false)
    alert('foo');
}

I am trying to get to JSHINT errors using execjs, irb session:

irb(main):001:0> require 'execjs'
=> true
irb(main):002:0> context = ExecJS.compile(File.read('jshint.js'))
=> #<ExecJS::ExternalRuntime::Context:0x007fd81a83d4f8 @runtime=#<ExecJS::ExternalRuntime:0x007fd818a18bd0 @name="Node.js (V8)", @command=["nodejs", "node"], @runner_path="/Users/carhartl/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/support/node_runner.js", @test_args=nil, @test_match=nil, @encoding="UTF-8", @binary="node">, @source="...">
irb(main):003:0> context.call('JSHINT', File.read('foo.js'))
=> false
irb(main):004:0> context.exec('return JSHINT.errors;')
=> nil
irb(main):005:0>

Linting the file delivers the expected result false, but I expected to not get nil in the last line, since ultimately what is returned by context.call('JSHINT', File.read('foo.js')) is this:

return JSHINT.errors.length === 0;

Am I missing something?

Error message: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

I have install the node.js and when i use "rails s",it's ok,but when I use passenger+nginx get the following error:

These are the possible causes:
There may be a syntax error in the application's code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
Further information about the error may have been written to the application's log file. Please check it in order to analyse the problem.
Error message:
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
Exception class:
PhusionPassenger::UnknownError
Application root:
/data1/web/itangyi
Backtrace:

File Line Location

0 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/execjs-1.3.0/lib/execjs/runtimes.rb 50 in autodetect' 1 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/execjs-1.3.0/lib/execjs.rb 5 in'
2 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/execjs-1.3.0/lib/execjs.rb 4 in ' 3 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/coffee-script-2.2.0/lib/coffee_script.rb 1 inrequire'
4 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/coffee-script-2.2.0/lib/coffee_script.rb 1 in ' 5 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/coffee-script-2.2.0/lib/coffee-script.rb 1 inrequire'
6 /home/itangyi/.rvm/gems/ruby-1.9.3-p125@rails3_2/gems/coffee-script-2.2.0/lib/coffee-script.rb 1 in `'

somebody know why?

execjs fails to detect therubyrhino

Using jruby 1.9.2 and the gem therubyrhino (with or without :require => 'rhino') is in my Gemfile. Bundle show shows:

execjs (1.2.0)
therubyrhino (1.72.8)
Upon startup of my rails3.1.rc4 app I get:

/home/gucki/.rvm/gems/ruby-1.9.2-p180/gems/execjs-1.2.0/lib/execjs/runtimes.rb:46:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

invalid gemspec for 1.2.4

Installing execjs (1.2.4) Invalid gemspec in [/Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/specifications/execjs-1.2.4.gemspec]: invalid date format in specification: "2011-08-03 00:00:00.000000000Z"
/Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:277:in `block in _resort!': undefined method `name' for nil:NilClass (NoMethodError)
    from /Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:276:in `sort!'
    from /Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:276:in `_resort!'
    from /Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:270:in `_all'
    from /Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:402:in `each'
    from /Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:204:in `include?'
    from /Users/jarod/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:204:in `install'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/bin/bundle:19:in `load'
    from /Users/jarod/.rvm/gems/ruby-1.9.2-p0@trump/bin/bundle:19:in `<main>'

Add EXECJS_PATH_PREFIX ENV option

It would be nice to set an environment variable that adds a path prefix to the search path that ExecJS uses to find the runtime executables. Some people install a JS runtime only for ExecJS and might not want it in their global path. What do you think?

Unclear error messages

I'm not sure if this issue belongs here or to sprockets. same difference?
If you pass some bad command to execjs, in my case it was a simple typo, then the error message is not at all clear and it took me a few minutes to find it:

E.g:

//= req2uire mylib

output:

throw Error("ExecJS::ProgramError: Parse error on line 1: Unexpected '='\n  (in /opt/my.js)")

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

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.

JavaScript runtime

ActionView::Template::Error (Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

I am trying to deploy rails 3.1 to Amazon ec2. It is working fine on development. But on production this error is bothering me.
I read tickets. I put gem install 'therubyracer' .
Still this issue.
Can you please tell me why it is giving me this error. why on production not on development mode on my Mac?
By the way installed also gem execjs. Can it be my virtual server?

Thanks

Could not find a JavaScript runtime

Being aware of the other tickets for this issue, my rails 3.1 app refuses to work with either therubyrhino, therubyracer or mustang. Rake db:migrate keeps giving "Could not find a JavaScript runtime." Any hint greatly appreciated!

Something wrong with sources

I'm on Windows 7. When i running my app, my JS doesn't seems to load, so i look at log file and saw this.

Error compiling asset application.js:
ExecJS::RuntimeError:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '/cygdrive/c/Sites/my_app/C:/Temp/execjs20110710-3628-12kqzkh-0.js'
at Function._resolveFilename (module.js:322:11)
at Function._load (module.js:267:25)
at Array. (module.js:426:10)
at EventEmitter._tickCallback (node.js:126:26)

(in C:/Sites/my_app/app/assets/javascripts/users.js.coffee)
Served asset /application.js - 500 Internal Server Error

C:/Sites/my_app/ - folder where i running my server
C:/Temp - my Windows temp folder

I think something wrong with sources wich sends to runtime.
Can you help to fix it?

nodejs selected, but with incorrect path

i'm running into an odd issue whereby execjs seems to correctly identify that nodejs is available, but then tries to run it from not a full path.

sh: node: not found
/bundle/ruby/1.8/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:150:in `exec_runtime'

this is the result of a rake task run using bundle exec. nodjs was installed from source.

# which node
/usr/local/bin/node

thanks!

Difference in Runtimes behavior

I am having the code, that works with JS context.

In RubyRacer runtime:

ENV['EXECJS_RUNTIME']="RubyRacer"
require 'execjs'
c = ExecJS.compile("var window = {}; window.a = 5; window.b = 2;")
c.eval("window.b = 3")
c.eval("window") #=> {"a"=>5, "b"=>3}

And it looks right.

In case of Node runtime:

ENV['EXECJS_RUNTIME']="Node"
require 'execjs'
c = ExecJS.compile("var window = {}; window.a = 5; window.b = 2;")
c.eval("window.b = 3")
c.eval("window") #=> {"a"=>5, "b"=>2}

The context doesn't change after eval.

Feel like this difference in behavior breaks the idea of ExecJS.

How can I operate on the same JS context eval there multiple times in Node runtime?

execjs doesn't seem to work properly with Spidermonkey

I'm on FreeBSD8-amd64, installed spidermonkey with 'make install' from /usr/ports/lang/spidermonkey.

js -v reports: JavaScript-C 1.7.0 2007-10-03

Here's the output from running test_runtimes.rb:


Runtime Support:
therubyracer (V8) Not found
therubyrhino (Rhino) Not found
Mustang (V8) Not found
Node.js (V8) Not found
JavaScriptCore Not found
✓ Spidermonkey Found
JScript Not found

Loaded suite test_execjs
Started
EEE.EF
Finished in 0.155266 seconds.

  1. Error:
    Spidermonkey:
    ExecJS::ProgramError: ExecJS::ProgramError
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:53:in extract_result' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:19:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:32:in compile_to_tempfile' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:18:inexec'
    test_execjs.rb:38:in `test_compile'

  2. Error:
    Spidermonkey:
    ExecJS::ProgramError: ExecJS::ProgramError
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:53:in extract_result' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:19:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:32:in compile_to_tempfile' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:18:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:13:in eval' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:77:ineval'
    test_execjs.rb:25:in `test_eval'

  3. Error:
    Spidermonkey:
    ExecJS::ProgramError: ExecJS::ProgramError
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:53:in extract_result' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:19:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:32:in compile_to_tempfile' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:18:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:72:in exec' test_execjs.rb:11:intest_exec'

  4. Error:
    Spidermonkey:
    ExecJS::ProgramError: ExecJS::ProgramError
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:53:in extract_result' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:19:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:32:in compile_to_tempfile' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:18:inexec'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:13:in eval' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:77:ineval'
    test_execjs.rb:44:in `test_this_is_global_scope'

  5. Failure:
    Spidermonkey [test_execjs.rb:55]:
    ExecJS::ProgramError exception expected but was
    Class: ExecJS::RuntimeError
    Message: <"/tmp/execjs20110427-55682-vjfq9h-0:17: ReferenceError: JSON is not defined\n">
    ---Backtrace---
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:99:in exec_runtime' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:19:insend'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:19:in exec' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:32:incompile_to_tempfile'
    /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:18:in exec' /home/clee/.rvm/gems/ruby-1.8.7-p334@rails31/gems/execjs-0.3.0/lib/execjs/external_runtime.rb:72:inexec'
    test_execjs.rb:56:in `test_thrown_exception'

test_execjs.rb:55:in `test_thrown_exception'

6 tests, 6 assertions, 1 failures, 4 errors

SpiderMonkey encoding problem with Rails 3.1

I had encoding issues with rake assets:precompile and noticed some strange encoding problems with UTF-8 characters when using ExecJS SpiderMonkey runtime and Rails 3.1.1

How to reproduce:

# $ EXECJS_RUNTIME=SpiderMonkey rails c
require "open-uri"
context = ExecJS.compile(open("http://jashkenas.github.com/coffee-script/extras/coffee-script.js").read)
context.call("CoffeeScript.compile", "ÄÖÄÖåååÖÖÄÅ", {})
# => "\n  \xC4\xD6\xC4\xD6\xE5\xE5\xE5\xD6\xD6\xC4\xC5;\n\n\n" 
context.call("CoffeeScript.compile", "ÄÖÄÖåååÖÖÄÅ", {}).encoding
# => #<Encoding:UTF-8>
context.call("CoffeeScript.compile", "ÄÖÄÖåååÖÖÄÅ", {}).valid_encoding?
# => false
ExecJS.runtime
# => #<ExecJS::ExternalRuntime:0x00000003a0f660 @name="SpiderMonkey", @command="js", @runner_path="/home/asdf/.rvm/gems/ruby-1.9.2-p290@execjs/gems/execjs-1.2.9/lib/execjs/support/spidermonkey_runner.js", @test_args=nil, @test_match=nil, @encoding=nil, @binary="/usr/bin/js", @runner_source="(function(program, execJS) { execJS(program) })(function() { \#{source}\n}, function(program) {\n  \#{json2_source}\n  var output;\n  try {\n    result = program();\n    if (typeof result == 'undefined' && result !== null) {\n      print('[\"ok\"]');\n    } else {\n      try {\n        print(JSON.stringify(['ok', result]));\n      } catch (err) {\n        print('[\"err\"]');\n      }\n    }\n  } catch (err) {\n    print(JSON.stringify(['err', '' + err]));\n  }\n});\n"> 

It's strange, because encoding works well in irb-shell:

# $ EXECJS_RUNTIME=SpiderMonkey irb
require 'execjs'
require 'open-uri'
context = ExecJS.compile(open("http://jashkenas.github.com/coffee-script/extras/coffee-script.js").read)
context.call("CoffeeScript.compile", "ÄÖÄÖåååÖÖÄÅ", {})
# => "\n  ÄÖÄÖåååÖÖÄÅ;\n\n\n"
context.call("CoffeeScript.compile", "ÄÖÄÖåååÖÖÄÅ", {}).valid_encoding?
# => true
ExecJS.runtime
# => #<ExecJS::ExternalRuntime:0x0000000255c5b0 @name="SpiderMonkey", @command="js", @runner_path="/home/asdf/.rvm/gems/ruby-1.9.2-p290@execjs/gems/execjs-1.2.9/lib/execjs/support/spidermonkey_runner.js", @test_args=nil, @test_match=nil, @encoding=nil, @binary="/usr/bin/js", @runner_source="(function(program, execJS) { execJS(program) })(function() { \#{source}\n}, function(program) {\n  \#{json2_source}\n  var output;\n  try {\n    result = program();\n    if (typeof result == 'undefined' && result !== null) {\n      print('[\"ok\"]');\n    } else {\n      try {\n        print(JSON.stringify(['ok', result]));\n      } catch (err) {\n        print('[\"err\"]');\n      }\n    }\n  } catch (err) {\n    print(JSON.stringify(['err', '' + err]));\n  }\n});\n">

Switched to NodeJS runtime and everything works great (in Rails and irb).
OS: Fedora 16
Ruby: 1.9.2-p290
$ locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

Incorrect runtime detection when directory of same name exists

If you have a directory named "nodejs" in your current working directory, then execjs will incorrectly detect it as the nodejs binary, and try to use that as your runtime.

To fix this, ExecJS::ExternalRuntime should check File.file? in addition to File.executable? on the candidate binary.

To reproduce:

  1. Have node.js installed with the binary named "node" (not "nodejs")
  2. Start with a clean gemset or bundle that includes only execjs
  3. At the shell prompt: mkdir nodejs
  4. In irb:
require 'execjs'
ExecJS.eval('1 + 2')

Result:
ExecJS::RuntimeError: sh: nodejs: command not found

linux jsc change breaks when finding .NET jsc

#36 added "jsc" as a way to find the linux version of JavaScriptCore.

Unfortuntately on some windows boxes (with .NET framework/dev tools installed), jsc is installed at c:\windows\Microsoft.NET\framework64\v4.0.xxxxx

so when execjs runs, it favors jsc over JScript - but uses the jsc support script.

I'm not sure what the best way to discern good jscs from bad jscs but its out there.

Javascript Core UTF-8 issue

This test fails on 1.8 and 1.9:

test_eval(JavaScriptCoreTest) [./test/test_runtimes.rb:29]:
<"caf\303\251"> expected but was
<"caf\303\203\302\251">.

test_eval(JavaScriptCoreTest) [test/test_runtimes.rb:29]:
<"café"> expected but was
<"café">.

how should commonJS `require` statements work?

Just curious about what the best approach is for running code that includes commonJS require statements. I haven't found many examples of people leveraging this, with one notable exception (uses therubyracer, but achieves limited require support and the general principle seems sound IMO):

https://github.com/cowboyd/handlebars.rb/blob/master/lib/handlebars/loader.rb#L14

Is there a reason why this isn't implemented? Like, is it a bad idea? Are there technical limitations?

Thanks!

Question: Test assertion

Hello, as you noticed i'm working in the integration with Mustang, some namescope issues where fixed and i'm preparing the commit again, but now i have a question in test/test_runtimes.rb:24 and :10 is this assertion:

assert_nil @runtime.eval("function() {}")

"function() {}" works in most of the runtimes but in V8 raises "SyntaxError: Unexpected token (". This assertion is correct? or should be deleted or tested in the SyntaxtError tests?

Memory leak on MRI

The following code eats up memory until the OOM killer kills Ruby:

require 'execjs'

p ExecJS.runtime
loop do
  1000.times { ExecJS.eval "'red yellow blue'.split(' ')" }
  print '.'
end

Output:

#<ExecJS::RubyRacerRuntime:0x000000029e8b88>
....Killed

I'm using MRI, ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux].

Running therubyracer directly eats up memory too, but at a much much slower rate, well after a million evals.

require 'v8'

cxt = V8::Context.new
loop do
  1000.times { cxt.eval "'red yellow blue'.split(' ')" }
  print '.'
end

testcase is failing on windows with node.exe

I had one problem again.

I had tested execjs with node.exe, and executed "rake test". But tests were not passed.

Loaded suite C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib
/rake/rake_test_loader
Started
.....EEFF......
Finished in 3.840000 seconds.

  1. Error:
    test_encoding(TestExecJS):
    Encoding::InvalidByteSequenceError: "\x83" followed by """ on Windows-31J
    C:/Sites/execjs/lib/execjs/external_runtime.rb:163:in read' C:/Sites/execjs/lib/execjs/external_runtime.rb:163:inblock in sh'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:163:in popen' C:/Sites/execjs/lib/execjs/external_runtime.rb:163:insh'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:123:in exec_runtime' C:/Sites/execjs/lib/execjs/external_runtime.rb:25:inblock in exec'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:38:in compile_to_tempfile' C:/Sites/execjs/lib/execjs/external_runtime.rb:24:inexec'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:17:in eval' C:/Sites/execjs/lib/execjs/external_runtime.rb:105:ineval'
    C:/Sites/execjs/lib/execjs/module.rb:23:in eval' C:/Sites/execjs/test/test_execjs.rb:91:intest_encoding'

  2. Error:
    test_encoding_compile(TestExecJS):
    Encoding::InvalidByteSequenceError: "\x83" followed by """ on Windows-31J
    C:/Sites/execjs/lib/execjs/external_runtime.rb:163:in read' C:/Sites/execjs/lib/execjs/external_runtime.rb:163:inblock in sh'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:163:in popen' C:/Sites/execjs/lib/execjs/external_runtime.rb:163:insh'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:123:in exec_runtime' C:/Sites/execjs/lib/execjs/external_runtime.rb:25:inblock in exec'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:38:in compile_to_tempfile' C:/Sites/execjs/lib/execjs/external_runtime.rb:24:inexec'
    C:/Sites/execjs/lib/execjs/external_runtime.rb:17:in eval' C:/Sites/execjs/test/test_execjs.rb:110:intest_encoding_compile'

  3. Failure:
    test_eval(TestExecJS) [C:/Sites/execjs/test/test_execjs.rb:80]:
    <"caf\u00E9"> expected but was
    <"caf\uFF83\uFF69">.

  4. Failure:
    test_exec(TestExecJS) [C:/Sites/execjs/test/test_execjs.rb:61]:
    <"caf\u00E9"> expected but was
    <"caf\uFF83\uFF69">.

15 tests, 44 assertions, 2 failures, 2 errors, 0 skips

Windows's default encoding is Windows-31J (like Shift_JIS) in Japan.
Therefore, external_encoding is Windows-31J.
I attempt a next code, and fix problem.

Node = ExternalRuntime.new(
  :name        => "Node.js (V8)",
  :command     => ["nodejs", "node"],
  :runner_path => ExecJS.root + "/support/node_runner.js",
  :encoding    => 'UTF-8' # ★
)

I think external_encoding explicitly must be specified.
Same code is work fine on centos-5.6 linux too, thanks.

ExecJS IO.popen call fails in JRuby running in 1.9 mode

ExecJS fails to execute IO.popen(command, options) on line 141 of lib/execjs/external_runtime.rb while running JRuby 1.6.3 running in MRI 1.9.2 mode. It fails with a TypeError: can't convert Hash to String.

The primary cause appears to be JRuby's IO functions not being fully 1.9 compliant—see JRUBY-5532.

The question is, should this be patched as a workaround in ExecJS directly, or forked as a JRuby specific branch until such time as JRuby catches up -- since I'm pretty sure this patch is going to have side effects related to different character encodings for someone, somewhere.

I'll submit a pull request with a proposed patch shortly.

execjs + Ruby 1.8.7 + JSC + coffee + multibyte = BOOM!

execjs fails when trying to compile a CoffeeScript file containing multibyte (UTF-8) chars with JavaScriptCore runtime.

Here's a sample JS file:

% cat hellohello.js.coffee
alert 'こんにちはこんにちは!'

And the stack trace is like this.

Iconv::IllegalSequence ("こんにちは\343"...):
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:146:in `iconv'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:146:in `sh'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:95:in `exec_runtime'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:19:in `send'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:19:in `exec'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:32:in `compile_to_tempfile'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:18:in `exec'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:13:in `eval'
  /Users/a_matsuda/src/git/execjs/lib/execjs/external_runtime.rb:24:in `call'
  coffee-script (2.2.0) lib/coffee_script.rb:57:in `compile'

It seems this commit had introduced the breakage 24a41dfe9dac62e29e5e
and removing this line actually makes everything works fine for me https://github.com/sstephenson/execjs/blob/master/lib/execjs/runtimes.rb#L19

I'm sorry for not attaching a patch, but let me just file the issue, as I can't see the intension of the commit 24a41df

Windows XP: JScript not available on the platform.

I've been having trouble running any kind of thing with ExecJS, even the built-in Windows Script.

I have added an environment variable EXECJS_RUNTIME = "JScript" to the windows environment variables, and this is the error message I get. I commented out all other runtimes (in particular Node; I installed this and this led to all of my problems, and uninstalling it did not do the trick.) However, I am getting this error message. Note that I can run the following command in the command prompt: "cscript //E:jscript //Nologo //U" without a problem. Any idea why this error would be occurring?

[rake --tasks] rake aborted!
JScript runtime is not available on this system
C:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.3.1/lib/execjs/runtimes.rb:64:in from_environment' C:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.3.1/lib/execjs/runtimes.rb:49:inautodetect'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.3.1/lib/execjs.rb:5:in <module:ExecJS>' C:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.3.1/lib/execjs.rb:4:in<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:inblock in require'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:inrequire'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler.rb:119:in require' C:/Users/Jim/RubymineProjects/RubyRailsTest/config/application.rb:7:in<top (required)>'
C:/Users/Jim/RubymineProjects/RubyRailsTest/Rakefile:5:in require' C:/Users/Jim/RubymineProjects/RubyRailsTest/Rakefile:5:in<top (required)>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in load' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:inload_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in raw_load_rakefile' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:inblock in load_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:inload_rakefile'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in block in run' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in run' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in<top (required)>'
C:/Ruby193/bin/rake:23:in load' C:/Ruby193/bin/rake:23:in

'

Compile Error when upgrading to 1.3.1

ActionView::Template::Error (no such file to load -- ["ok","(function() {\n\n $.Isotope.prototype._getCenteredMasonryColumns = function() {\n var colW, cols, parentWidth;\n this.width = this.element.width();\n parentWidth = this.element.parent().width();\n colW = this.options.masonry && this.options.masonry.columnWidth || this.$filteredAtoms.outerWidth(true) || parentWidth;\n cols = Math.floor(parentWidth / colW);\n cols = Math.max(cols, 1);\n this.masonry.cols = cols;\n return this.masonry.columnWidth = colW;\n };\n\n $.Isotope.prototype._masonryReset = function() {\n var i, _results;\n this.masonry = {};\n this._getCenteredMasonryColumns();\n i = this.masonry.cols;\n this.masonry.colYs = [];\n _results = [];\n while (i--) {\n _results.push(this.masonry.colYs.push(0));\n }\n return _results;\n };\n\n $.Isotope.prototype._masonryResizeChanged = function() {\n var prevColCount;\n prevColCount = this.masonry.cols;\n this._getCenteredMasonryColumns();\n return this.masonry.cols !== prevColCount;\n };\n\n $.Isotope.prototype._masonryGetContainerSize = function() {\n var i, unusedCols;\n unusedCols = 0;\n i = this.masonry.cols;\n while (--i) {\n if (this.masonry.colYs[i] !== 0) {\n break;\n }\n unusedCols++;\n }\n return {\n height: Math.max.apply(Math, this.masonry.colYs),\n width: (this.masonry.cols - unusedCols) * this.masonry.columnWidth\n };\n };\n\n}).call(this);\n"]

(in /Users/david/dev/ab/rails/dash/vendor/assets/javascripts/isotope_theme.js.coffee)):
11: = render 'layouts/footer'
12:
13: // javascript
14: = javascript_include_tag :application
15: = yield :on_demand_script
16:
17: // javascript widgets
app/views/layouts/application.html.haml:14:in `_app_views_layouts_application_html_haml___2587078288227510863_70214171044500'

Could not find a JavaScript runtime.

This error is in my rails 3.1 app.
Therubyracer is installed, OS=Freebsd 8.2.
My gemfile contains required gem listed in faq's:

gem 'execjs'
gem 'therubyracer'

Bundle says that I have
execjs (1.2.4)
therubyracer (0.9.4)

All Runtimes maintain context except for ExternalRuntime

Most Runtimes:

ctx = ExecJS.compile("A = 1")
ctx.eval("A = 2")
ctx.eval("A") # => 2

ExternalRuntime:

ctx = ExecJS.compile("A = 1")
ctx.eval("A = 2")
ctx.eval("A") # => 1

Since the goal is the same behavior, either the ExternalRuntime should somehow maintain context or other runtimes should create a new context for each eval/exec operation.

Test failure with execjs 1.2.13 and spidermonkey 1.8.5

I'm getting two test failures with spidermonkey 1.8.5. Tests all pass with nodejs 0.6.6.

  1) Error:
test_eval(TestExecJS):
MultiJson::DecodeError: lexical error: invalid character inside string.
                                 ["ok","�"] 
                     (right here) ------^

    /usr/lib64/ruby/gems/1.8/gems/multi_json-1.0.4/lib/multi_json/engines/yajl.rb:10:in `parse'
    /usr/lib64/ruby/gems/1.8/gems/multi_json-1.0.4/lib/multi_json/engines/yajl.rb:10:in `decode'
    /usr/lib64/ruby/gems/1.8/gems/multi_json-1.0.4/lib/multi_json.rb:76:in `decode'
    ./lib/execjs/external_runtime.rb:61:in `extract_result'
    ./lib/execjs/external_runtime.rb:27:in `exec'
    ./lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
    ./lib/execjs/external_runtime.rb:26:in `exec'
    ./lib/execjs/external_runtime.rb:18:in `eval'
    ./lib/execjs/external_runtime.rb:107:in `eval'
    ./lib/execjs/module.rb:23:in `eval'
    /var/tmp/portage/dev-ruby/execjs-1.2.13/work/all/sstephenson-execjs-7fc7967/test/test_execjs.rb:82:in `test_eval'

  2) Error:
test_exec(TestExecJS):
MultiJson::DecodeError: lexical error: invalid character inside string.
                                 ["ok","�"] 
                     (right here) ------^

    /usr/lib64/ruby/gems/1.8/gems/multi_json-1.0.4/lib/multi_json/engines/yajl.rb:10:in `parse'
    /usr/lib64/ruby/gems/1.8/gems/multi_json-1.0.4/lib/multi_json/engines/yajl.rb:10:in `decode'
    /usr/lib64/ruby/gems/1.8/gems/multi_json-1.0.4/lib/multi_json.rb:76:in `decode'
    ./lib/execjs/external_runtime.rb:61:in `extract_result'
    ./lib/execjs/external_runtime.rb:27:in `exec'
    ./lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
    ./lib/execjs/external_runtime.rb:26:in `exec'
    ./lib/execjs/external_runtime.rb:102:in `exec'
    ./lib/execjs/module.rb:19:in `exec'
    /var/tmp/portage/dev-ruby/execjs-1.2.13/work/all/sstephenson-execjs-7fc7967/test/test_execjs.rb:63:in `test_exec'

ExecJS aborts when node path includes some spaces

Since 0.6.1, NodeJS for Windows installs forcibly "C:\Program Files\nodejs\node.exe" and we cannot customize that path on installer. So that #125 on lib/execjs/external_runtime.rb, this line aborts because of executing "C:\Program"

      def exec_runtime(filename)
        output = sh("#{shell_escape(*(@binary.split(' ') << filename))} 2>&1")
        if $?.success?
          output
        else
          raise RuntimeError, output
        end
      end

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

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)
https://gist.github.com/1228994

And the user's setup/Gemfile.lock is like so:
https://gist.github.com/1229054

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

Add a Changelog

It'd be very helpful to have a Changelog to get a quick snapshot of what changed, whether an upgrade is necessary, and if anything has been deprecated with suitable replacements.

Unicode isn't handled properly in CScript

I wrote this hack, though there may be a better solution:

class ExecJS::ExternalRuntime
  protected
    def exec_runtime(filename)
      output = nil
      # Add //U to force Unicode
      IO.popen("#{@binary} //U #{filename} 2>&1") { |f| output = f.read }
      if $?.success?
        # Windows returns UTF-16LE but we still think it's UTF-8, fix that
        # Should this go before the if?
        output.force_encoding('UTF-16LE').encode('UTF-8')
      else
        raise RuntimeError, output
      end
    end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.