Laravel 5.8 , artisan commands error : Failed to parse dotenv file due to an invalid name

Abdulaziz Tayyar picture Abdulaziz Tayyar · Mar 13, 2019 · Viewed 14.6k times · Source

This problem only happens with Laravel 5.8 on my shared hosting.

It is working fine in my shared hosting with Laravel 5.7.

It is working fine in my local environment with Laravel 5.8.

the problem is:

every time I run php artisan commands (on my shared hosting with Laravel 5.8 only) I got this error

The environment file is invalid! Failed to parse dotenv file due to an invalid name.

Failed at [APP_NAME].

my .env first line is : APP_NAME=rased

Also my site after updating to Laravel 5.8 is becoming a white blank page!

Answer

Praj Basnet picture Praj Basnet · Aug 14, 2019

This is a general error related to parsing the .env file. You'll see this is indicated in the error e.g.

The environment file is invalid!
Failed to parse dotenv file due to unexpected whitespace. 
Failed at [This will fail].

In this example it was caused by having unescaped whitespace in the APP_NAME field i.e.

APP_NAME=This will fail

To fix, escape with quotes e.g.

APP_NAME="This is better"