webpacker
webpacker copied to clipboard
rake aborted NoMethodError: undefined method 'environment'
In a Rails 4.2.10 app on Ruby 2.3.1 when I add the webpacker gem v3.2 and run bundle exec rake webpacker:install I get the following error at the end of the rake task:
Installing binstubs
run bundle binstubs webpacker from "."
Adding configurations
rake aborted!
NoMethodError: undefined method 'environment' for #<Rails::Generators::AppGenerator:0x007fe4586d4608>
/Users/fredguest/.rvm/gems/ruby-2.3.1@my_app/gems/webpacker-3.2.0/lib/install/template.rb:20:in `apply'
/Users/fredguest/.rvm/gems/ruby-2.3.1@my_app/gems/thor-0.20.0/lib/thor/actions.rb:225:in 'instance_eval'
/Users/fredguest/.rvm/gems/ruby-2.3.1@my_app/gems/thor-0.20.0/lib/thor/actions.rb:225:in 'apply'
/Users/fredguest/.rvm/gems/ruby-2.3.1@my_app/gems/railties-4.2.10/lib/rails/tasks/framework.rake:13:in 'block (2 levels) in <top (required)>'
Tasks: TOP => rails:template
(See full trace by running task with --trace)
So it's pointing to this line https://github.com/rails/webpacker/blob/master/lib/install/template.rb#L20
I am also having this issue:
Copying webpack core config
exist config/webpack
identical config/webpack/development.js
identical config/webpack/environment.js
identical config/webpack/production.js
identical config/webpack/test.js
Copying .postcssrc.yml to app root directory
identical .postcssrc.yml
Copying .babelrc to app root directory
identical .babelrc
Creating JavaScript app source directory
exist app/javascript
identical app/javascript/packs/application.js
Installing binstubs
run bundle binstubs webpacker from "."
Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.
Adding configurations
rake aborted!
NoMethodError: undefined method `environment' for #<Rails::Generators::AppGenerator:0x007fd58ba722c8>
/Users/pwgustafson/.rvm/gems/ruby-2.2.2@cloud_mlx/gems/webpacker-3.2.0/lib/install/template.rb:20:in `apply'
/Users/pwgustafson/.rvm/gems/ruby-2.2.2@cloud_mlx/gems/thor-0.20.0/lib/thor/actions.rb:225:in `instance_eval'
/Users/pwgustafson/.rvm/gems/ruby-2.2.2@cloud_mlx/gems/thor-0.20.0/lib/thor/actions.rb:225:in `apply'
/Users/pwgustafson/.rvm/gems/ruby-2.2.2@cloud_mlx/gems/railties-4.2.10/lib/rails/tasks/framework.rake:13:in `block (2 levels) in <top (required)>'
Tasks: TOP => rails:template
Confirmed, we should use inject_into_file instead to support Rails 4.2