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

Bazel build error “Invalid or incomplete multibyte or wide character” #16065

Closed
QIvan opened this issue Apr 19, 2021 · 11 comments
Closed

Bazel build error “Invalid or incomplete multibyte or wide character” #16065

QIvan opened this issue Apr 19, 2021 · 11 comments
Labels
area/build question Questions that are neither investigations, bugs, nor enhancements

Comments

@QIvan
Copy link
Contributor

QIvan commented Apr 19, 2021

Title: Bazel build error “Invalid or incomplete multibyte or wide character”

Description:
I followed your instruction to set up my build environment. I use Linux Ubuntu 20.04

I installed Bazelisk as bazel and downloaded clang+llvm-11.1.0-x86_64-linux-gnu-ubuntu-16.04 as required. But at the build step I got an exception:

bazel build --config=libc++ //source/exe:envoy-static

the output is

...   
ERROR: An error occurred during the fetch of repository 'go_sdk':
   Traceback (most recent call last):
    File "/home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/io_bazel_rules_go/go/private/sdk.bzl", line 100, column 16, in _go_download_sdk_impl
        _remote_sdk(ctx, [url.format(filename) for url in ctx.attr.urls], ctx.attr.strip_prefix, sha256)
    File "/home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/io_bazel_rules_go/go/private/sdk.bzl", line 180, column 29, in _remote_sdk
        ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error extracting /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/temp12776099964645160554/go1.15.5.linux-amd64.tar.gz to /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/temp12776099964645160554: /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/test/fixedbugs/issue27836.dir/Äfoo.go (Invalid or incomplete multibyte or wide character)
ERROR: Analysis of target '//source/exe:envoy-static' failed; build aborted: java.io.IOException: Error extracting /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/temp12776099964645160554/go1.15.5.linux-amd64.tar.gz to /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/temp12776099964645160554: /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/test/fixedbugs/issue27836.dir/Äfoo.go (Invalid or incomplete multibyte or wide character)
INFO: Elapsed time: 9.751s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (18 packages loaded, 6 targets configured)
    Fetching ...b20/external/go_sdk; Extracting /home/ivan/.cache/bazel/_bazel_ivan/bc15f3e663f55c36b0229b6c70ea3b20/external/go_sdk/temp12776099964645160554/go1.15.5.linux-amd64.tar.gz 6s

I understand it's somehow related to encodings but I'm out of options what can I do here.

[optional Relevant Links:]
I've found a similar problem
https://www.gitmemory.com/issue/bazelbuild/rules_go/2771/755621824

I also made a question on stackoverflow https://stackoverflow.com/questions/67165482/bazel-error-during-envoyproxy-envoy-build-invalid-or-incomplete-multibyte-or-wi

thank you in advance.

@QIvan QIvan added the triage Issue requires triage label Apr 19, 2021
@QIvan
Copy link
Contributor Author

QIvan commented Apr 19, 2021

funny enough, I got exactly the same error if I run a docker build:

./ci/run_envoy_docker.sh './ci/do_ci.sh bazel.dev'

