-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
.env file cannot be used: unexpected character "»" in variable name near "\ufeff" #9799
Comments
I could not reproduce just by creating an empty $ python3 -c 'with open(".env", "wb") as file: file.write(bytes("\uFEFF", "utf-8"))'
$ docker compose --env-file .env up
unexpected character "»" in variable name near "\ufeff" Notably,
|
Some Windows editors tend to add UTF-8 BOM markers to files, which breaks parsing of `.env` files. Now, when the file is read, if it starts with a UTF-8 BOM, we'll skip it. (`.env` files are always processed as UTF-8.) See docker/compose#9799. Signed-off-by: Milas Bowman <[email protected]>
Indeed, |
I made a fix for this in compose-spec/compose-go#301, which is the upstream library that handles the actual parsing. We'll get a new version of that tagged and included in the next release of Compose 🙂 |
This should be fixed in the latest release of Compose (v2.11.0+). |
Description
I am trying to get an application running with
docker compose up
that relies on environment variables that are set in a .env file. Anytime I attempt to use a .env file however, I get the error 'unexpected character "»" in variable name near "\ufeffENVIRONMENTVAR1=myvalue"'. I have gone so far as to make the .env file completely empty and this same error still occurs.Steps to reproduce the issue:
docker compose up
from an administrator powershell windowDescribe the results you received:
Docker compose appears to be failing to parse the .env file for a character that does not exist. I have triple checked that there is no hidden unicode characters in the file, and the failure occurs even on totally empty .env files.
Describe the results you expected:
The environment variables would be parsed from the file and used in the same way that
docker run --env-file .env <image>
uses them.Additional information you deem important (e.g. issue happens only occasionally):
Output of
docker compose version
:Output of
docker info
:Additional environment details:
The Windows Server 2019 instance I am running docker in is a VM on a Windows 10 host machine. Other operations with running containers directly, or using compose files that do not rely on environment files works fine.
The text was updated successfully, but these errors were encountered: