TransWikia.com

.env parsing error on Windows server

Craft CMS Asked by carbonjoetunis on February 20, 2021

Has anyone had issues with Craft parsing a .env on Windows Server? Dotenv is throwing an exception (FileException – invalid name) when parsing the first line of my .env, which is just a comment. I can remove that line and then i complains about the next line.

My .env simple starts with:

# The environment Craft is currently running in (dev, staging, production, etc.)
ENVIRONMENT=dev

basically, Dotenv/Parser/isValidName’s Regex call is failing.

Full Stack…

Fatal error: Uncaught DotenvExceptionInvalidFileException: Failed to parse dotenv file due to an invalid name. Failed at [ENVIRONMENT]. in C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcParser.php:74 

Stack trace: 
#0 C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcParser.php(30): DotenvParser::parseName() 

#1 C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcLoader.php(169): DotenvParser::parse()

#2 C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcLoader.php(107): DotenvLoader->processEntries()

#3 C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcLoader.php(91): DotenvLoader->loadDirect()

#4 C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcDotenv.php(123): DotenvLoader->load()

#5 C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcDotenv.php(80): DotenvDotenv->loadData()

#6 in C:WebRootWebApplicationsadvantage-rebate-portal-v4.0vendorvlucasphpdotenvsrcParser.php on line 74

One Answer

Turns out it WAS a file encoding issue. It was UTF BOM (?), and had a weird hidden character right at the beginning of the file. I was able to open the file up in Notepad++ (Thanks Brad) and was able to convert the file to "normal" UTF8.

Answered by carbonjoetunis on February 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP