Coder Social home page Coder Social logo

Possible conflict with Foreman about dotenv HOT 5 CLOSED

bkeepers avatar bkeepers commented on July 22, 2024
Possible conflict with Foreman

from dotenv.

Comments (5)

bkeepers avatar bkeepers commented on July 22, 2024

Foreman uses dotenv. Can you give more information on your two environments and how they're being loaded?

from dotenv.

obromios avatar obromios commented on July 22, 2024

The two environments are running as a Virtualbox Ubuntu 12.04 guest on a windows machine. Both are running Rails 3.2.12. The .env file is in the root. If I do bundle, then I see the following entries for dotenv

Using dotenv (0.9.0) 
Using dotenv-rails (0.9.0) 

Please let me know if you need any more information about how it is loaded.

One clue might be the .env file that is on the system that is not working looks as follows:

RACK_ENV=development
TEMP_ME="here"

When I load up the system, I can run console and if I type ENV["RACK_ENV], it returns "development" but if I type ENV["TEMP_ME"] it returns nil. If I edit the .env file to change the RACK_ENV variable to something else and then run rails console, the value of RACK_ENV does not change, so it looks like it is being loaded up somewhere else. However, if I search through all my project files, I can not see anywhere obvious that this is happening.

Chris

from dotenv.

obromios avatar obromios commented on July 22, 2024

As well, the contents of my Procfile is:

web: bundle exec rails server thin -p $PORT -e $RACK_ENV

from dotenv.

bkeepers avatar bkeepers commented on July 22, 2024

Setting RACK_ENV or RAILS_ENV in .env is a chicken-egg problem. By the time .env is loaded in your rails app script/rails console, the environment has already been chosen. It works through foreman because it pre-loads .env before bootstrapping your app.

I would strongly recommend setting RACK_ENV in /etc/environment on your server.

from dotenv.

obromios avatar obromios commented on July 22, 2024

Thank you

from dotenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.