react_on_rails: foreman start in dev Unknown switches '-w'

I trying this React on Rails Basic Tutorial. But in the step “foreman start -f Procfile.dev” I got this error:

00:25:16 web.1    | started with pid 27599
00:25:16 client.1 | started with pid 27600
00:25:18 client.1 | ReactOnRails: Set generated_assets_dir to default: public/webpack/development
00:25:18 web.1    | => Booting Puma
00:25:18 web.1    | => Rails 5.1.4 application starting in development
00:25:18 web.1    | => Run `rails server -h` for more startup options
00:25:18 web.1    | ReactOnRails: Set generated_assets_dir to default: public/webpack/development
00:25:18 web.1    | Puma starting in single mode...
00:25:18 web.1    | * Version 3.10.0 (ruby 2.4.2-p198), codename: Russell's Teapot
00:25:18 web.1    | * Min threads: 5, max threads: 5
00:25:18 web.1    | * Environment: development
00:25:18 web.1    | * Listening on tcp://localhost:3000
00:25:18 web.1    | Use Ctrl-C to stop
00:25:18 client.1 | Unknown switches '-w'
00:25:19 client.1 | exited with code 15
00:25:19 system   | sending SIGTERM to all processes
00:25:19 web.1    | - Gracefully stopping, waiting for requests to finish
00:25:19 web.1    | === puma shutdown: 2017-10-14 00:25:19 +0700 ===
00:25:19 web.1    | - Goodbye!
00:25:19 web.1    | Exiting
00:25:19 web.1    | terminated by SIGTERM

I using gem and have Procfile.dev like in the Tutorial: #Gemfile

gem 'react_on_rails', '9.0.0'

#Procfile.dev

web: rails s -p 3000
# Next line runs a watch process with webpack
client: sh -c 'rm -rf public/packs/* || true && bundle exec rake react_on_rails:locale && bin/webpack -w'

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Ok a solution that works without downgrading Bundler is as follows:

rm ./bin/webpack ./bin/webpack-dev-server && bundle binstub webpacker --standalone

This re-generates the binstubs without the 2 extra lines at the start which eat your command line arguments.

I ran into the same issue with latest versions of rails (5.1.4), react_on_rails (10.0.0) and bundler (1.16.0.pre.3). This is related to the way Bundler generates the binstubs.

To get around this problem:

  • Downgrade Bundler to 1.15.4
  • Delete the binstubs bin/webpack and bin/webpack-dev-server
  • Run rails webpacker:install and rails webpacker:install:react commands again (Bundler will generate new working binstubs)
  • Upgrade Bundler back to 1.16.0.pre.3

No more Unknown switches '-w' error message!

Hope this helps.

“For now, the fix is to run bundle binstubs bundler --force” rails/rails#31193

This changes bin/bundler vs the webpack stuff and works for me now both locally and on Heroku