Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dvlancer's avatar

Unable to read the environment file

Hi all

after deploying for a very first time the application is unable to locate the environment file.

PHP Fatal error: Uncaught exception 'Dotenv\Exception\InvalidPathException' with message 'Unable to read the environment file at /var/www/projectdir/releases/20160628080834/bootstrap/../.env.'

However envoyer uploads .env file into project path directory /var/www/projectdir

why does envoyer uploads it into /var/www/projectdir and not into /var/www/projectdir/releases/20160628080834?

0 likes
9 replies
d3xt3r's avatar

The env file should not be part of your version control. Envoyer will always write it to the current directory

dvlancer's avatar

env is not part of our version control

Envoyer places it in a wrong directory

Under deployment options in server configuration we have the following Project Path: /var/www/projectdir

After deployment Envoyer creates the following folders inside /var/www/projectdir: current -> /var/www/projectdir/releases/20160628080834/ .env releases/ storage/

However when we access the website, laravel looks for the .env in /var/www/projectdir/releases/20160628080834/

d3xt3r's avatar

what path you are using to access the site?

Your site should point to /var/www/projectdir/current/public. The env file will be stored in /var/www/projectdir/ with symlinking in current/ This is how, in general current/ directory should look like

drwxrwxr-x 11 forge forge   4096 Jun 13 23:32 .
drwxrwxr-x  6 forge forge   4096 Jun 13 23:33 ..
lrwxrwxrwx  1 forge forge     24 Jun 13 23:32 .env -> /home/forge/default/.env
-rw-rw-r--  1 forge forge    423 Jun 13 23:31 .env.example
-rw-rw-r--  1 forge forge     61 Jun 13 23:31 .gitattributes
-rw-rw-r--  1 forge forge    105 Jun 13 23:31 .gitignore
drwxrwxr-x  9 forge forge   4096 Jun 13 23:31 app
-rwxrwxr-x  1 forge forge   1646 Jun 13 23:31 artisan
drwxrwxr-x  3 forge forge   4096 Jun 13 23:31 bootstrap
-rw-rw-r--  1 forge forge   1434 Jun 13 23:31 composer.json
-rw-rw-r--  1 forge forge 122740 Jun 13 23:31 composer.lock
drwxrwxr-x  2 forge forge   4096 Jun 13 23:31 config
drwxrwxr-x  5 forge forge   4096 Jun 13 23:31 database
-rw-rw-r--  1 forge forge    728 Jun 13 23:31 gulpfile.js
drwxrwxr-x  2 forge forge   4096 Jun 13 23:31 middleware
-rw-rw-r--  1 forge forge    338 Jun 13 23:31 package.json
-rw-rw-r--  1 forge forge   1026 Jun 13 23:31 phpunit.xml
drwxrwxr-x  8 forge forge   4096 Jun 13 23:31 public
-rw-rw-r--  1 forge forge   1918 Jun 13 23:31 readme.md
drwxrwxr-x  5 forge forge   4096 Jun 13 23:31 resources
-rw-rw-r--  1 forge forge    567 Jun 13 23:31 server.php
lrwxrwxrwx  1 forge forge     27 Jun 13 23:32 storage -> /home/forge/default/storage
drwxrwxr-x  2 forge forge   4096 Jun 13 23:31 tests
drwxrwxr-x 32 forge forge   4096 Jun 13 23:32 vendor

dvlancer's avatar

correct. our site is pointed to /var/www/projectdir/current/public

I'm assuming that Envoyer should've created the symlink (current/.env -> /var/www/projectdir/.env ) during the deployment. Shouldn't?

d3xt3r's avatar

It should if you are using envoyer to manage your environment.

dvlancer's avatar

ok, we do use envoyer to manage our environment. It does upload the .env in /var/www/projectdir/ but it does not create symlink to this file from the current dir

d3xt3r's avatar

I think then you should take this up with Envoyer support.

etelford's avatar

Be sure to cd into the directory first. If you're running this from forge, have your scheduler command look like:

cd /your/projectdir/current; php artisan command

Or the same in your crontab.

Please or to participate in this conversation.