Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExecJS::ProgramError in Welcome#index #1

Closed
sylhare opened this issue Jun 1, 2017 · 13 comments
Closed

ExecJS::ProgramError in Welcome#index #1

sylhare opened this issue Jun 1, 2017 · 13 comments
Assignees
Labels

Comments

@sylhare
Copy link
Owner

sylhare commented Jun 1, 2017

Happens on windows following the rails tuto between:

  • 4.2 Say "Hello", Rails
  • 4.3 Setting the Application Home Page

When restarting the server with rails server in the correct folder, I still get this issue ExecJS::ProgramError in Welcome#index when connecting to http://localhost:3000/welcome/index

@sylhare sylhare added the bug label Jun 1, 2017
@sylhare sylhare self-assigned this Jun 1, 2017
@Sd0b
Copy link

Sd0b commented Jul 13, 2017

I changed

blog\app\views\layouts\ application.html.erb

to

blog\app\views\layouts\ default.html.erb

and it's done !!

@sylhare
Copy link
Owner Author

sylhare commented Jul 13, 2017

Yup it seems to work, thanks!

I will list here all the other solutions that was found for this problem (stackOverFlow).

Solution 1 - replacing application by default

Replacing the "application" by "default" in blog\app\views\layouts\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' %>

It should now be working fine. Although I've read that there might be an issue when running javascript while using "default" instead of application.


Solution 2 - changing coffee script's version in the Gemfile

Add in blog/GemFile the coffee-script-source v1.8.0 (v1.9.0 does not work on Windows)

#For Windows it works with CofferScript v1.8
gem 'coffee-script-source', '1.8.0'

Stop the server (if it was running) and do:

bundle update coffee-script-source

It should now be working fine.


Solution 3 - Installing nodeJS and ExecJS (Not tested)

With Node.js

  • Install Node.js
  • Add it to the PATH (ENV_VAR)
  • restart the server
  • Install Execjs: gem install execjs

sylhare added a commit that referenced this issue Jul 16, 2017
Updates on #1
@sylhare sylhare closed this as completed Aug 24, 2017
@najuste
Copy link

najuste commented Sep 25, 2017

I'm sorry to comment the closed topic, but I am not really happy with solution options.
I've just started learning and ran into this... and
Solution 2. - I don't even have this gem installed, and it never came into Error Message
Solution 3. - Didn't work. Error message didn't change
Solution 1. - worked for that application. But do I always have to change that manually? Or could you please explain where / how I'm supposed to change

I'm on Windows 10 with Ruby 2.4.1 , gem 2.6.11, rails 5.1.4

@sylhare
Copy link
Owner Author

sylhare commented Sep 25, 2017

Allo @najuste ,

Thanks for your question, I added here some more details. I don't know if you're following the ruby on rails tutorial, it's a good read ! 😉

For Solution 1

You should find it in C:\blog\app\views\layouts\application.html.erb in your case if you've created the blog using rails new blog from the root of the C disk C:\.

Here it could be clearer, I have the file application.html.erb on this repository.

There you replace application by default in these two lines:

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

However I really do advise to go with solution 2.

For Solution 2

Here the problem is solved when you change in the Gemfile in blog/Gemfile the coffee script version. You should see what I am talking about the Gemfile, the file is in my repository as well.

You will need to stop the server then do a bundle install after doing that. It should then work.

For Solution 3

Argh I didn't try, but I think there's maybe more to it than what I wrote eheh.

@sylhare sylhare reopened this Sep 25, 2017
@najuste
Copy link

najuste commented Sep 26, 2017

Thanks for a quick reply.

Solution 2

I do not have the'coffee-script-source' gem listed in my Gemfile (?), only 'coffee-rails'.
# Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' - and it's the same version as yours.

So, I manually added coffee script source in a Gemfile as given and ran bundle install.
However got the message:
The bundle currently has coffee-script-source locked at 1.12.2. Try running bundle update coffee-script-source

And when I tried to run the server got the same in red asking to update.. and so server was not started.

@sylhare
Copy link
Owner Author

sylhare commented Sep 26, 2017

@najuste
Can you print here a copy of your Gemfile?
I'll check what you have.

@najuste
Copy link

najuste commented Sep 27, 2017

Gemfile

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

@sylhare
Copy link
Owner Author

sylhare commented Sep 28, 2017

Allo,

Try adding that to your gemfile like at line 23:

#For Windows it works with CofferScript v1.8
gem 'coffee-script-source', '1.8.0'

And now it will download and install the right version of coffe script. Tell me how it goes.

@najuste
Copy link

najuste commented Sep 28, 2017

:) I did add, as I've posted before here up, and since server could not be started (requesting to update the coffee-script-source bundle, and also run bundle install...) I have removed it again.
Well, I just read the win message again and tried 'bundle update coffee-script-source` ... and it did the job. 'bundle update' just wasn't working... for that
😫
I just needed to read the message again...
My apologies for the disturbance.

@sylhare
Copy link
Owner Author

sylhare commented Sep 28, 2017

ahah ok, good I'm glad it worked 😉

@sylhare sylhare closed this as completed Sep 28, 2017
@MuriungiPatrick
Copy link

Works perfectly....I've replaced Applications.html.erb with defaults.html.erb
Thanks

@Siwarr
Copy link

Siwarr commented Jun 23, 2019

none ofthese solutions is working for me pls HELP !
Im following this tutorial : https://guides.rubyonrails.org/getting_started.html
when creating the first hello, Rails! page i get this error:
error

@MuriungiPatrick
Copy link

Have you tried this?

  1. Install nodes.js
  2. Install the coffe-script-source gem
    gem 'coffee-script-source', '1.8.0'
  3. Add this line in "config\initializers\assets.rb"
    Rails.application.config.assets.precompile + =% w (application.css)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants