Hi,
I'm using webpacker 3.5.5, rails 5.2.0, and ruby 2.3.5 and when running RAILS_ENV=staging bundle exec rake assets:precompile I'm getting the following error:
RAILS_ENV=staging environment is not defined in config/webpacker.yml, falling back to production environment
NoMethodError: undefined method `inquiry' for "production":String
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/webpacker-3.5.5/lib/webpacker/env.rb:16:in `inquire'
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/webpacker-3.5.5/lib/webpacker/env.rb:7:in `inquire'
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/webpacker-3.5.5/lib/webpacker/instance.rb:11:in `env'
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/webpacker-3.5.5/lib/webpacker/instance.rb:18:in `config'
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/webpacker-3.5.5/lib/webpacker.rb:25:in `config'
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/webpacker-3.5.5/lib/tasks/webpacker/verify_install.rake:6:in `block (2 levels) in <top (required)>'
/var/www/.libs/customer/.bundle/2.3.5/1/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/cli.rb:18:in `start'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/exe/bundle:30:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
/usr/local/rvm/gems/ruby-2.3.5/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.5/bin/bundle:23:in `load'
/usr/local/rvm/gems/ruby-2.3.5/bin/bundle:23:in `<main>'
Tasks: TOP => assets:precompile => webpacker:compile => webpacker:verify_install
(See full trace by running task with --trace)
I was able to fix it by adding a staging section in my webpacker.yml. Also, using an older of webpacker (v3.2.2) also seems to fix it.
@cswilliams Could you please double check both node and ruby versions are same i.e. 3.5.5? Can't seem to reproduce this issue on my end.

I played around with it some more. Looks like the underlying issue was we had commented out require "sprockets/railtie" in the config/application.rb
When I added it back, then everything worked. Is that intentional? If so, I'll close the issue.
Ahh right, that's strange because it should work without it: https://github.com/rails/webpacker/blob/master/lib/tasks/webpacker/compile.rake#L42
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "active_storage/engine"
require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
just tested this in a Rails 5.2. app:

here's the frameworks that I originally had that causes the error for me:
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_cable/engine"
#require "sprockets/railtie"
# require "rails/test_unit/railtie"
looks like requiring this also fixes it:
require "active_support/core_ext/string/inquiry"
I see, looks like one of the rails modules requires this already so no error in my case. Perhaps, it makes sense to import this extension since we explicitly use it in the gem. Happy to make a PR?
Perhaps somewhere here: https://github.com/rails/webpacker/blob/master/lib/webpacker.rb#L1
Thanks so much for the help @gauravtiwari!
No problem! Thanks for the PR, it's on master/3-x-stable branch but will make a release later.
Most helpful comment
looks like requiring this also fixes it:
require "active_support/core_ext/string/inquiry"