conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.08k stars 959 forks source link

[bug] Exception when passing string arguments to commands on PowerShell with UTF8-BOM encoding #13995

Open zillemarco opened 1 year ago

zillemarco commented 1 year ago

Environment details

Steps to reproduce

Running any command that accepts a string as input produces an exception. For example, running conan config show "core.*" throws this exception: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte.

Other commands that do not require string input work fine, for example conan --version.

Changing the encoding of the PowerShell session solved the issue. To do that I used this command: $PSDefaultParameterValues['*:Encoding'] = 'ascii'.

Logs

No response

memsharded commented 1 year ago

Hi @zillemarco

Thanks for your report.

I have been trying to reproduce, but it works fine here in my Windows Powershell. Maybe it is something in the configuration of your computer or your powershell? Does it happens in other Windows machine, or just that specific server?

zillemarco commented 1 year ago

Hi @memsharded, thanks for the quick feedback 🙂

Locally on my machine works as well, I had this issue on our CI pipeline running Windows Server 2019 PowerShell.

By default, Windows Server 2019 should come with PowerShell 5.1 installed (which had BOM enabled by default).

The image I am using is based on this docker image: mcr.microsoft.com/windows/servercore:ltsc2019

memsharded commented 1 year ago

Seems related: https://bugs.python.org/issue21927

What python version are you using?

I'd say that this sounds outside of the Conan scope. It is not possible for Conan to just be sanitizing every input to check for special BOM encodings by different systems, and also it is not possible to easily know in which terminal/powershell are you running with which encodings. I think this belongs and it should be provided by the Powershell+Python installation combo.

zillemarco commented 1 year ago

To be honest I don't know which version of Python it's using, I installed Conan via Chocolatey so I think that installed Python as a dependency, but running python --version from inside the container it does not recognize the command (same using python3) 🤷

But I do agree that this is more related to Python itself rather than Conan 🙂