gjtorikian / commonmarker

Ruby wrapper for the comrak (CommonMark parser) Rust crate
MIT License
416 stars 80 forks source link

Building in Docker fails for alpine/musl #272

Open andyjeffries opened 5 months ago

andyjeffries commented 5 months ago
129.3 error: cannot produce cdylib for `commonmarker v1.0.0
129.3 (/usr/local/bundle/gems/commonmarker-1.0.4/ext/commonmarker)` as the target
129.3 `x86_64-unknown-linux-musl` does not support these crate types
129.3 make: *** [Makefile:566: target/release/libcommonmarker.so] Error 101
129.3 
129.3 make failed, exit code 2
129.3 
129.3 Gem files will remain installed in /usr/local/bundle/gems/commonmarker-1.0.4 for
129.3 inspection.
129.3 Results logged to
129.3 /usr/local/bundle/extensions/x86_64-linux-musl/3.3.0/commonmarker-1.0.4/gem_make.out
129.3 
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:125:in `run'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:51:in `block in make'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `each'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `make'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:42:in `build'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:193:in `build_extension'
129.3 /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:227:in `block in
129.3 build_extensions'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `each'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `build_extensions'
129.3   /usr/local/lib/ruby/3.3.0/rubygems/installer.rb:852:in `build_extensions'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/rubygems_gem_installer.rb:76:in
129.3 `build_extensions'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/rubygems_gem_installer.rb:28:in
129.3 `install'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/source/rubygems.rb:205:in
129.3 `install'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/installer/gem_installer.rb:54:in
129.3 `install'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/installer/gem_installer.rb:16:in
129.3 `install_from_spec'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/installer/parallel_installer.rb:132:in
129.3 `do_install'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/installer/parallel_installer.rb:123:in
129.3 `block in worker_pool'
129.3   /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/worker.rb:62:in `apply_func'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/worker.rb:57:in `block in
129.3 process_queue'
129.3   <internal:kernel>:187:in `loop'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/worker.rb:54:in
129.3 `process_queue'
129.3 /usr/local/bundle/gems/bundler-2.5.4/lib/bundler/worker.rb:90:in `block (2
129.3 levels) in create_threads'
129.3 
129.3 An error occurred while installing commonmarker (1.0.4), and Bundler cannot
129.3 continue.
129.3 
129.3 In Gemfile:
129.3   commonmarker
------
ERROR: failed to solve: executor failed running [/bin/sh -c apk add --update --no-cache build-base make gcc musl-dev     && bundle install     && rm -rf /usr/local/bundle/cache/*.gem     && find /usr/local/bundle/gems/ -name "*.c" -delete     && find /usr/local/bundle/gems/ -name "*.o" -delete     && apk del make gcc musl-dev build-base]: exit code: 5

Exited with code exit status 1

This is a Ruby 3.3 (ruby:3.3.0-alpine) based image, that is simply doing a bundle install

gjtorikian commented 5 months ago

Ah yeah I don't support musl, it says so right in the first few lines:

129.3 error: cannot produce cdylib for `commonmarker v1.0.0
129.3 (/usr/local/bundle/gems/commonmarker-1.0.4/ext/commonmarker)` as the target
129.3 `x86_64-unknown-linux-musl` does not support these crate types

I am not sure if I ever will tbh. Bluntly, it's more work to figure out how to get it working in this environment. I have heard too many tales of alpine being "different" enough to not investigate it. I'd consider PRs that support it, though.

gjtorikian commented 2 months ago

Hi, I had a chance to look into this. I can adjust the project to build for x86_64-linux-musl:

cd pkg/commonmarker-1.1.1-x86_64-linux-musl
  Successfully built RubyGem
  Name: commonmarker
  Version: 1.1.1
  File: commonmarker-1.1.1-x86_64-linux-musl.gem

But, I don't know enough about musl to understand what your platform is. The build system I use doesn't recognize it:

❌ Platform x86_64-unknown-linux-musl is not supported

Would support for x86_64-linux-musl be enough for you? What exactly is unknown-linux-musl?

andyjeffries commented 2 months ago

To be honest, we've just pinned the version to 0.23.10 and it works for us. So don't stress too much for now about it (at least from my perspective)

It was being built on an alpine base on CircleCI. So I don't know what CPUs they use or why it comes as "unknown".