bootstrap-rubygem icon indicating copy to clipboard operation
bootstrap-rubygem copied to clipboard

ExecJS::ProgramError after adding bootstrap gem

Open jasonjoh opened this issue 6 years ago • 18 comments

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:

  1. Run rails new ruby-test

  2. CD to ruby-test, edit Gemfile

  3. Change sqlite3 line to load from GitHub (for Ruby 2.5 on Windows compatibility):

    gem 'sqlite3', git: 'https://github.com/sparklemotion/sqlite3-ruby'
    
  4. Run bundle install

  5. Run rails generate controller Home index

  6. Run rails server

  7. Browse to http://localhost:3000/home/index and verify the page renders

  8. Add bootstrap to Gemfile, bundle install

  9. Rename application.css to application.scss, replace contents of file with:

    // Custom bootstrap variables must be set or imported *before* bootstrap.
    @import "bootstrap";
    
  10. Restart server

  11. Browse to http://localhost:3000/home/index, see error.

jasonjoh avatar Jun 08 '18 21:06 jasonjoh

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.

jasonjoh avatar Jun 08 '18 22:06 jasonjoh

I also get the same error. I wrote the codes as the page below says. https://qiita.com/NaokiIshimura/items/c8db09daefff5c11dadf

yasunari89 avatar Jun 12 '18 11:06 yasunari89

Please keep this issue open. I can confirm I am getting the same error as @jasonjoh above.

tuffs avatar Jun 12 '18 17:06 tuffs

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.

leightjohnson93 avatar Jun 13 '18 14:06 leightjohnson93

When I ran the same code on Mac, it worked well, so this problem maybe is caused by x64-mingw32(maybe sqlite3(x64-mingw32)?).

yasunari89 avatar Jun 15 '18 11:06 yasunari89

I installed node.js in my Win10 and removed 'duktape' from the gemfile. After that this issue is resolved.

yasunari89 avatar Jun 15 '18 14:06 yasunari89

@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.

tuffs avatar Jun 20 '18 19:06 tuffs

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

KapilSachdev avatar Jun 23 '18 14:06 KapilSachdev

The PR is actually rails/execjs#77.

KapilSachdev avatar Jun 23 '18 14:06 KapilSachdev

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.

Hellfar avatar Aug 02 '18 19:08 Hellfar

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 avatar Oct 14 '18 11:10 miguelcarrasco94

@miguelcarrasco94. As long as you have Node.js installed locally everything should work fine.

judofyr avatar Oct 14 '18 11:10 judofyr

Same problem here. But works fine after installing Node in windows 10.

prdpspkt avatar Nov 14 '18 06:11 prdpspkt

Thanks, seem to work for now!

GrayStrider avatar Dec 03 '18 06:12 GrayStrider

@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 avatar Jun 05 '19 11:06 cqcn1991

@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 avatar Jun 10 '19 10:06 KapilSachdev

@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.

cqcn1991 avatar Jun 10 '19 11:06 cqcn1991

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.

dcig avatar Oct 12 '19 19:10 dcig