Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Misbeavings with target x86_64-unknown-linux-musl #1603

Closed
lanceschi opened this issue Jan 29, 2022 · 20 comments
Closed

Misbeavings with target x86_64-unknown-linux-musl #1603

lanceschi opened this issue Jan 29, 2022 · 20 comments
Labels
C-bug Category: This is a bug O-linux Operating system: Linux

Comments

@lanceschi
Copy link

lanceschi commented Jan 29, 2022

Reproduction steps

I managed to build helix editor v0.6.0 with target set to x86_64-unknown-linux-musl.

Here's the Dockerfile. If I extract the binary from the built image and I run it on my Ubuntu 20.04.3 LTS desktop for instance, it works as expected. It did not under the Alpine Linux v3.15.0 container. The theme doesn't seem to be applied as well as the syntax highlighting.

Build the above Dockerfile:

docker build \
  --file ./Dockerfile \
  --pull -t "<DOCKER-IMAGE-NAME>" .

... and run the container with the following:

docker run --rm -it <DOCKER-IMAGE-NAME> /bin/ash

From within the running container download an example file:

wget https://raw.githubusercontent.com/lanceschi/threejs-ply-loader/develop/tests/index.spec.js

Open it verbosely:

./hx -vvv index.spec.js

Here's a screenshot:
helix-editor-alpine

Here the content of Alpine Linux file ~/.cache/helix/helix.log:

2022-01-29T19:28:27.724 helix_core::syntax [INFO] Error opening dynamic library "/helix-v0.6.0/runtime/grammars/javascript.so"
2022-01-29T19:28:27.725 helix_view::editor [ERROR] Failed to initialize the LSP for `source.js` { LSP not defined }
2022-01-29T19:28:27.725 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
2022-01-29T19:28:27.725 mio::poll [TRACE] registering event source with poller: token=Token(2), interests=READABLE | WRITABLE
2022-01-29T19:28:27.725 mio::poll [TRACE] registering event source with poller: token=Token(0), interests=READABLE
2022-01-29T19:28:27.725 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE
2022-01-29T19:30:05.388 mio::poll [TRACE] deregistering event source from poller
2022-01-29T19:30:05.388 mio::poll [TRACE] deregistering event source from poller

Here's the screenshot of the same file opened with the same musl binary on the host Ubuntu 20.04.3 LTS:

helix-ubuntu

Here's the Ubuntu log ~/.cache/helix/helix.log:

2022-01-29T20:41:31.821 helix_core::syntax [INFO] Error opening dynamic library "/home/luca/dev/tools-in-rust/helix-editor-musl2/dist/helix-v0.6.0/runtime/grammars/javascript.so"
2022-01-29T20:41:31.822 helix_view::editor [ERROR] Failed to initialize the LSP for `source.js` { LSP not defined }
2022-01-29T20:41:31.822 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
2022-01-29T20:41:31.822 mio::poll [TRACE] registering event source with poller: token=Token(2), interests=READABLE | WRITABLE
2022-01-29T20:41:31.822 mio::poll [TRACE] registering event source with poller: token=Token(0), interests=READABLE
2022-01-29T20:41:31.822 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE
2022-01-29T20:41:33.929 mio::poll [TRACE] deregistering event source from poller
2022-01-29T20:41:33.929 mio::poll [TRACE] deregistering event source from poller

Environment

  • Platform: Alpine Linux v3.15.0
  • Terminal emulator: Terminator (and WezTerm)
  • Helix version: helix v0.6.0-dirty

Thanks 💯 for the awesome app!!!

@lanceschi lanceschi added the C-bug Category: This is a bug label Jan 29, 2022
@dead10ck
Copy link
Member

dead10ck commented Jan 29, 2022

You have to tell helix where to find the runtime directory, so you'll need something like

ENV HELIX_RUNTIME="/helix-${VERSION}/runtime"

@archseer
Copy link
Member

Ah cool, you got it to build on musl? Linking back to an older thread where there was some issues #1028

@lanceschi
Copy link
Author

You have to tell helix where to find the runtime directory, so you'll need something like

ENV HELIX_RUNTIME="/helix-${VERSION}/runtime"

Hello @dead10ck, and thanks for your advice. I made some minor edits to the Dockerfile and I added the following line:

ENV PATH=/helix-${VERSION}:"$PATH"

... so that the helix editor can be invoked simply issuing hx without the ./ folder prefix. No noticeable difference though.
I tried your suggestion within the live running container issuing the following:

export HELIX_RUNTIME="/helix-${VERSION}/runtime"

Again no noticeable difference:
helix-alpine

@dead10ck
Copy link
Member

Ah I see, maybe it's related to #1028 then.

@lanceschi
Copy link
Author

lanceschi commented Jan 30, 2022

Ah cool, you got it to build on musl? Linking back to an older thread where there was some issues #1028

Hello @archseer,

yes, I setup a Dockerfile in a WIP github repo.
You can build the docker image yourself or pull a prebuilt image:

docker pull lanceschi/helix-editor-musl:latest

... and have a look:

docker run --rm -it lanceschi/helix-editor-musl:latest /bin/ash

