Airflow default installation always creates db in user's home even after setting AIRFLOW_HOME


I am setting the AIRFLOW_HOME (as user say testuser)


After executing the following commands -

echo “Installing Apache Airflow …”
which pip3 install -q apache-airflow

echo “Initializing Apache Airflow …”
which python3 which airflow initdb

I still see that it always uses the user’s home (~/testuser/) for the sqllite db, is this expected? Is there a way to have it build at the location of $AIRFLOW_HOME (ie: /usr/share/airflow)?

Output -

Initializing Apache Airflow …
[2019-10-14 05:18:06,997] {} INFO - Using executor SequentialExecutor
DB: sqlite:////testuser/airflow/airflow.db
[2019-10-14 05:18:07,305] {} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.


are you setting the env var so it’s available in whatever code you’re running to init the db? It should put those files in AIRFLOW_HOME. Can you print your env vars right before you issue the airflow initdb command?

My apologies for the delay …

Here is the output after installation and initdb ->

Activating the virtual env …
Killing existing Airflow processes …
Recreating airflow home - /usr/share/airflow
Airflow Home: /usr/share/airflow
Executing -> /var/lib/virtualenvs/myenv/bin/pip3 install -q apache-airflow
Installing Apache Airflow …
Airflow Home: /usr/share/airflow
Executing -> /var/lib/virtualenvs/myenv/bin/python3 /var/lib/virtualenvs/myenv/bin/airflow initdb
Initializing Apache Airflow …
[2019-10-15 19:49:12,315] {} INFO - Using executor SequentialExecutor
DB: sqlite:////root/airflow/airflow.db
[2019-10-15 19:49:12,651] {} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
WARNI [airflow.utils.log.logging_mixin.LoggingMixin] cryptography not found - values will not be stored encrypted.


Hmm, I’m not really sure whats going on there. It should place the file in AIRFLOW_HOME. Only thing I can think of is that env var is missing for the shell running the code. I’d try to print out env cars to confirm they exist and are valid.