Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should "rails new --webpack=..." stop when bin/yarn fails? #103

Closed
marcusmolchany opened this issue Feb 22, 2017 · 4 comments
Closed

Should "rails new --webpack=..." stop when bin/yarn fails? #103

marcusmolchany opened this issue Feb 22, 2017 · 4 comments

Comments

@marcusmolchany
Copy link

Locally I was running node version 5.0.0 which caused an error during the yarn install step of rails new.

loader-runner (a sub-dependency of webpack) failed because of its engines requirement in package.json. This prevented ./bin/webpack-watcher from running because it was not installed in the node_modules folder.

My question is should the rails new --wepback=... command fail if there is an issue during the yarn install? After rails new ran and completed, with errors further up in the logs, it took some time to trace back why ./bin/webpacker-watcher was not running.


Below is the full output of my rails new commands (omitted large output for brevity using [...]). The current working directory of the command is the root directory of cloning rails/rails from github. The error occurs in the logs after run ./bin/yarn add --dev webpack webpack-merge webpack-dev-server path-complete-extname babel-loader babel-core babel-preset-latest coffee-loader coffee-script rails-erb-loader glob from "."

$ ./rails/railties/exe/rails new my5oneapp --edge --webpack=react
      create  
      create  README.md
      create  Rakefile
      [...]
      create  vendor/.keep
      create  package.json
      remove  config/initializers/cors.rb
         run  bundle install
Fetching https://github.com/rails/rails.git
[...]
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 12.0.0
Using concurrent-ruby 1.0.4
[...]
Using webpacker 0.2 from https://github.com/rails/webpacker.git (at master@35586c7)
Using rails 5.1.0.alpha from https://github.com/rails/rails.git (at master@ecca24e)
Using sass-rails 6.0.0.beta1 from https://github.com/rails/sass-rails.git (at master@dfbcc6a)
Bundle complete! 17 Gemfile dependencies, 70 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
       rails  webpacker:install
      create  app/javascript
      create  app/javascript/packs/application.js
       exist  bin
      create  bin/webpack-dev-server
      create  bin/webpack-watcher
      create  bin/webpack
    conflict  bin/yarn
Overwrite /Users/mmolchany/development/my5oneapp/bin/yarn? (enter "h" for help) [Ynaqdh] 
       force  bin/yarn
      create  config/webpack
      create  config/webpack/development.js
      create  config/webpack/production.js
      create  config/webpack/shared.js
      append  .gitignore
         run  ./bin/yarn add --dev webpack webpack-merge webpack-dev-server path-complete-extname babel-loader babel-core babel-preset-latest coffee-loader coffee-script rails-erb-loader glob from "."
yarn add v0.19.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error loader-runner@2.3.0: The engine "node" is incompatible with this module. Expected version ">=4.3.0 <5.0.0 || >=5.10".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
       rails  webpacker:install:react
Replacing loader presets to include react in /Users/mmolchany/development/my5oneapp/config/webpack/shared.js
Replacing loader test to include react in /Users/mmolchany/development/my5oneapp/config/webpack/shared.js
Copying react example to app/javascript/packs/hello_react.js
yarn add v0.19.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 17 new dependencies.
@rafaelfranca
Copy link
Member

Yes, it should fail.

@paulsturgess
Copy link

For what it's worth I just hit this with Rails 5.1.0.beta1.

The rails new myapp --webpack=react command looked like it had completed with no issues. It was only when I ran the webpack watcher that I realised something wasn't right:

$ ./bin/webpack-watcher
sh: ./node_modules/webpack/bin/webpack.js: No such file or directory

Looking back in amongst the output of rails new:

error webpack-dev-server@2.4.1: The engine "node" is incompatible with this module. Expected version ">=4.7".
error Found incompatible module

So I updated Node (which involved uninstalling and re-installing), deleted the app files and re-ran rails new myapp --webpack=react. The rails application was generated again but this time in amongst the output I saw:

Yarn executable was not detected in the system

Presumably this is another dependency that should cause the generation to fail.

I installed yarn via: npm install -g yarn, deleted the app files again and re-ran rails new myapp --webpack=react and everything was good 👍

@dhh
Copy link
Member

dhh commented Feb 25, 2017 via email

@gauravtiwari
Copy link
Member

I think we fixed this on webpacker side recently with #222. Now need to add the same checks in app_base installer in rails when --webpack option is supplied. I will open a new PR on rails repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants