bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.71k stars 3.98k forks source link

bazel mod graph whitespaces broken on Windows #22858

Closed Vertexwahn closed 14 hours ago

Vertexwahn commented 2 weeks ago

Description of the bug:

bazel mod graph leads to the following output on my Windows system:

e) PS G:\dev\project1> bazel mod graph
Starting local Bazel server and connecting to it...
<root> (de_vertexwahn@0.0.0)
Ôö£ÔöÇÔöÇÔöÇabseil-cpp@_ 
Ôöé   Ôö£ÔöÇÔöÇÔöÇbazel_skylib@_ (*) 
Ôöé   Ôö£ÔöÇÔöÇÔöÇgoogletest@1.14.0.bcr.1 (*) 
Ôöé   ÔööÔöÇÔöÇÔöÇplatforms@0.0.10 (*) 
Ôö£ÔöÇÔöÇÔöÇapple_support@1.15.1 
Ôöé   Ôö£ÔöÇÔöÇÔöÇbazel_skylib@_ (*) 
Ôöé   ÔööÔöÇÔöÇÔöÇplatforms@0.0.10 (*) 
Ôö£ÔöÇÔöÇÔöÇautodiff@_ 
Ôöé   ÔööÔöÇÔöÇÔöÇeigen@3.4.0 (*) 
Ôö£ÔöÇÔöÇÔöÇbazel_skylib@_ 
Ôöé   Ôö£ÔöÇÔöÇÔöÇplatforms@0.0.10 (*) 
Ôöé   ÔööÔöÇÔöÇÔöÇrules_license@0.0.8 (*) 
Ôö£ÔöÇÔöÇÔöÇboost.algorithm@1.83.0.bcr.1 
Ôöé   Ôö£ÔöÇÔöÇÔöÇplatforms@0.0.10 (*) 
Ôöé   Ôö£ÔöÇÔöÇÔöÇboost@1.83.0.bcr.1 
Ôöé   Ôöé   Ôö£ÔöÇÔöÇÔöÇboost.asio@1.83.0.bcr.1 (*) 

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

Windows 11

What is the output of bazel info release?

release 7.2.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

peakschris commented 2 weeks ago

I've also been seeing this, windows 10, regardless of shell (cmd, bash, powershell)

sgowroji commented 2 weeks ago

Hi @Vertexwahn, Could you please provide complete steps to reproduce this issue?

peakschris commented 2 weeks ago

For me, on windows:

git clone https://github.com/bazelbuild/bazel.git
cd bazel
git checkout release-7.2.1 #specific release unimportant
bazel mod graph

displays:

Starting local Bazel server and connecting to it...
<root> (bazel@_)
Γö£ΓöÇΓöÇΓöÇabseil-cpp@20230125.1
Γöé   Γö£ΓöÇΓöÇΓöÇbazel_skylib@1.6.1 (*)
Γöé   Γö£ΓöÇΓöÇΓöÇplatforms@0.0.9 (*)
Γöé   ΓööΓöÇΓöÇΓöÇrules_cc@0.0.9 (*)
<snip>
fmeum commented 2 weeks ago

What happens if you pass --charset=ascii? Does your terminal support UTF-8?

peakschris commented 2 weeks ago

--charset=ascii shows the tables, albeit less nicely: image

The terminal does support UTF-8:

wget https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt
cat UTF-8-demo.txt

shows: image

fmeum commented 2 weeks ago

Sounds like Windows requires special API usage for printing UTF-8 to the console: https://stackoverflow.com/a/9337400/297261

If you are interested, you could try integrating WriteConsoleW in WriteToStdOutErr here: https://cs.opensource.google/bazel/bazel/+/master:src/main/cpp/util/file_windows.cc;drc=7f782e3c1a1c4a21beea19c2cedb614be8316e67

Edit: Fixed the reference

peakschris commented 2 weeks ago

I added this one line to file_windows.cc:

image

bazel mod graph now outputs: image

I think SetConsoleOutputCP could just be called once somewhere from main(), as long as it is not reset elsewhere.

Sorry, I can't submit this as a PR due to CLA.

Chris

fmeum commented 2 weeks ago

@bazel-io fork 7.3.0

Wyverald commented 14 hours ago

Fixed in https://github.com/bazelbuild/bazel/commit/4a5fe6207eb596effc13fe6b8e862727dc03eda6