No remote cache is set, skipping setup remote cache.
ENVOY_SRCDIR=/source
ENVOY_BUILD_TARGET=//source/exe:envoy-static
ENVOY_BUILD_ARCH=x86_64
$TEST_TMPDIR defined: output root default is '/build/tmp' and max_idle_secs default is '15'.
Starting local Bazel server and connecting to it...
$TEST_TMPDIR defined: output root default is '/build/tmp' and max_idle_secs default is '15'.
HEAD is now at d135632 fix test timeout (#146)
$TEST_TMPDIR defined: output root default is '/build/tmp' and max_idle_secs default is '15'.
building using 8 CPUs
building for x86_64
clang toolchain with libc++ configured
bazel fastbuild build with tests...
Building...
Building...
$TEST_TMPDIR defined: output root default is '/build/tmp' and max_idle_secs default is '15'.
WARNING: The following configs were expanded more than once: [clang]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
INFO: SHA256 (https://golang.org/dl/?mode=json&include=all) = 4bb9f5f7d71d826c10b10c65bcaf53847a038f646101c25de10e52d8ffae7a7e
INFO: Repository go_sdk instantiated at:
  /source/WORKSPACE:21:25: in <toplevel>
  /source/bazel/dependency_imports.bzl:19:27: in envoy_dependency_imports
  /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl:417:28: in go_register_toolchains
  /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl:129:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
  /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl:116:35: in <toplevel>
INFO: Repository 'go_sdk' used the following cache hits instead of downloading the corresponding file.
 * Hash '9a58494e8da722c3aef248c9227b0e9c528c7318309827780f16220998180a0d' for https://dl.google.com/go/go1.15.5.linux-amd64.tar.gz
If the definition of 'go_sdk' was updated, verify that the hashes were also updated.
ERROR: An error occurred during the fetch of repository 'go_sdk':
   Traceback (most recent call last):
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 100, column 16, in _go_download_sdk_impl
		_remote_sdk(ctx, [url.format(filename) for url in ctx.attr.urls], ctx.attr.strip_prefix, sha256)
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 180, column 29, in _remote_sdk
		ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error extracting /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198/go1.15.5.linux-amd64.tar.gz to /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198: /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/test/fixedbugs/issue27836.dir/�foo.go (Invalid or incomplete multibyte or wide character)
Internal error thrown during build. Printing stack trace: java.lang.IllegalStateException: Unexpected analysis error: ConfiguredTargetKey{label=//source/exe:envoy-static, config=BuildConfigurationValue.Key[f08be14ff07ffec9774f8551b3b64a6a219b46534825436b5e722feba526aef6]} -> ErrorInfo{exception=Traceback (most recent call last):
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 100, column 16, in _go_download_sdk_impl
		_remote_sdk(ctx, [url.format(filename) for url in ctx.attr.urls], ctx.attr.strip_prefix, sha256)
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 180, column 29, in _remote_sdk
		ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error extracting /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198/go1.15.5.linux-amd64.tar.gz to /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198: /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/test/fixedbugs/issue27836.dir/�foo.go (Invalid or incomplete multibyte or wide character), rootCauses=[REPOSITORY_DIRECTORY:@go_sdk], cycles=[], isCatastrophic=false, rootCauseOfException=REPOSITORY_DIRECTORY:@go_sdk, isDirectlyTransient=false, isTransitivelyTransient=true}, ([ConfiguredTargetKey{label=//source/exe:envoy-static, config=BuildConfigurationValue.Key[f08be14ff07ffec9774f8551b3b64a6a219b46534825436b5e722feba526aef6]}])
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.assertValidAnalysisException(SkyframeBuildView.java:875)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.processErrors(SkyframeBuildView.java:651)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.configureTargets(SkyframeBuildView.java:471)
	at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:418)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:213)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:128)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:168)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:405)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:97)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:589)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:235)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:546)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:611)
	at io.grpc.Context$1.run(Context.java:605)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

INFO: Elapsed time: 12.511s
INFO: 0 processes.
Internal error thrown during build. Printing stack trace: java.lang.IllegalStateException: Unexpected analysis error: ConfiguredTargetKey{label=//source/exe:envoy-static, config=BuildConfigurationValue.Key[f08be14ff07ffec9774f8551b3b64a6a219b46534825436b5e722feba526aef6]} -> ErrorInfo{exception=Traceback (most recent call last):
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 100, column 16, in _go_download_sdk_impl
		_remote_sdk(ctx, [url.format(filename) for url in ctx.attr.urls], ctx.attr.strip_prefix, sha256)
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 180, column 29, in _remote_sdk
		ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error extracting /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198/go1.15.5.linux-amd64.tar.gz to /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198: /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/test/fixedbugs/issue27836.dir/�foo.go (Invalid or incomplete multibyte or wide character), rootCauses=[REPOSITORY_DIRECTORY:@go_sdk], cycles=[], isCatastrophic=false, rootCauseOfException=REPOSITORY_DIRECTORY:@go_sdk, isDirectlyTransient=false, isTransitivelyTransient=true}, ([ConfiguredTargetKey{label=//source/exe:envoy-static, config=BuildConfigurationValue.Key[f08be14ff07ffec9774f8551b3b64a6a219b46534825436b5e722feba526aef6]}])
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.assertValidAnalysisException(SkyframeBuildView.java:875)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.processErrors(SkyframeBuildView.java:651)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.configureTargets(SkyframeBuildView.java:471)
	at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:418)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:213)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:128)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:168)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:405)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:97)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:589)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:235)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:546)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:611)
	at io.grpc.Context$1.run(Context.java:605)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
