Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4829

Clarify RAILS_ENV, MONGOID_ENV must be set in ENV

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 8.0.1
    • Affects Version/s: 7.0.5
    • Component/s: Dev Exp
    • Fully Compatible

      When Mongoid cannot determine the environment to use, it raises the following exception:

      /home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mongoid-7.0.5/lib/mongoid/config/environment.rb:24:in `env_name':  (Mongoid::Errors::NoEnvironment)
      message:
        Could not load the configuration since no environment was defined.
      summary:
        Mongoid attempted to find the appropriate environment but no Rails.env, Sinatra::Base.environment, RACK_ENV, or MONGOID_ENV could be found.
      resolution:
        Make sure some environment is set from the mentioned options. Mongoid cannot load configuration from the yaml without knowing which environment it is in, and we have considered defaulting to development an undesireable side effect of this not being defined.
      

      In this message, Rails.env and Sinatra::Base are valid Ruby code, but RACK_ENV and MONGOID_ENV are not - the latter are not recognized as constants but only as keys in ENV.

      The exception message should explicitly state that the latter two references are to ENV keys.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: