I'm trying to get a basic Rails deployment (rails new project-name --webpack) up and running. Everything works, rake webpacker:compile works. However once I add rails-erb-loader (rails webpacker:install:erb) it breaks the compilation process. If webpacker starts compiling, it just freezes at "compiling.." and never ends. This can go on for hours with no result, until I terminate the process. No error messages.
I've tried formatting packs and imported files in different ways, I've tried leaving packs empty, I've tried removing all packs point blank. I've shrunk the problem down to the default, stock Rails deployment, with the default rails-erb-loader installed. Rails works, adding erb loader breaks it.
I have removed all comments from the files in webpacker's folder (since those would be interpreted by ERB). I have also changed file extensions to .js.erb. This was working 3 days ago and I have no idea what I'm doing wrong now.
-- Reproducing
(Enter into bash)
rails new project-name --webpack
cd project-name
rake webpacker:compile (will work)
rails webpacker:install:erb
rake webpacker:compile (will hang)
-- Console output ((--trace will return no output after "compiling.."))
rake webpacker:compile
Compiling…
^C#<Thread:0x00007fffc66119f8@/usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/open3.rb:287 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/open3.rb:287:in `block (2 levels) in capture3'
/usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/open3.rb:287:in `read': stream closed in another thread (IOError)
#<Thread:0x00007fffc66118b8@/usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/open3.rb:288 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/open3.rb:288:in `block (2 levels) in capture3'
/usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/open3.rb:288:in `read': stream closed in another thread (IOError)
rake aborted!
Interrupt:
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/webpacker/compiler.rb:61:in `run_webpack'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/webpacker/compiler.rb:21:in `compile'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/webpacker/commands.rb:18:in `compile'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/webpacker.rb:27:in `compile'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/tasks/webpacker/compile.rake:31:in `block (4 levels) in <main>'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/tasks/webpacker/compile.rake:6:in `ensure_log_goes_to_stdout'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/tasks/webpacker/compile.rake:30:in `block (3 levels) in <main>'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/webpacker.rb:20:in `with_node_env'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/webpacker-4.0.7/lib/tasks/webpacker/compile.rake:29:in `block (2 levels) in <main>'
/home/melvin/.rvm/gems/ruby-2.6.3/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/home/melvin/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
/home/melvin/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => webpacker:compile
(See full trace by running task with --trace)
I also had a problem with erb-loader. Found the solution in this comment. There is some problem with erb-loader and spring interaction which causes the freeze. To fix it, just need to add
env: {
...process.env,
DISABLE_SPRING: 1,
}
to options in erb-loader config(config/webpack/loaders/erb.js), so the entire config looks like this:
module.exports = {
test: /\.erb$/,
enforce: 'pre',
exclude: /node_modules/,
use: [{
loader: 'rails-erb-loader',
options: {
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner',
env: {
...process.env,
DISABLE_SPRING: 1,
},
}
}]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With