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

Error when building on Linux: 'utf-8' codec can't decode byte 0xc2 in position 6583: invalid continuation byte #8

Closed
johanneskastl opened this issue Jan 1, 2022 · 7 comments

Comments

@johanneskastl
Copy link

Hi,

when building this package as an RPM on openSUSE, I get the following error:

[  183s] ktop.x86_64: E: readelf-failed /usr/bin/ktop 'utf-8' codec can't decode byte 0xc2 in position 6583: invalid continuation byte
[  183s] Executing readelf on this file failed, all checks could not be run.

Any idea how to fix that? Is this something that needs to be done inside the source code or am I missing some flags for the build command?
(Sorry, golang-Newbie here...)

@vladimirvivien
Copy link
Owner

Hi @johanneskastl
Thanks for the issue. At first glance I have no idea what's going on with what you reported. Can you provide step-by-step detail how you got the error? How were you building the code ?

@johanneskastl
Copy link
Author

johanneskastl commented Jan 2, 2022

Hi,
basically I just setup a package in the openSUSE Buildservice (OBS) that does all the nitty gritty details:
https://build.opensuse.org/package/show/home:ojkastl_buildservice:Branch_devel_kubic/ktop

(OBS spawns a new VM with the desired OS, installs all package dependencies and builds the package inside that VM. This guarantees a clean state every time)

The build step is just:

go build \
   -mod=vendor \
   -buildmode=pie \
   -ldflags="-X main.Version=%{version}"

I also tried without those options but got the same error.

BTW, this build is using go1.17, but I get the same error with go1.16.

@vladimirvivien
Copy link
Owner

@johanneskastl I don't usually build with buildmode=pie, so I am not familiar of its requirements. My suggestion is to remove it (or use buildmode=default), so that the build generates a native executable for the targeted OS/architecture.

@johanneskastl
Copy link
Author

Hi Vladimir,
removing this options does not help, as I wrote. I still get the error when omitting this parameter.

@vladimirvivien
Copy link
Owner

@johanneskastl
Since I am not entirely sure how your build env is setup, I can only guess (based on error below) it is building a binary for the wrong OS/arc combination. The second line in error, readelf failed indicates there is an ELF problem which means that the binary that was built cant run on the OS/arc combination where the package is being prepared.

[  183s] ktop.x86_64: E: readelf-failed /usr/bin/ktop 'utf-8' codec can't decode byte 0xc2 in position 6583: invalid continuation byte
[  183s] Executing readelf on this file failed, all checks could not be run.

I think the error is happening at this line in your rpm spec:

# Install the binary.
install -D -m 0755 %{name} "%{buildroot}/%{_bindir}/%{name}"

Suggestions

I am not an expert in RPM building. But I can only suggest some simple debugging steps:

  1. Do a local build (outside of OBS) to make sure you can build the code (which I am guessing is not the problem)
  2. Use OBS to do a simple build that targets one arc only (i.e. x86_64 for example) , then test to see if your spec succeeds
  3. If you are building for Linux/x86_64 only, try specifying that in your build
GOOS=linux GOARCH=amd64 go build \
   -mod=vendor \
   -buildmode=pie \
   -ldflags="-X main.Version=%{version}"```

Hope this helps move your effort further. Thanks for doing this.

@johanneskastl
Copy link
Author

I just did some more testing:

  • adding the options you mentioned (GOOS=linux GOARCH=amd64) did not help
  • removing the utf characters from ui/icons.go does not solve this

So I asked for help on the opensuse-go mailing list. I'll let you know if there is any answer or solution.

Thanks for your help, Vladimir!

@johanneskastl
Copy link
Author

This seems to be unrelated to this exact package, I saw this also on other packages. Seems to be an error inside the actual rpmlint check.

Hence closing this issue.

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

2 participants