question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: rails-erb-loader failed with code: 1

See original GitHub issue

Running the following: ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/swathishah/shopify-app/bin/spring rails --trace assets:precompile

But I randomly get following error:

ERROR in ./app/javascript/components/layout_tab.js.erb
Module build failed: Error: rails-erb-loader failed with code: 1
    at ChildProcess.<anonymous> (/Users/swathishah/shopify-app/node_modules/rails-erb-loader/index.js:108:16)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:501:12)
 @ ./app/javascript/components/tabs.js 12:0-44
 @ ./app/javascript/packs/notifications_react.jsx

Package.json has following:

{
  "name": "shopify-app",
  "private": true,
  "dependencies": {
    "@rails/webpacker": "^3.2.1",
....
   "rails-erb-loader": "^5.4.1",
...
    "yarn": "^1.3.2"
  },
  "devDependencies": {
    "webpack-dev-server": "^2.11.1"
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:9
  • Comments:81 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
prithvi16commented, Nov 30, 2018

We had a similar problem with erb-loader on CircleCI. Everything worked fine locally but failed to build on CircleCi.

I sshed into CI job and ran

$ cat app/javascript/vendor/javascripts/smart_listing/smart_listing.coffee.erb | bin/rails runner ./node_modules/rails-erb-loader/erb_transformer.rb __RAILS_ERB_LOADER_DELIMETER__ erb

for my .erb file. But it was giving me an error that rake was not found. It was an issue with spring. Disabling spring for the job worked.

So in our case it was DISABLE_SPRING=1 bin/webpack

Link to the spring issue. https://github.com/rails/spring/pull/546

4reactions
dmkecommented, May 29, 2018

I’ve come across this error as well. In my case, the Rails Runner script was invoked with the global Ruby installation, not my local rbenv version. bin/rails has the default shebang (#!/usr/bin/env ruby), which works in my default shell, but obviously not with spawn?

The error message I got was

12% building modules 22/25 modules 3 active $RAILS_ROOT/app/javascript/i18n.js.erb
Ignoring bcrypt-3.1.12 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.12
Ignoring bcrypt_pbkdf-1.0.0 because its extensions are not built.  Try: gem pristine bcrypt_pbkdf --version 1.0.0
Ignoring binding_of_caller-0.8.0 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.8.0
 $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/spec_set.rb:91:in `block in materialize': Could not find nokogiri-1.8.2 in any of the sources (Bundler::GemNotFound)
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/spec_set.rb:85:in `map!'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/spec_set.rb:85:in `materialize'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/definition.rb:171:in `specs'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/definition.rb:238:in `specs_for'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/definition.rb:227:in `requested_specs'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/runtime.rb:108:in `block in definition_method'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/runtime.rb:20:in `setup'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler.rb:107:in `setup'
	from $RBENV_GEMSET_DIR/gems/bundler-1.16.2/lib/bundler/setup.rb:20:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
	from $RAILS_ROOT/config/boot.rb:3:in `<top (required)>'
	from bin/rails:3:in `require_relative'
	from bin/rails:3:in `<main>'

followed by

ERROR in ./app/javascript/i18n.js.erb
Module build failed: Error: rails-erb-loader failed with code: 1
    at ChildProcess.<anonymous> ($RAILS_ROOT/node_modules/rails-erb-loader/index.js:120:16)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)
 @ ./app/javascript/packs/frontend.js 119:0-37
 @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 babel-polyfill ./app/javascript/packs/frontend.js

I’m still running Webpacker 2.0, so I could just modify my config/webpacker/loaders/erb.js:

   options: {
-    runner: 'bin/rails runner',
+    runner: 'bundle exec bin/rails runner',
   },

I don’t know, however, why this became a problem today. When working on the very same project on the same machine last week, the webpack was built without hickups…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails Webpacker : rails-erb-loader failing parsing .html.erb
I created a loader definition html_erb.js module.exports = { test: /\.html.erb$/, loader: [ 'rails-erb-loader', 'html-loader' ] };.
Read more >
SylarRuby - Hotwire Discussion
Uncaught Error: Module build failed (from ./node_modules/rails-erb-loader/index.js): Error: rails-erb-loader failed with code: 1.
Read more >
Error: rails-erb-loader failed with code: 1 - Bountysource
Running the following: ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/swathishah/shopify-app/bin/spring rails ...
Read more >
rails-erb-loader - npm
rails -erb-loader. 5.5.2 • Public • Published 4 years ago. Readme · Code Beta · 2 Dependencies · 3 Dependents · 18 Versions ......
Read more >
ruby-pagy/Lobby - Gitter
node_modules/rails-erb-loader/index.js): Error: rails-erb-loader failed with code: 1. Domizio Demichelis. @ddnexus. ok, so please, debug that first.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found