ExecJS::ProgramError in Welcome#index - ruby-on-rails

On Ubuntu 16.04 with Ruby 2.3.3, Rails 5.0.0.1, and NodeJS 4.2.6 installed, I generated a toy controller with bin/rails generate controller welcome index. After running bin/rails server, I opened http://localhost:3000/welcome/index in my browser to get the following error:
ExecJS::ProgramError in Welcome#index
Showing /rails-app-path/app/views/layouts/application.html.erb where line #7 raised:
ReferenceError: CoffeeScript is not defined
Extracted source (around line #7):
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

This was answered Here
There is a problem in coffe-script-source gem 1.12.1 which was recently updated. the issue is that the source file in this version is empty. there is already an open issue , and it should be fixed soon.
For now you can add this to your GemFile
gem 'coffee-script-source', '= 1.11.1'
and run bundle update coffee-script-source until it's fixed.

As it turned out, a broken version 1.12.1 of the coffee-script-source gem had been uploaded. That version has now been unpublished, so the above hello world app now works (once I rebundled my gems).

ExecJS::ProgramError in Welcome#index error :
It's an easy fix you just have to rename a file,
app/views/layouts/application.html.erb
TO
app/views/layouts/default.html.erb
And then the magic happens :)

Related

Ruby - Webpacker can't find application in

