3

I have a problem configuring my app to user wercker. My wercker.yml looks like this:

box: ruby
services:
  - postgres
build:
    steps:
        - script:
            name: Nokogiri fix
            code: bundle config build.nokogiri --use-system-libraries
        - bundle-install
        - rails-database-yml
        - script:
            name: Set up db
            code: bundle exec rake db:schema:load RAILS_ENV=test
        - script:
            name: rspec
            code: bundle exec rspec

When I run build it fails with the following error:

rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'uglifier'.
/pipeline/source/config/application.rb:7:in `<top (required)>'
/pipeline/source/Rakefile:4:in `require'
/pipeline/source/Rakefile:4:in `<top (required)>'
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs.rb:5:in `<module:ExecJS>'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs.rb:4:in `<top (required)>'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `require'
/pipeline/cache/bundle-install/ruby/2.3.0/gems/uglifier-2.7.2/lib/uglifier.rb:3:in `<top (required)>'
/pipeline/source/config/application.rb:7:in `<top (required)>'
/pipeline/source/Rakefile:4:in `require'
/pipeline/source/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace

I think that I need to install nodejs on wercker but the question is how can I do this?

Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133
  • In your gemfile write: `gem 'therubyracer'` and run `bundle install`. It is written: `ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.` – Deepesh Mar 16 '16 at 15:15
  • There is no other way than adding a gem? – Mateusz Urbański Mar 16 '16 at 15:21
  • 1
    Ruby on Rails requires javascript runtime. Why? This will answer: http://stackoverflow.com/questions/9673081/why-does-rails-require-javascript-runtime – Deepesh Mar 16 '16 at 15:22

1 Answers1

2

As the comments on the question suggest, you need to install a javascript runtime.

You have a few options:

  1. add gem 'therubyracer' to your Gemfile.
  2. Install nodejs via apt-get, brew, etc.

I'd go for option 2 as to not unnecessarily add gems to your project.

yez
  • 2,368
  • 9
  • 15