50

Can you comment out lines in a .env file read by foreman?

0

2 Answers 2

94

FWIW, '#' appears to work as a comment character.

It at least has the effect of removing unwanted environment declarations. It might be declaring others starting with a #, but... it still works.

EG

DATABASE_URL=postgres://mgregory:@localhost/mgregory
#DATABASE_URL=mysql://root:secret@localhost:3306/cm_central

results in postgres being used by django when started by foreman with this .env file, which is what I wanted.

0
13

I THINK the app will ONLY look for specific variables inside .env, anything other than the predefined variables (pre-defined in the app files) will be ignored.

So anything you write there that is not used in your application files you can consider a comment. Similarly if you wanna comment out a variable then basically any change you make to the name will "comment it out"; for example, if you change DB_HOST to #DB_HOST then the latter will be ignored because the application is looking for 'DB_HOST' not '#DB_HOST'.

2
  • I guess you are confirming here the way that I guessed the answer I posted earlier works :) Jan 12, 2017 at 3:19
  • 8
    actually, he also claims changing 'DB_HOST' to 'xDB_HOST' or '~DB_HOST' would do the same effect. Nothing special about '#'
    – DonkeyKong
    Oct 10, 2017 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.