java.lang.IllegalStateException: Unexpected analysis error: ConfiguredTargetKey{label=//source/exe:envoy-static, config=BuildConfigurationValue.Key[f08be14ff07ffec9774f8551b3b64a6a219b46534825436b5e722feba526aef6]} -> ErrorInfo{exception=Traceback (most recent call last):
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 100, column 16, in _go_download_sdk_impl
		_remote_sdk(ctx, [url.format(filename) for url in ctx.attr.urls], ctx.attr.strip_prefix, sha256)
	File "/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/io_bazel_rules_go/go/private/sdk.bzl", line 180, column 29, in _remote_sdk
		ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error extracting /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198/go1.15.5.linux-amd64.tar.gz to /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/temp17390252849696083198: /build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/go_sdk/test/fixedbugs/issue27836.dir/�foo.go (Invalid or incomplete multibyte or wide character), rootCauses=[REPOSITORY_DIRECTORY:@go_sdk], cycles=[], isCatastrophic=false, rootCauseOfException=REPOSITORY_DIRECTORY:@go_sdk, isDirectlyTransient=false, isTransitivelyTransient=true}, ([ConfiguredTargetKey{label=//source/exe:envoy-static, config=BuildConfigurationValue.Key[f08be14ff07ffec9774f8551b3b64a6a219b46534825436b5e722feba526aef6]}])
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.assertValidAnalysisException(SkyframeBuildView.java:875)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.processErrors(SkyframeBuildView.java:651)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.configureTargets(SkyframeBuildView.java:471)
	at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:418)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:213)
	at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:128)
	at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:168)
	at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:405)
	at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:97)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:589)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:235)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:546)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:611)
	at io.grpc.Context$1.run(Context.java:605)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Server terminated abruptly (error code: 14, error message: 'Socket closed', log file: '/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/server/jvm.out')

please note �foo.go (Invalid or incomplete multibyte or wide character)

@asraa
Copy link
Contributor

asraa commented Apr 19, 2021

Maybe try clearing the entire cache?
bazel clean --expunge, or
rm -rf the whole cache /home/ivan/.cache/bazel/_bazel_ivan

@asraa asraa added area/build question Questions that are neither investigations, bugs, nor enhancements and removed triage Issue requires triage labels Apr 19, 2021
@QIvan
Copy link
Contributor Author

QIvan commented Apr 20, 2021

no... I did that, and with docker, it should be a clear state "our the box" anyway, right?

@asraa
Copy link
Contributor

asraa commented Apr 20, 2021

Can you read up and see if any of this helps? bazelbuild/bazel#12986
Particularly the utf8only

@QIvan
Copy link
Contributor Author

QIvan commented Apr 20, 2021

oh, my God, thank you, I'll take a look right away.

@QIvan
Copy link
Contributor Author

QIvan commented Apr 20, 2021

@asraa Thanks once again, I thought I'm alone with such a problem.
They said

Addressing the unicode handling situation for strings (replacing latin-1 with utf-8) is on the schedule for this year, perhaps in Q2.

but could you help me, please, with a workaround for this problem for the current Bazel version?

@asraa
Copy link
Contributor

asraa commented Apr 20, 2021

Add a patch to rules_go bazel-contrib/rules_go#2771 like this one

There are examples of patching deps in this repo. look for .patch files.

@jvolkman
Copy link

I believe rules_go v0.26+ has a workaround for this issue.

@asraa
Copy link
Contributor

asraa commented Apr 20, 2021

nice, feel free to try updating, and send a PR!

QIvan added a commit to QIvan/envoy that referenced this issue Apr 20, 2021
in the resent version of rules_go, the issue bazel-contrib/rules_go#2771 was fixed.
It should address the bazel build issue on some Linux or MacOS (bazelbuild/bazel#12986)

Signed-off-by: Ivan Zemlyanskiy <[email protected]>
@QIvan
Copy link
Contributor Author

QIvan commented Apr 20, 2021

@asraa here you go =)
#16083

build works for me after the upgrade. Thanks, @jvolkman!

lizan pushed a commit that referenced this issue Apr 21, 2021
in the resent version of rules_go, the issue bazel-contrib/rules_go#2771 was fixed. 
It should address the bazel build issue on some Linux or MacOS (bazelbuild/bazel#12986)

Signed-off-by: izemlyanskiy <[email protected]>
@QIvan
Copy link
Contributor Author

QIvan commented Apr 24, 2021

I think we can close it. At least, it works for me after my PR merge.
Thank y'all for the help, I do appreciate it!

@QIvan QIvan closed this as completed Apr 24, 2021
gokulnair pushed a commit to gokulnair/envoy that referenced this issue May 6, 2021
in the resent version of rules_go, the issue bazel-contrib/rules_go#2771 was fixed.
It should address the bazel build issue on some Linux or MacOS (bazelbuild/bazel#12986)

Signed-off-by: izemlyanskiy <[email protected]>
Signed-off-by: Gokul Nair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build question Questions that are neither investigations, bugs, nor enhancements
Projects
None yet
Development

No branches or pull requests

3 participants