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 after adding bootstrap gem #157

Open
jasonjoh opened this issue Jun 8, 2018 · 18 comments
Open

ExecJS::ProgramError after adding bootstrap gem #157

jasonjoh opened this issue Jun 8, 2018 · 18 comments

Comments

@jasonjoh
Copy link

jasonjoh commented Jun 8, 2018

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
Copy link
Author

jasonjoh commented Jun 8, 2018

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.

@yasunari89
Copy link

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

@tuffs
Copy link

tuffs commented Jun 12, 2018

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

@leightjohnson93
Copy link

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.

@yasunari89
Copy link

yasunari89 commented Jun 15, 2018

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
Copy link

yasunari89 commented Jun 15, 2018

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

@tuffs
Copy link

tuffs commented Jun 20, 2018

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

@KapilSachdev
Copy link

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
Copy link

The PR is actually rails/execjs#77.

@Hellfar
Copy link

Hellfar commented Aug 2, 2018

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.

@miguelcarrasco94
Copy link

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 ?

@judofyr
Copy link

judofyr commented Oct 14, 2018

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

@prdpspkt
Copy link

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

@GrayStrider
Copy link

Thanks, seem to work for now!

@cqcn1991
Copy link

cqcn1991 commented Jun 5, 2019

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

@KapilSachdev
Copy link

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

@cqcn1991
Copy link

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

@dcig
Copy link

dcig commented Oct 12, 2019

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.

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

No branches or pull requests