After installing the device gem, I encountered an error. How can i fix this:
Webpacker can't find application in /home/grkmdgn06/Desktop/my5_homework/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
Extracted source (around line #9):
...
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> # error line
...
perhaps your node.js is out of date
try this:
sudo npm install n -g
sudo n stable
bundle exec rake webpacker:install

ActiveAdmin can't find jquery.ui.datepicker

ActionView::Template::Error (couldn't find file 'jquery.ui.datepicker'
(in /home/raimat/webapps/keita/gems/bundler/gems/active_admin-2ae0a9e09bf9/app/assets/javascripts/active_admin/base.js.coffee:2)):
7: <%= stylesheet_link_tag params[:controller] %>
8: <link rel='stylesheet' href='/assets/typicons.min.css'/>
9:
10: <%= javascript_include_tag "application" %>
11: <%= javascript_include_tag 'ckeditor/ckeditor.js' %>
12:
13:
app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__42414357695359850_50936120'
app/controllers/home_controller.rb:15:in `index'
This only occurs when I try to deploy my app at webfaction (Both Production and development). I've tried it on two different local machines, and it goes as smooth as it should.
Edit: I removed Gemfile.lock on my local machine, and now I get this error there as well.
Tried the solutions found at rails active admin deployment : couldn't find file 'jquery-ui' but I still stand with the bug.
I use Rails 4.0.2
ActiveAdmin at master branch
I need jquery-rails > ~> 3.1.0 for another gem
Tried adding gem jquery-rails-ui, but still nothing..
Ideas?
I was running into the same problem. Noticed there was an upgrade to jquery-ui-rails a couple of days ago (July 3, 2014) so I downgraded to the previous version and that fixed my problems
In gemfile
gem 'jquery-ui-rails', '~> 4.2.1'
In application.js
//= require jquery-ui

rails 4: cannot load such file -- sass

I want to use bootstrap in my project. My operating system is Windows, Ruby version is 1.9.3, Rails version 4.0.4.
I try to bundle one gem every time because there is dependence in some gem when I execute bundle install.
bootstrap-sass (2.3.2.0)
sass (3.3.5, 3.2.19)
sass-rails (4.0.2)
sprockets (2.12.0, 2.11.0)
Now, I add //= require bootstrap into application.js and add #import "bootstrap" into application.css.scss. But when I start server, I got Load Error in *Controller#home:
cannot load such file -- sass (in D:/first_app/app/assets/style sheets / application.css.scss
Extracted source (around line #5):
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
Rails.root: D:/rails_projects/first_app
Any advice?
Did you make sure that you also removed the sprockets //= require directive in your application.css.scss file?
Also, make sure all your gem versions are aligned. According to this rubygems page, version 2.3.2 of boostrap-rails requires version 3.1 for the saas gem. Running bundle install should also notify you of any gem version mismatches in your Gemfile.
Finally, if you're using Rails 4, why are you using an older version of bootstrap-rails? The latest stable version of bootstrap-rails is 3.1.1.0 (as of Feb 13, 2014).

Possible to get Rails 4 working on Windows?

I'm working on a Rails 4 (using the release candidate) project and now need to collaborate with someone on a Windows machine. I can't even get a basic webpage to come up, however :(. It was quite a pain even installing sqlite3 using Ruby 2.0. Now, when I try to get a webpage up (I just created a dummy /home/index controller and view), I get this error:
Showing C:/Users/me/RubymineProjects/test_project/app/views/layouts/application.html.erb where line #6 raised:
(in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/turbolinks-1.1.1/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line #6):
3 <head>
4 <title>TestProject</title>
5 <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6 <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7 <%= csrf_meta_tags %>
8 </head>
9 <body>
Is Rails 4 just not ready for Windows yet? Using Ruby 2.0.0p195.
UPDATE: As per #szines request, here's the webpage output for
http://localhost:3000/rails/info/properties:
Ruby version 2.0.0 (x64-mingw32)
RubyGems version 2.0.3
Rack version 1.5
Rails version 4.0.0.rc1
JavaScript Runtime JScript
Active Record version 4.0.0.rc1
Action Pack version 4.0.0.rc1
Action Mailer version 4.0.0.rc1
Active Support version 4.0.0.rc1
Middleware
ActionDispatch::Static
Rack::Lock
#<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x000000036b85c0>
Rack::Runtime
Rack::MethodOverride
ActionDispatch::RequestId
Rails::Rack::Logger
ActionDispatch::ShowExceptions
ActionDispatch::DebugExceptions
ActionDispatch::RemoteIp
ActionDispatch::Reloader
ActionDispatch::Callbacks
ActiveRecord::Migration::CheckPending
ActiveRecord::ConnectionAdapters::ConnectionManagement
ActiveRecord::QueryCache
ActionDispatch::Cookies
ActionDispatch::Session::CookieStore
ActionDispatch::Flash
ActionDispatch::ParamsParser
Rack::Head
Rack::ConditionalGet
Rack::ETag
Warden::Manager
Application root C:/Users/me/RubymineProjects/test_project
Environment development
Database adapter sqlite3
Database schema version 20130523073322
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
Change this to :
<%= stylesheet_link_tag "defaults", media: "all", "data-turbolinks-track" => true %>
It should work.
It will be great if someone can provide explanation for this.
More info:
ExecJS::RuntimeError in Users#index (RoR)
ExecJS and could not find a JavaScript runtime
Just install node.js and the problem will gone.
Explanation:
If you'll try to precompile assets, you'll get the following trace:
(in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/turbolinks-1.3.0/lib/assets/javascripts/turbolinks.js.coffee)
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:142:in `exec_runtime'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:28:in `block in exec'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:41:in `compile_to_tempfile'
...
As you can see, there is a problem with ExecJS. ExecJS lets you run JavaScript code from Ruby and it requires one of the JS interpreters to be installed on your system. Here's a list of supported interpreters. Usually, you can use therubyracer which is just V8 but there are problems with compiling V8 under the windows. So you can choose another option - NodeJS. ExecJS will use it automatically when you'll install NodeJS and add it to your PATH.
changing following line
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
to
<%= javascript_include_tag "defaults", "data-turbolinks-track" => true %>
works.
OR
you can install node.js
The actual solution for getting Turbolinks to work on Windows 8 x64 is posted at ExecJS::RuntimeError on Windows trying to follow rubytutorial, option 3.
I have been facing this problem for a while and it's that on windows jquery and coffee script are not functional in their latest update and finally i found this wonderful method that worked perfectly without the need to download node or escape //require tree. So all you need is configure the settings in your runtimes.rb which lives in execjs to be like this- you will find this part with few differences fix them and you'll be good to go.
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
You can watch this video for detailed solution.
https://www.youtube.com/watch?v=N5i94L17KPo

ExecJS::RuntimeError on (essentially) empty new project

I just created an empty application and only generated a StaticPages controller with home, help, about, and contact options, but when I access localhost:3000/static_pages/home, I get an error:
ExecJS::RuntimeError in Static_pages#home
Showing [...]views/layouts/application.html.erb where line #6 raised:
(in [...]/app/assets/javascripts/static_pages.js.coffee) Extracted source (around line #6):
3: <head>
4: <title>TodolistApp</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %> 8: </head> 9: <body> Rails.root: [..]
Application Trace | Framework Trace | Full Trace app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__694989846_43803828'
I've looked at a few stackoverflow articles on this same problem, and some recommended installing Node.js, which I have done, but it hasn't done anything. Just to be clear, I have not added any code to any of the static pages views, nor have I added any javascript anywhere.
Also, something interesting is that if I take out line 4 ( <%= javascript_include_tag "application" %>) there is no error. But I assume that if I take this out, the I can't add javascript.
I'd appreciate any help, thanks!
Try to use "gem 'therubyracer'" in your Gemfile, with installed "therubyracer_for_windows"
I did the following (windows 8 64x):
1. Download gem + dll from https://github.com/hiranpeiris/therubyracer_for_windows
2. install this gem (gem instal ...) and move dll-files to "ruby\bin"
3. restart server (rails s, optionally)
4. Then "bundle install" with "gem 'therubyracer'" in my Gemfile works well
Example:
"Using sqlite3 (1.3.7)
Using therubyracer (0.11.0beta1)
Using uglifier (1.3.0)
Using webrat (0.7.1)
Your bundle is complete! Use bundle show [gemname] to see where a bundled gem
is installed."
Add this to your gemfile
gem 'therubyracer', :platform => :ruby
gem 'execjs'
Try this,it might works for you. I got somewhat similar error,i resolved using this.

Resources