You can also have a look at the logs of the Github Dockerfile build action.

@jirutka
Copy link

jirutka commented Feb 2, 2022

I’ve packaged Helix in Alpine Linux (package helix), so you don’t have to build it yourself anymore. It’s currently in the testing repo, I’m gonna move it to the community repo soon.

@lanceschi
Copy link
Author

lanceschi commented Feb 2, 2022

Hello @jirutka,

thanks a lot! I had a try issuing the following from a alpine:3.15.0 base image:

echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
apk add helix@testing

The post message install note reports:

fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
(1/1) Installing helix@testing (0.6.0-r0)
Executing helix-0.6.0-r0.post-install
*
* Tree-sitter grammars for syntax highlighting are packaged separately.
* Install either selected tree-sitter-<lang> packages for the languages you
* use or a "virtual package" tree-sitter-grammars to install all of them.
*

How am I supposed to install those?
Maybe that's why I can't get syntax highlighting?

Another thing I noticed checking the helix version number:

$ hx -V
helix v3.15.0-5432-gd33618c49f

Isn't it supposed to be helix v0.6.0?

@jirutka
Copy link

jirutka commented Feb 2, 2022

How am I supposed to install those?

I don’t understand what’s unclear on this. They are packaged separately, i.e. there are packages tree-sitter-rust, tree-sitter-ruby etc. which you can install to get syntax highlighting for the given languages. Or you can install tree-sitter-grammars which will install all tree-sitter grammar packages available in the Alpine repository. Packages are installed using apk add, as you already did to install helix itself.

$ hx -V
helix v3.15.0-5432-gd33618c49f

Thanks, I’ll fix this.
The problem here is that helix foolishly reads its own version during the build from a git repository where the sources are unpacked. This version (v3.15.0-5432-gd33618c49f) actually comes from our aports repository, where build recipes are stored and packages are built from.

@archseer
Copy link
Member

archseer commented Feb 2, 2022

@jirutka Thank you for packaging helix! 🎉

The problem here is that helix foolishly reads its own version during the build from a git repository where the sources are unpacked.

Yeah this was my concern when the change was introduced in #957. I'll revert that and only pull the commit sha from the repository. That won't fully fix it but at least the version will be correct.

EDIT: d3221b0

@lanceschi
Copy link
Author

lanceschi commented Feb 2, 2022

Thanks 💯 for the clarification @jirutka. I followed your advices:

echo "@edge https://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories
apk add tree-sitter-javascript@edge

Now I gained syntax highlighting for JavaScript files, still the helix default purple theme doesn't seem to be applied:
alpine-helix

Any clues?

@archseer
Copy link
Member

archseer commented Feb 2, 2022

What terminal are you using? Does it support true color?

@lanceschi
Copy link
Author

@archseer I tried with both Terminator (and WezTerm)

I tried with both the more advanced bash as well as fish Unix shells instead of the default ash that comes with Alpine Linux.

Please also consider that both terminals works good with my host computer.

@jirutka
Copy link

jirutka commented Feb 2, 2022

Thank you for packaging helix! tada

You’re welcome!

Yeah this was my concern when the change was introduced in #957. I'll revert that and only pull the commit sha from the repository. That won't fully fix it but at least the version will be correct.

EDIT: d3221b0

You can test if there’s a .git directory in the root of the project; if it’s not, skip pulling any version information from git.

@jirutka
Copy link

jirutka commented Feb 2, 2022

I can confirm @archseer’s findings, I also see black background. I didn’t know it was supposed to be purple by default, so I didn’t initially consider it a bug. However, I dunno what can be the cause.

@jirutka
Copy link

jirutka commented Feb 2, 2022

I just tried it on my Alpine desktop in Kitty terminal and I see a purple background.

Relevant env. variables:

COLORTERM=truecolor
TERM=xterm-kitty

@lanceschi
Copy link
Author

export COLORTERM=truecolor did the trick for me. Thanks @jirutka

@archseer
Copy link
Member

archseer commented Feb 3, 2022

Weird, wezterm should be already setting the COLORTERM var.

@lanceschi
Copy link
Author

lanceschi commented Feb 4, 2022

Weird, wezterm should be already setting the COLORTERM var.

No, actually it makes sense @archseer. I launch WezTerm from the host computer where COLORTERM is correctly set to truecolor, whereas in the running Alpine container that specific ENV variable turns out to be unset.

I faced the same issue with a CentOS v7.x powered machine as well.

@lanceschi
Copy link
Author

@jirutka is it possible to see the Dockerfile or CLI command sequence you're using to build helix?

@jirutka
Copy link

jirutka commented Feb 4, 2022

testing/helix in the Alpine aports repository. However, you will not find anything special here. Maybe the key difference is that you build it with the stock rustc instead of rustc from Alpine package.

@kirawi kirawi added the O-linux Operating system: Linux label Jan 19, 2023
@helix-editor helix-editor locked and limited conversation to collaborators Apr 11, 2024
@pascalkuthe pascalkuthe converted this issue into discussion #10356 Apr 11, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-bug Category: This is a bug O-linux Operating system: Linux
Projects
None yet
Development

No branches or pull requests

5 participants