Search code examples
ruby-on-railsruby-on-rails-4asset-pipelineexecjs

Rails: ExecJS::ProgramError, related to assets pipeline


I'm learning Rails by following a tutorial, and I ran into this problem where I want to link to an image with the assistance of assets pipeline like follows

<%= link_to image_tag("rails.png", alt: "Rails logo"), 'http://somewebsite.com' %>

But, when loading the page it shows the following error , ExecJS::Program Error

note that I've deployed my app into Heroku, and it is working just fine !!

Also, I should add that I have experienced the same error before for a different problem and the fix (according to an answer here) was to change the application.html.erb from

 <%= stylesheet_link_tag    'application', media: 'all',
                                          'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

to

 <%= stylesheet_link_tag    'default', media: 'all',
                                          'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'default', 'data-turbolinks-track': 'reload' %>

and again both codes are working just fine with Heroku.

FYI, my machine is running Windows 10..


Solution

  • You need to downgrade your coffee-script gem because coffee-script source >= 1.10.0 does not work well with Windows (coffee-script-source Windows issue)

    • add gem 'coffee-script-source', '1.8.0' to your gemfile
    • do a bundle update from your CLI by running bundle update coffee-script-source

    This worked for me when I was learning back on my Windows PC.