execjs: Version 2.8.0 raises ExecJS::ProgramError: TypeError: Cannot read property 'version' of undefined
Hi, I don’t know much about jekyll or ruby or rails or exec-js My project won’t build with version 2.8.0
here’s the traceback :
ExecJS::ProgramError: TypeError: Cannot read property 'version' of undefined
eval (eval at <anonymous> ((execjs):1:213), <anonymous>:1:10)
(execjs):1:213
(execjs):16:14
(execjs):1:40
Object.<anonymous> ((execjs):1:58)
Module._compile (internal/modules/cjs/loader.js:1063:30)
Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
Module.load (internal/modules/cjs/loader.js:928:32)
Function.Module._load (internal/modules/cjs/loader.js:769:14)
Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
/usr/lib64/ruby/gems/2.6.0/gems/execjs-2.8.0/lib/execjs/external_runtime.rb:39:in `exec'
/usr/lib64/ruby/gems/2.6.0/gems/execjs-2.8.0/lib/execjs/external_runtime.rb:21:in `eval'
/usr/lib64/ruby/gems/2.6.0/gems/execjs-2.8.0/lib/execjs/runtime.rb:64:in `eval'
/usr/lib64/ruby/gems/2.6.0/gems/autoprefixer-rails-9.8.6.5/lib/autoprefixer-rails/processor.rb:170:in `runtime'
/usr/lib64/ruby/gems/2.6.0/gems/autoprefixer-rails-9.8.6.5/lib/autoprefixer-rails/processor.rb:53:in `process'
/usr/lib64/ruby/gems/2.6.0/gems/autoprefixer-rails-9.8.6.5/lib/autoprefixer-rails.rb:16:in `process'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-autoprefixer-1.0.2/lib/jekyll/autoprefixer/autoprefixer.rb:27:in `block (2 levels) in process'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-autoprefixer-1.0.2/lib/jekyll/autoprefixer/autoprefixer.rb:23:in `open'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-autoprefixer-1.0.2/lib/jekyll/autoprefixer/autoprefixer.rb:23:in `block in process'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-autoprefixer-1.0.2/lib/jekyll/autoprefixer/autoprefixer.rb:20:in `each'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-autoprefixer-1.0.2/lib/jekyll/autoprefixer/autoprefixer.rb:20:in `process'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-autoprefixer-1.0.2/lib/jekyll-autoprefixer.rb:24:in `block in <top (required)>'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/hooks.rb:103:in `block in trigger'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/hooks.rb:102:in `each'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/hooks.rb:102:in `trigger'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:234:in `write'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/site.rb:82:in `process'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:28:in `process_site'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:65:in `build'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/build.rb:36:in `process'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `each'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
/usr/lib64/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
/usr/lib64/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
/usr/lib64/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
/usr/lib64/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
/usr/lib64/ruby/gems/2.6.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
/usr/lib64/ruby/gems/2.6.0/gems/jekyll-4.2.0/exe/jekyll:15:in `<top (required)>'
/usr/bin/jekyll:9:in `load'
/usr/bin/jekyll:9:in `<top (required)>'
I don’t know if it’s a jekyll issue or an execjs issue, meanwhile we’re rolling back to 2.7.0. Best Regards, SuwakoMmh.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 26
- Comments: 44 (4 by maintainers)
Commits related to this issue
- Downgrade execjs gem due to error in new version See GitHub issue here: https://github.com/rails/execjs/issues/99 — committed to Walls-to-Walls-Cleaning/website by deleted user 3 years ago
- Lock execjs verstion to 2.7.0 until we migrate ruby version to 2.7.0 or execjs issue fix https://github.com/rails/execjs/issues/99 — committed to network-for-good/nfg_onboarder by pawan-kc 3 years ago
- https://github.com/rails/execjs/issues/99 — committed to twsl/jekyll-struggle by twsl 3 years ago
- Downgrade execjs https://github.com/vwochnik/jekyll-autoprefixer/issues/11 https://github.com/rails/execjs/issues/99 — committed to jacobmischka/coyote-grill by jacobmischka 3 years ago
- GBL: v2.4.0 changes Gems: bump to GBL 2.4.0 and lock execjs at 2.7.0 to avoid "TypeError: Cannot read property 'version' of undefined" error. See: https://github.com/rails/execjs/issues/99 SVG: remo... — committed to WIStCart/GeoData by ewlarson 3 years ago
I had rails 5.2 with ruby 2.3.1. To fix this issue I had to downgrade to execjs to 2.7.0. Do the following:
gem 'execjs', '2.7.0'
to your gemfile.bundle update execjs
Then bingo it all worked for me.
I use ruby 3.0.1 on Ubuntu, and execjs 2.8.0 raise errors too.
I am experiencing the same with ExecJS 2.8.0 and Ruby 2.7.3. For me it says
JSON::ParserError: 434
. Had to downgrade to ExecJS 2.7.0 again to fix it.@mrgordon yanking a gem has serious side effects - if you analyse the outcome of the mimemagic yanking it left many people unable to deploy their applications and doing the same here was not necessary as there were no legal consequences of leaving it up. The main Rails gem has only been yanked 5 times and 4 of those were RC versions with security flaws. I only became aware of the issue this morning and we pushed the fix out within an hour of it being merged.
I’m sorry you feel you’ve wasted your time but obviously our intention is that it should’ve been backwards compatible. One of the reasons we eventually went with 2.8 as the version number is that we would’ve had to release a new version of Sprockets as well and we didn’t want to have to force people to upgrade that at the same time.
Again, I’m sorry for the time you spent having to debug this.
This is occurring for me as well on Ruby 2.7.3. Pinning execjs to 2.7.0 fixes the issue.
Not sure if it’s the same issue, but we’re on Ruby 2.7.3 and our CI got errors building assets:
The problem is that autoprefixer tries to detect the node version: https://github.com/ai/autoprefixer-rails/issues/203
A long time ago
process
was removed to ensure all runtimes could be swappable: https://github.com/rails/execjs/commit/b0be19c73ded5f20c2c86c8e546558e09da4e2a5Let’s try to find a solution with autoprefixer, I don’t think this version check is the way to go.
Well I use ruby 2.7.3
Traceback
This is related to using Ruby < 2.7. If you must stay on Ruby 2.6 or earlier, you probably need to stay on
execjs
< 2.8. The other option is to upgrade to Ruby 2.7 or above. Adding this here for posterity and anyone else running into that rough error message 😃Two solutions:
Thank you @pixeltrix and everyone else for fixing this in a matter of hours/days. Much appreciated.
It’s out: https://rubygems.org/gems/execjs/versions/2.8.1
This gem needs to be yanked or fixed ASAP. Like many people in this thread, my coworker and I spent several days digging into why our complicated pull request was suddenly failing only to discover that a minor version upgrade of 2.7.0 to 2.8.0 on this library had been causing the arcane error
vJSON::ParserError: 419: unexpected token at '{"code":"/*!\n * Flat UI Free v2.2.2
during asset compilation. This is really wasting a lot of time for no reason.Ok, so:
autoprefixer
will be fixed in autoprefixer at some point, in the meantime it’s locked to 2.7.0ParseError
is fixed by a6abf130c721ca6ec05cfc7ed79cf2e87a7dcc35I’ll ask for a release, hopefully it should happen soon. In the meantime as many mentioned you can lock to 2.7.0, or use another runtime, e.g. add the
mini_racer
gem.@mrgordon Ouch, several days. I realise it won’t work for every project or for every update, but we update deps daily in our main project precisely so it’s easier to pinpoint regressions like this one. In this case we upgraded 3 gems that day, got CI errors from that commit, noted execjs was the only one that seemed related to assets, rolled it back to confirm, then locked the version down. Maybe 40 minutes all in all.
@byroot Thank you! ❤️
Same here for ruby 3.0.1. Rails precompile assets failed.
No problem, I understand yanking may not have been the right approach. I appreciate your time certainly and I only commented to let people know the extreme downstream effects in hopes that broken code could be removed as quickly as possible in the future. Certainly if you just learned of the issue then you did everything you could. It just felt like after a few days with the issue being open here it was possible that it wasn’t being reverted while it was looked into as there were a number of comments already including some recommending people upgrade their Ruby version (which didn’t even resolve the issue). People saying the solution was to upgrade the Ruby version made it feel like it wasn’t a “minor” change but in retrospect it seems it was just a bug
I’m just not convinced this check is even necessary. It seems to me that it was added to help users figure out why autoprefixer might not work.
I feel like autoprefixer could just not check and add a message to any error that is raised to hint at checking the node version.
You think it would create a bigger mess than people finding a mysterious bug and spending four days looking for it? I somehow doubt it would have taken four days for me to notice that the gem was yanked, maybe 15 seconds. Regardless rolling forward to 2.8.1 was also a fine solution and allows people to use 2.8.0 in the meantime if it works for them (until they run the wrong command and it stops working…). I was trying to provide an immediate solution and it was clear 2.7.0 worked. Its unreasonable to expect bugs to be fixed immediately but if they completely break functionality for many users then at least reverting out the change is usually polite.
Okay he rolled forward with a new release, I hadn’t seen 2.8.1 yet.
I think after 10+ years we could expect the main Rails project to not leave a majorly broken “minor” upgrade in the current release for like 4 days when people are saying its breaking their projects and is hard to even find the problem. You can consider it entitled, but I consider it a basic aspiration for any well-functioning project. I appreciate all the hard work people put into execjs but I also know that small improvements to process can save people thousands of hours.
@mrgordon you may want to look into the
bummr
gem to automate some of this: https://github.com/lpender/bummrThis was a random CI blurp, nothing concerning.
This is not what gem yanking is for. It would have created an even bigger mess, especially since only peopke using the node runtime were affected.
No it wasn’t.
@igorkasyanchuk Please read the discussion above. The issue you point is with autoprefixer, and will be fixed in autoprefixer.
don’t know if my issue should be in a different thread, however I have also been able to pinpoint the failure of version
2.8.0
at building a container based solution in the steprails assets:precompile
as it gives aJSON::ParserError: 434: unexpected token at ...
errorLocking at version
2.7.0
solves the issue.