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

UnicodeDecodeError"utf-8" on Windows10pro #5967

Closed
kaibara opened this issue May 17, 2018 · 9 comments
Closed

UnicodeDecodeError"utf-8" on Windows10pro #5967

kaibara opened this issue May 17, 2018 · 9 comments

Comments

@kaibara
Copy link

kaibara commented May 17, 2018

Description of the issue

I got the Error when docker-compose up on powershell

Context information (for bug reports)

Output of "docker-compose version"
docker-compose version 1.21.2, build a1334711
docker-py version: 3.3.0
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.0.2k  26 Jan 2017
Output of "docker version"
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:12:48 2018
 OS/Arch:      windows/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:22:38 2018
  OS/Arch:      linux/amd64
  Experimental: false
Output of "docker-compose config"
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 71, in main
  File "compose\cli\main.py", line 121, in perform_command
  File "compose\cli\main.py", line 332, in config
  File "compose\cli\command.py", line 68, in get_config_from_options
  File "compose\config\config.py", line 402, in load
  File "compose\config\config.py", line 502, in load_services
  File "compose\config\config.py", line 481, in build_services
  File "compose\config\config.py", line 481, in <listcomp>
  File "compose\config\config.py", line 473, in build_service
  File "compose\config\config.py", line 846, in finalize_service
  File "compose\config\config.py", line 658, in resolve_environment
  File "compose\config\environment.py", line 36, in env_vars_from_file
  File "c:\projects\compose\venv\lib\codecs.py", line 713, in __next__
  File "c:\projects\compose\venv\lib\codecs.py", line 644, in __next__
  File "c:\projects\compose\venv\lib\codecs.py", line 557, in readline
  File "c:\projects\compose\venv\lib\codecs.py", line 503, in read
  File "c:\projects\compose\venv\lib\encodings\utf_8_sig.py", line 117, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
[10840] Failed to execute script docker-compose

Steps to reproduce the issue

1.Job File install to local
2.move installed directory on powershell
3.docker-compose up

Observed result

Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 71, in main
  File "compose\cli\main.py", line 124, in perform_command
  File "compose\cli\command.py", line 41, in project_from_options
  File "compose\cli\command.py", line 113, in get_project
  File "compose\config\config.py", line 402, in load
  File "compose\config\config.py", line 502, in load_services
  File "compose\config\config.py", line 481, in build_services
  File "compose\config\config.py", line 481, in <listcomp>
  File "compose\config\config.py", line 473, in build_service
  File "compose\config\config.py", line 846, in finalize_service
  File "compose\config\config.py", line 658, in resolve_environment
  File "compose\config\environment.py", line 36, in env_vars_from_file
  File "c:\projects\compose\venv\lib\codecs.py", line 713, in __next__
  File "c:\projects\compose\venv\lib\codecs.py", line 644, in __next__
  File "c:\projects\compose\venv\lib\codecs.py", line 557, in readline
  File "c:\projects\compose\venv\lib\codecs.py", line 503, in read
  File "c:\projects\compose\venv\lib\encodings\utf_8_sig.py", line 117, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
[1772] Failed to execute script docker-compose

Expected result

docker-compose up finished

Stacktrace / full error message

  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 71, in main
  File "compose\cli\main.py", line 124, in perform_command
  File "compose\cli\command.py", line 41, in project_from_options
  File "compose\cli\command.py", line 113, in get_project
  File "compose\config\config.py", line 402, in load
  File "compose\config\config.py", line 502, in load_services
  File "compose\config\config.py", line 481, in build_services
  File "compose\config\config.py", line 481, in <listcomp>
  File "compose\config\config.py", line 473, in build_service
  File "compose\config\config.py", line 846, in finalize_service
  File "compose\config\config.py", line 658, in resolve_environment
  File "compose\config\environment.py", line 36, in env_vars_from_file
  File "c:\projects\compose\venv\lib\codecs.py", line 713, in __next__
  File "c:\projects\compose\venv\lib\codecs.py", line 644, in __next__
  File "c:\projects\compose\venv\lib\codecs.py", line 557, in readline
  File "c:\projects\compose\venv\lib\codecs.py", line 503, in read
  File "c:\projects\compose\venv\lib\encodings\utf_8_sig.py", line 117, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
[1772] Failed to execute script docker-compose

Additional information

OS version:
Windows 10 Pro

docker-compose install method:
Binary from (github release page)[https://github.com/docker/compose/releases]
and docker ce for windows installer (stable channel) from (docker store)[https://store.docker.com/editions/community/docker-ce-desktop-windows]

@AdrienLemaire
Copy link

Might that be related to #5826 ?

@kaibara kaibara changed the title UnicodeDecodeError"utf-8" on Windows10pro # UnicodeDecodeError"utf-8" on Windows10pro #5826 May 18, 2018
@kaibara kaibara changed the title UnicodeDecodeError"utf-8" on Windows10pro #5826 UnicodeDecodeError"utf-8" on Windows10pro May 18, 2018
@kaibara
Copy link
Author

kaibara commented May 18, 2018

This isuue resolved.
I mistaked settting.env File.
Thank,you.

@shin- shin- closed this as completed May 23, 2018
@geraldcsoftware
Copy link

@kaibara Can you please explain further what you mean by "I mistaked setting .env file". I am facing the same issue but can't figure out the steps you took that fixed the problem.

@kaibara
Copy link
Author

kaibara commented Jan 29, 2019

@Gerald-C
I'm sorry.
Since it is more than half a year's agenda, I forgot the concrete solution.
Can I find a solution together?

I think that it was caused by installing docker when the basic character code of windows is not utf - 8 and being unable to read the file in docker.
Could you try $ sr.CurrentEncoding with powershell?
As a result, or can you show me a screenshot?
Reference page(Japanese):https://codezine.jp/article/detail/3592

@geraldcsoftware
Copy link

@kaibara Still learning docker, my problem was - im trying to run an asp.net-core project using docker in visual studio. had a good run until i was trying to add a .env file for some environment variables. That's when the build failed with exactly the same stack trace and google got me here. Without the .env file, things work fine so far.

Here is my docker-compose.yml without using .env file:

services: sql-server: image: mcr.microsoft.com/mssql/server:2017-latest container_name: sample-sql-server-2017-container environment: - ACCEPT_EULA=Y - SA_PASSWORD=P@ssw0rd123 ports: - "1400:1433" shopping-api: image: ${DOCKER_REGISTRY-}shoppingapi environment: - ConnectionStrings:DbConnection=Server=sql-server;Database=MySampleShoppingApp;User Id=sa;Password=P@ssw0rd123 depends_on: - sql-server build: context: . dockerfile: src/shopping-api/Dockerfile

and with .env file, I use a variable for the SA_PASSWORD

`version: '3.4'

services:
sql-server:
image: mcr.microsoft.com/mssql/server:2017-latest
container_name: sample-sql-server-2017-container
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${SA_PASWORD_FROM_ENV_FILE}
ports:
- "1400:1433"
shopping-api:
image: ${DOCKER_REGISTRY-}shoppingapi
environment:
- ConnectionStrings:DbConnection=Server=sql-server;Database=MySampleShoppingApp;User Id=sa;Password=${SA_PASWORD_FROM_ENV_FILE}
depends_on:
- sql-server
build:
context: .
dockerfile: src/shopping-api/Dockerfile
`

My .env file just has this one line SA_PASSWORD_IN_ENV_FILE="P@ssw0rd123", and is in the same directory as the docker-compose.yml file. As soon as i do this, the error shows up.

24420] Failed to execute script docker-compose 2>Traceback (most recent call last): 2> File "docker-compose", line 6, in <module> 2> File "compose\cli\main.py", line 71, in main 2> File "compose\cli\main.py", line 124, in perform_command 2> File "compose\cli\command.py", line 27, in project_from_options 2> File "compose\config\environment.py", line 61, in from_env_file 2> File "compose\config\environment.py", line 57, in _initialize 2> File "compose\config\environment.py", line 36, in env_vars_from_file 2> File "c:\projects\compose\venv\lib\codecs.py", line 713, in __next__ 2> File "c:\projects\compose\venv\lib\codecs.py", line 644, in __next__ 2> File "c:\projects\compose\venv\lib\codecs.py", line 557, in readline 2> File "c:\projects\compose\venv\lib\codecs.py", line 503, in read 2> File "c:\projects\compose\venv\lib\encodings\utf_8_sig.py", line 117, in decode 2>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : [24420] Failed to execute script docker-compose 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : Traceback (most recent call last): 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "docker-compose", line 6, in <module> 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "compose\cli\main.py", line 71, in main 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "compose\cli\main.py", line 124, in perform_command 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "compose\cli\command.py", line 27, in project_from_options 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "compose\config\environment.py", line 61, in from_env_file 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "compose\config\environment.py", line 57, in _initialize 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "compose\config\environment.py", line 36, in env_vars_from_file 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "c:\projects\compose\venv\lib\codecs.py", line 713, in __next__ 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "c:\projects\compose\venv\lib\codecs.py", line 644, in __next__ 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "c:\projects\compose\venv\lib\codecs.py", line 557, in readline 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "c:\projects\compose\venv\lib\codecs.py", line 503, in read 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : File "c:\projects\compose\venv\lib\encodings\utf_8_sig.py", line 117, in decode 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte. 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(367,5): error : For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting 2>Done building project "docker-compose.dcproj" -- FAILED.

@geraldcsoftware
Copy link

Forgive the spacing and indenting, they seem to have been lost in copying and pasting.

@n4ybn
Copy link

n4ybn commented Feb 4, 2020

I had the same error and fixed it by removing the .etc file.

@PjotrB
Copy link

PjotrB commented Nov 23, 2020

I had this too, and found that my .env file started with the UTF-8 BOM. The fix was to use a text editor (Notepad++) to save it as ANSI, and then it was OK.

I can only wonder why someone would implement a "UTF-8 reader" and then forget to make it compatible with the well-documented marker that indicates that UTF-8 data is coming... :sigh:

@annamalaig
Copy link

Thanks @PjotrB -- Your recommendation resolved the issue for me on Windows 10.

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

7 participants