react-rails icon indicating copy to clipboard operation
react-rails copied to clipboard

./bin/webpack not found due to CWD with rails -d (daemon mode)

Open akomakom opened this issue 6 years ago • 0 comments

Steps to reproduce

  1. Follow react-rails install instructions.
  2. Start in foreground: rails s, confirm that webpack (re)compilation works
  3. Start in background: rails s -d, confirm that webpack (re)compilation fails (output below).

Expected behavior

On-demand compilation should work with rails in daemon mode.

Actual behavior

Processing by NodesController#index as HTML
  ↳ app/controllers/nodes_controller.rb:32
  Rendering nodes/index.html.erb within layouts/application
  Rendered nodes/index.html.erb within layouts/application (66.7ms)
[Webpacker] Compiling…
[Webpacker] Compilation failed:
/home/XXXXXX/.rvm/rubies/ruby-2.4.0/bin/ruby: No such file or directory -- ./bin/webpack (LoadError)

System configuration

OS: CentOS 7.5 Webpacker 3.5.5: React-Rails 2.4.7: Rails version: 5.2.1: Ruby version: 2.4.0: yarn: (RPM) yarn-1.12.3-1.noarch node: (RPM) nodejs-6.14.3-1.el7.x86_64

(Using RVM).


Summary

Webpack on-demand compilation is working fine in my setup as long as I start rails in foreground mode. The moment I add -d, the current working directory for the rails (puma, in my case) process changes to // (as per /proc/####/cwd), and everything in rails still works except webpack.

Troubleshooting

It makes no difference how I start rails, I've tried it via bundle exec, via an rvm wrapper (for both bundle and rails), via sudo or from an interactive shell, via su -u xxx and via sudo -u xxx bash -c rails..., etc.

The moment I enable daemon mode, ./bin/webpack (clearly a relative path) is not found, likely because the current working directory is incorrect.

Manual compilation also works fine from an interactive shell, eg: rails webpacker:compile

akomakom avatar Jan 08 '19 13:01 akomakom