Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a comment character for foreman's .env file?

Tags:

foreman

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

like image 283
GreenAsJade Avatar asked Nov 03 '14 11:11

GreenAsJade


People also ask

Can you put comments in a .env file?

You can add a comment in . env by starting a line with a hash (#) symbol. E.g. Lines started from # detected as comments.

How do I comment multiple lines in a .env file?

As you said, the only way to comment is at line level with the # character. A workaround would be looking for a shortcut in your IDE to employ multi-line editing (e.g. use Shift + Alt + Arrow Keys on Visual Studio Code in Linux).

What should .env files contain?

env file should be particular to the environment and not checked into version control. This. env. example file documents the application's necessary variables and can be committed to version control.


2 Answers

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.

like image 166
GreenAsJade Avatar answered Sep 22 '22 15:09

GreenAsJade


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'.

like image 34
MCH Avatar answered Sep 22 '22 15:09

MCH