bootstrap-rubygem
bootstrap-rubygem copied to clipboard
ExecJS::ProgramError after adding bootstrap gem
After adding the bootstrap gem to my brand new Rails app and importing it in application.scss, my pages fail with
ExecJS::ProgramError in Home#index
Showing C:/Source/Repos/graph-tutorials/ruby-test/app/views/layouts/application.html.erb where line #8 raised:
identifier '(function(opts, pluginOpts) {return eval(process' undefined
Rails.root: C:/Source/Repos/graph-tutorials/ruby-test
- Ruby 2.5.1
- Rails 5.2.0
- Windows 10
Steps to reproduce:
-
Run
rails new ruby-test
-
CD to
ruby-test
, edit Gemfile -
Change
sqlite3
line to load from GitHub (for Ruby 2.5 on Windows compatibility):gem 'sqlite3', git: 'https://github.com/sparklemotion/sqlite3-ruby'
-
Run
bundle install
-
Run
rails generate controller Home index
-
Run
rails server
-
Browse to http://localhost:3000/home/index and verify the page renders
-
Add bootstrap to Gemfile, bundle install
-
Rename
application.css
toapplication.scss
, replace contents of file with:// Custom bootstrap variables must be set or imported *before* bootstrap. @import "bootstrap";
-
Restart server
-
Browse to http://localhost:3000/home/index, see error.
I should point out that in my steps above I didn't install jquery-rails
as it says in the README. I left that out to eliminate it as the cause. I still get the error even with that gem installed and application.js updated per the README.
I also get the same error. I wrote the codes as the page below says. https://qiita.com/NaokiIshimura/items/c8db09daefff5c11dadf
Please keep this issue open. I can confirm I am getting the same error as @jasonjoh above.
I removed 'duktape' from the gemfile and it seems to have resolved the issue. At least for the one page I was trying to load.
When I ran the same code on Mac, it worked well, so this problem maybe is caused by x64-mingw32(maybe sqlite3(x64-mingw32)?).
I installed node.js in my Win10 and removed 'duktape' from the gemfile. After that this issue is resolved.
@yasunari89 I can say this is not an issue with sqlite3 as I explicitly use Postgres for everything I do.
@leightjohnson93 will try this tonight and see where things go.
duktape
has become the default JS Runtime in Windows sometime ago in rails/rails#30014.
If you look into other similar issues involving Exejs you might found out that duktape
is actually the culprit (however its execjs
here for definition of duktape
context).
If you change your runtime environment to use Nodejs, the error would be resolved, as the case with @yasunari89
# In `config/boot.rb`
ENV['EXECJS_RUNTIME'] = 'Node'
You can find more info in #152 , #153 and #155 .
However, above issues with invalid regex was fixed with new version of duktape
, for more info visit judofyr/duktape.rb#41
The new version which resolved the invalid regex
issue , started causing issue which you are encountering now.
This issue happens because ( as defined in execjs
) duktape
doesn't support complex contexts and full JS as identifier
.
However a PR is under review that will possibly resolve the issue, thanks to @judofyr
The PR is actually rails/execjs#77.
I am having the same issue here on linux.
- Ruby 2.3.1p112
- Rails 5.2.0
- Linux
Steps to reproduce: You do not need step 3 and 9 from those you presented in order to reproduce the error.
Also I tried gem 'bootstrap', '~> 4.0.0'
(a version that worked for me before) and gem 'bootstrap', '~> 4.1.3'
and having the same issue with rails 5.2.
I removed 'duktape' from the gemfile and it seems to have resolved the issue. At least for the one page I was trying to load.
I have a question... but iof youi remove this gem, what will be its possible consequence ?
@miguelcarrasco94. As long as you have Node.js installed locally everything should work fine.
Same problem here. But works fine after installing Node in windows 10.
Thanks, seem to work for now!
@KapilSachdev Thanks for your notes. I want to know if this problem is solved right now? because I'm still getting the error while the PR you mentioned is merged. (And I solved by installing NodeJS and remove duktape
from gemfile)
@cqcn1991 I too can confirm the issue is still persisting, even though the PR is merged. Are you getting the same error as reported?
ActionView::Template::Error (identifier '(function(opts, pluginOpts) {return eval(process' undefined):
What is the version of execjs you are using?
Can you also provide the definition of the method call(identifier, *args)
from your local system which you may find in file duktape_runtime.rb
(something like C:\Ruby25-x64\lib\ruby\gems\2.5.0\gems\execjs-2.7.0\lib\execjs\duktape_runtime.rb
)
@KapilSachdev I just get away with it by your approach, commenting out duktape
and installed node js instead. And now my code can run locally in Windows and Heroku.
Figured it was worth mentioning. I'm running Ruby 2.5.5, Rails 5.2.3, Win10. Node.js was already installed on my machine, ran into identifier '(function(opts, pluginOpts) {return eval(process' undefined
Error message when navigating to home page through local.
This was occurring after I installed gem 'materialize-sass', '~> 1.0.0'
& gem 'material_icons'
I commented out duktape
, then bundle install
, restarted server and all is well again.
Note: I did install gem 'coffee-script-source', '1.8.0'
prior to removing duktape
, not sure if that may have affected anything.