webpacker icon indicating copy to clipboard operation
webpacker copied to clipboard

binstubs should NOT honor the RACK_ENV environment variable in addition to the RAILS_ENV environment variable

Open saltvedt opened this issue 5 years ago • 2 comments

See issue #773 and associated commit: https://github.com/rails/webpacker/commit/f0ce2a5e66f13cd2b562f71ec851f6f18c195121

When this works, it is by accident. The available values of RACK_ENV supported by Rack are development, deployment and none. Of these, only development is a common value of RAILS_ENV.

See: https://github.com/rack/rack/blob/master/lib/rack/server.rb#L180

I found this confusing when debugging an unrelated issue.

saltvedt avatar Oct 18 '21 13:10 saltvedt

This seems reasonable.

@saltvedt would you like to submit a PR on this?

CC: @guillaumebriday

justin808 avatar Nov 28 '21 09:11 justin808

Here's the documentation.

https://github.com/rack/rack/blob/master/lib/rack/server.rb#L184-L190

    # * :environment
    #     this selects the middleware that will be wrapped around
    #     your application. Default options available are:
    #       - development: CommonLogger, ShowExceptions, and Lint
    #       - deployment: CommonLogger
    #       - none: no extra middleware
    def default_options
      environment  = ENV['RACK_ENV'] || 'development'
      default_host = environment == 'development' ? 'localhost' : '0.0.0.0'

justin808 avatar Nov 28 '21 20:11 justin808