Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Why is building the Ruby environment hard?

SHIBATA Hiroshi
September 10, 2022

Why is building the Ruby environment hard?

The Rubyists are facing the build error with missing libraries like openssl, libyaml and libffi issues when they install the new versions every year. Other people are facing issues of nokogiri, rmagick and others when they develop Rails application.

Why we got these issues everyday? I describe the build failure case and their solution from the ruby-build maintainer's point of view. Finally, I introduce the plan for the imcompatible changes about build process in Ruby 3.2 and Rust support of next version of RubyGems.

SHIBATA Hiroshi

September 10, 2022
Tweet

More Decks by SHIBATA Hiroshi

Other Decks in Programming

Transcript

  1. Hiroshi SHIBATA @hsbt https://hsbt.org Executive Of fi cer VP of

    Engineering Technical Director at GMO Pepabo, Inc. @pepabo
  2. 3VCZ͕NBD04ͰϏϧυͰ͖ͳ͍ • ໰୊3VCZ΍ͷϏϧυ࣌ʹGJEEMFͰΤϥʔ • ղܾ๏BGJEEMFͷΤϥʔΛ௚͢ • ͔͠͠3VCZ͸ϝϯςφϯε͕ऴ͍ྃͯ͠ΔͷͰम ਖ਼͞Εͨ΋ͷ͕ϦϦʔε͞ΕΔ͜ͱ͸ͳ͍ compiling escape.c

    closure.c:264:14: error: implicit declaration of function 'ffi_prep_closure' is invalid in C99 [-Werror,-Wimplicit-function-declaration] result = ffi_prep_closure(pcl, cif, callback, (void *)self); ^ 6 warnings and 1 error generated.
  3. NBD04 7FOUVSB ͰϏϧυ͕Ͱ͖ͳ͍ • ໰୊݄͝ΖʹϦϦʔε༧ఆͷNBD04ͷ࣍ͷόʔδϣ ϯ7FOUVSBͰ͸3VCZ͕ϏϧυͰ͖ͳ͍🍎 • IUUQTCVHTSVCZMBOHPSHJTTVFT (snip) linking

    shared-object -test-/arith_seq/extract.bundle Undefined symbols for architecture arm64: "_rb_arithmetic_sequence_extract", referenced from: _arith_seq_s_extract in extract.o "_rb_ary_new_capa", referenced from: _arith_seq_s_extract in extract.o "_rb_ary_store", referenced from: _arith_seq_s_extract in extract.o "_rb_define_singleton_method", referenced from: _Init_extract in extract.o "_rb_path2class", referenced from: _Init_extract in extract.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
  4. NBD04 7FOUVSB ͰϏϧυ͕Ͱ͖ͳ͍ • ղܾ๏LBUFJ͕࡞ͬͨɺ"QQMFͷMMWNͷํͷػೳมߋʹ௥ै͢ Δमਖ਼ CVOEMF@MPBEFSΛ࢖͏ ͰϏϧυͰ͖ΔΑ͏ʹͳͬͨ • IUUQTHJUIVCDPNSVCZSVCZQVMM

    • ʹ΋όοΫϙʔτ͠ͳ͍ͱϏϧυ͸͓ͦΒ͘ෆՄೳ • 13͸࡞ͬͨͷͰɺ7FOUVSBਖ਼ࣜϦϦʔε࣌ʹ͸ΈΜͳ࢖͑Δ Α͏ʹͳΔ͸ͣɻ • 3VCZ͸ϚʔδࡁΈͳͷͰେৎ෉
  5. NBD04 7FOUVSB ͰGPSL͕ͳΜ͔ม • AUFTU@QSPDFTTSCAͷGPSLͷςετ͕ಈ͔ͳ͍ • ͓ͦΒ͘ࠓͷ··ͩͱ·ͱ΋ʹ։ൃ͸Ͱ͖ͳͦ͞͏ • ؀ڥม਺ͱͯ͠AFYQPSU0#+$@%*4"#-&@*/*5*"-*;&@'03,@4"'&5::&4AͰͱ Γ͋͑ͣςετ͸ಈ͕͘

    • ܧଓௐࠪத TestProcess#test_daemon_noclose objc[10525]: +[NSPlaceholderMutableString initialize] may have been in progress in another thread when fork() was called. objc[10525]: +[NSPlaceholderMutableString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
  6. NZTRM͕ϏϧυͰ͖ͳ͍  • ໰୊NZTRM@DPOGJH͕ݟ͔ͭΒͳ͍ • ղܾ๏ANZTRM@DPOGJHAΛ࢖͏ • ͜ͷखͷΤϥʔ͸QLHDPOGJHࢦఆͰղܾ͢Δ͜ͱ΋͋Δ (snip) checking

    for my_bool in mysql.h... no ----- Setting rpath to /opt/homebrew/Cellar/mysql/8.0.30/lib ----- $ gem install mysql2 -- --with-mysql-config=/opt/homebrew/bin/mysql_config
  7. NZTRM͕ϏϧυͰ͖ͳ͍  • ໰୊MJCTTMͱMJC[TUEͰϦϯΫΤϥʔ • ղܾ๏AMEGMBHTAͱAXJUIDQQGMBHTAΛ࢖͏ (snip) linking shared-object mysql2/mysql2.bundle

    ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) $ gem i mysql2 -- --with-ldflags=-L(brew --prefix openssl)/lib -L(brew --prefix zstd)/lib \ --with-cppflags=-I(brew --prefix openssl)/include
  8. NZTRM͕ͳͥϏϧυͰ͖ͳ͍ͷ͔ • IPNFCSFXͷύεͱґଘϥΠϒϥϦͷ໰୊🍺  • IPNFCSFX͕ఏڙ͢ΔNZTRMͷόΠφϦ͕ϦϯΫ͞ΕͯϥΠϒϥϦ PQFOTTM [TUE ͱSVCZ͕Ϗϧυ͞Εͨ࣌ʹϦϯΫ͞ΕΔϥΠϒϥϦ͕ ෆҰக

    • .NBD04Ͱ͸APQUIPNFCSFXAʹ΋ͳͬͯΔͷ΋໽հ • IUUQTHJUIVCDPNSCFOWSVCZCVJMEQVMMJTTVFDPNNFOU • ͪͳΈʹ͜ΕΒͷ໰୊͸NZTRMͰࣗಈͰ൑ఆ͞ΕΔΑ͏ʹमਖ਼ࡁΈ
  9. SEQBSUZίʔυͷόϯυϧ໰୊ • ݩʑ͸8JOEPXTͰͷϏϧυରࡦ • ೥WDQLHͷ͓͔͛Ͱ͜ͷ໰୊͸ղܾ͍ͯ͠Δ • 3VCZ ίϛολ ͷίϯτϩʔϧͷ֎Ͱมߋ΁ͷରԠίετ͸େ͖ ͍

    • όϯυϧ͢Δίʔυͷߋ৽͸৬ਓʹΑΔMJCZBNMͷมߋΛ೺ Ѳ্ͨ͠Ͱͷ3VCZ޲͚ͷύονΛखϚʔδ ITCUXPSL  • ੬ऑੑ͕ൃݟ͞Εͨ৔߹͸3VCZຊମͷϦϦʔε΋ඞཁͱͳΔ
  10. 3VCZͷϏϧυ͸ ͪΐͬͱ ೉͍͠ • 3VCZ͸αϝͷΑ͏ʹӭ͗ଓ͚ͯมԽ͠ଓ͚Δݴޠ🦈  • ݴޠػೳతͳҙຯ͚ͩͰ͸ͳ͘؀ڥʹదԠ͠ଓ͚͍ͯΔ • ؀ڥ΁ͷదԠ͸ίϛολͷ౒ྗ͚ͩͰ͸ͳ͘ɺଟ͘ͷϢʔβʔͷڠ

    ྗͰ੒Γཱ͍ͬͯΔ • 4QFDJBMUIBOLTOPCV LBUFJ SIF [O[ LLVCVO FSFHPO • 3VCZͷະདྷʹ޲͚ͯΤίγεςϜ։ൃΛҰॹʹ΍͍͖ͬͯ·͠ΐ͏💎