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 · 14 comments

Comments

Projects
None yet
10 participants
@jasonjoh
Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Jun 12, 2018

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

@tuffs

This comment has been minimized.

Copy link

commented Jun 12, 2018

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

@leightjohnson93

This comment has been minimized.

Copy link

commented Jun 13, 2018

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 15, 2018

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

@tuffs

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 23, 2018

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

This comment has been minimized.

Copy link

commented Jun 23, 2018

The PR is actually rails/execjs#77.

@Hellfar

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Oct 14, 2018

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

This comment has been minimized.

Copy link

commented Oct 14, 2018

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

@prdpspkt

This comment has been minimized.

Copy link

commented Nov 14, 2018

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

@GrayStrider

This comment has been minimized.

Copy link

commented Dec 3, 2018

Thanks, seem to work for now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.