Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get .env.local to work #175

Open
armouredking opened this issue Jan 16, 2025 · 7 comments
Open

Can't get .env.local to work #175

armouredking opened this issue Jan 16, 2025 · 7 comments

Comments

@armouredking
Copy link

Not sure what I'm doing wrong. If I use .env, it works fine. .env.local with same permissions in the same directory does not.

Both .env and .env.local file exists:

> bin/console doctrine:migrations:migrate
<TIMESTAMP> CRITICAL bla bla can't connect to database

Seems like it is reading the default .env file which is not configured. Rename .env to .env.dist to force read

> bin/console doctrine:migrations:migrate
PHP Fatal error:  Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/path/to/davis/.env" environment file. in /path/to/davis/vendor/symfony/dotenv/Dotenv.php:553
Stack trace:
#0 /path/to/davis/vendor/symfony/dotenv/Dotenv.php(106): Symfony\Component\Dotenv\Dotenv->doLoad()
#1 /path/to/davis/vendor/symfony/dotenv/Dotenv.php(149): Symfony\Component\Dotenv\Dotenv->loadEnv()
#2 /path/to/davis/bin/console(36): Symfony\Component\Dotenv\Dotenv->bootEnv()
#3 {main}
  thrown in /path/to/davis/vendor/symfony/dotenv/Dotenv.php on line 553

Rename .env.local to .env

 WARNING! You are about to execute a migration in database "davis" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
@tchapi
Copy link
Owner

tchapi commented Jan 16, 2025

It's weird, it works well in my case (and it's the common Symfony way of doing it). Can you share what ls -la gives in that folder with your .env.local file in it?

@armouredking
Copy link
Author

drwxr-xr-x 16 abc abc     28 Jan 16 10:57 .
drwxr-xr-x  3 abc abc      3 Jan 16 09:33 ..
-rw-r--r--  1 abc abc    165 Jan 16 09:33 .dockerignore
-rw-r--r--  1 abc abc   3530 Jan 16 09:33 .env
-rw-r--r--  1 abc abc    729 Jan 16 10:51 .env.local
-rw-r--r--  1 abc abc    406 Jan 16 09:33 .env.test
drwxr-xr-x  8 abc abc     13 Jan 16 09:33 .git
drwxr-xr-x  3 abc abc      4 Jan 16 09:33 .github
-rw-r--r--  1 abc abc    411 Jan 16 09:33 .gitignore
-rw-r--r--  1 abc abc    769 Jan 16 09:33 .php-cs-fixer.php
-rw-r--r--  1 abc abc   1062 Jan 16 09:33 LICENSE
-rw-r--r--  1 abc abc  19167 Jan 16 09:33 README.md
drwxr-xr-x  2 abc abc     10 Jan 16 09:33 _screenshots
drwxr-xr-x  2 abc abc      4 Jan 16 09:33 bin
-rw-r--r--  1 abc abc   2877 Jan 16 09:33 composer.json
-rw-r--r--  1 abc abc 404511 Jan 16 09:33 composer.lock
drwxr-xr-x  4 abc abc      7 Jan 16 09:33 config
drwxr-xr-x  3 abc abc     10 Jan 16 09:33 docker
drwxr-xr-x  2 abc abc     16 Jan 16 09:33 migrations
-rw-r--r--  1 abc abc    914 Jan 16 09:33 phpunit.xml.dist
drwxr-xr-x  5 abc abc     15 Jan 16 09:33 public
drwxr-xr-x 11 abc abc     13 Jan 16 09:33 src
-rw-r--r--  1 abc abc  15002 Jan 16 09:33 symfony.lock
drwxr-xr-x  8 abc abc     11 Jan 16 09:33 templates
drwxr-xr-x  3 abc abc      5 Jan 16 09:33 tests
drwxr-xr-x  2 abc abc      6 Jan 16 09:33 translations
drwxrwxrwx  4 abc abc      4 Jan 16 09:34 var
drwxr-xr-x 24 abc abc     26 Jan 16 09:34 vendor

@tchapi
Copy link
Owner

tchapi commented Jan 16, 2025

Seems fine to me 🤷🏼 And what's in your .env.local file?

@armouredking
Copy link
Author

Sanitized. Also, it doesn't recognize _FILE parameters, so I did have to change them around from my initial:

APP_ENV=prod
APP_SECRET=$secretkey
LOG_FILE_PATH=/config/log/davis/app.log
DATABASE_DRIVER=mysql
DATABASE_URL=$validpath
MAILER_DSN=$validmx:587
ADMIN_LOGIN=webadmin
ADMIN_PASSWORD=$validpass
AUTH_REALM=SabreDAV
AUTH_METHOD=IMAP
IMAP_AUTH_URL=$validmx:993
IMAP_AUTH_USER_AUTOCREATE=true
CALDAV_ENABLED=true
CARDDAV_ENABLED=true
WEBDAV_ENABLED=false
WEBDAV_TMP_DIR=/config/webdav/tmp
WEBDAV_PUBLIC_DIR=/config/webdav/public
WEBDAV_HOMES_DIR=/config/webdav/homes
INVITE_FROM_ADDRESS=$validaddress
APP_TIMEZONE=
TRUSTED_PROXIES=127.0.0.1
TRUSTED_HOSTS=^localhost|<valid dot escaped domain>$

Renaming it to .env and running the migration command works. It just doesn't work when it is .env.local

@tchapi
Copy link
Owner

tchapi commented Jan 16, 2025

There's something shady in your local setup then, but I don't know what

Also, it doesn't recognize _FILE parameters

What are _FILE parameters? LOG_FILE_PATH ?

@armouredking
Copy link
Author

No, where you append _FILE to the end of the ENV so that it'll take a file content rather than coding it into the ENV. It just makes secrets easier to manage when you load them from a common repository.

The 'local' environment is Linuxserver's SWAG container. Because SWAG comes with the prereqs listed, I'm just podman exec -it $name /bin/bash and doing the initial work from inside the container. The folder davis resides in is a bind mount so the data won't be lost upon restart.

@tchapi
Copy link
Owner

tchapi commented Jan 25, 2025

No, where you append _FILE to the end of the ENV so that it'll take a file content rather than coding it into the ENV. It just makes secrets easier to manage when you load them from a common repository.

I don't see how that would work, this is not something that Symfony provides (the framework used to power Davis)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants