google/rust_icu

SOLVED - Error building on macOS

westy92 opened this issue · 1 comments

When building/running my rust app, I received the following error:

error: failed to run custom build command for `rust_icu_sys v3.0.0`

Caused by:
  process didn't exit successfully: `/Users/westy92/Source/api-rust/target/debug/build/rust_icu_sys-d0b66de2cb871a9e/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=feature="renaming"
  cargo:rustc-cfg=feature="use-bindgen"
  cargo:rustc-cfg=feature="icu_config"

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: Empty }', /Users/westy92/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_icu_sys-3.0.0/build.rs:228:36
  stack backtrace:
     0:        0x104c9bfe6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6ae6bff14318b704
     1:        0x104cb231a - core::fmt::write::h072391c2938df059
     2:        0x104c7dbdc - std::io::Write::write_fmt::h88fcf164d5e43745
     3:        0x104c9bdc0 - std::sys_common::backtrace::print::h335d3fd0c103876b
     4:        0x104c83e73 - std::panicking::default_hook::{{closure}}::hd84d4fd3324d0128
     5:        0x104c83b62 - std::panicking::default_hook::h141bffb40908b0d1
     6:        0x104c846e1 - std::panicking::rust_panic_with_hook::h770b31c549b79e3e
     7:        0x104c9d044 - std::panicking::begin_panic_handler::{{closure}}::hddf7da8913935775
     8:        0x104c9c148 - std::sys_common::backtrace::__rust_end_short_backtrace::haa61a482c4c687d9
     9:        0x104c8423d - _rust_begin_unwind
    10:        0x104cc9443 - core::panicking::panic_fmt::h208cfee7b750b4aa
    11:        0x104cc98b5 - core::result::unwrap_failed::h65874989211a1511
    12:        0x104842968 - core::result::Result<T,E>::unwrap::hbafe4562ed8a51ba
                                 at /private/tmp/rust-20230331-7129-10kjp3b/rustc-1.68.2-src/library/core/src/result.rs:1112:23
    13:        0x10483f5d0 - build_script_build::inner::ICUConfig::version_major_int::h1b9b13b1b5b4c4c9
                                 at /Users/westy92/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_icu_sys-3.0.0/build.rs:228:16
    14:        0x1048415c7 - build_script_build::inner::copy_features::h9ab3c0b9d459a08f
                                 at /Users/westy92/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_icu_sys-3.0.0/build.rs:417:33
    15:        0x10484682d - build_script_build::main::h81193d2ae1af64df
                                 at /Users/westy92/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_icu_sys-3.0.0/build.rs:464:5
    16:        0x10483d07e - core::ops::function::FnOnce::call_once::h255f56527d8e4b98
                                 at /private/tmp/rust-20230331-7129-10kjp3b/rustc-1.68.2-src/library/core/src/ops/function.rs:250:5
    17:        0x104847c21 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3a549860eb82452b
                                 at /private/tmp/rust-20230331-7129-10kjp3b/rustc-1.68.2-src/library/std/src/sys_common/backtrace.rs:121:18
    18:        0x10483cb24 - std::rt::lang_start::{{closure}}::h3570684f4f3daa6c
                                 at /private/tmp/rust-20230331-7129-10kjp3b/rustc-1.68.2-src/library/std/src/rt.rs:166:18
    19:        0x104c82404 - std::rt::lang_start_internal::h2789a7315774cae2
    20:        0x10483caf7 - std::rt::lang_start::h81f91a3b4d4c9f85
                                 at /private/tmp/rust-20230331-7129-10kjp3b/rustc-1.68.2-src/library/std/src/rt.rs:165:17
    21:        0x1048469a8 - _main
    22:     0x7ff8103af41f - <unknown>

Relevant versions:

rust_icu version 3.0.0
rust version 1.68.2

Inspecting the original output from my icu4c install, I noticed:

/usr/local/bin/ginstall -c -m 644 ./config/icu-uc.pc ./config/icu-i18n.pc ./config/icu-io.pc /Users/westy92/local/lib/pkgconfig/

I then ran this command to see the issue:

% pkg-config --modversion icu-i18n                     
Package icu-i18n was not found in the pkg-config search path.
Perhaps you should add the directory containing `icu-i18n.pc'
to the PKG_CONFIG_PATH environment variable
No package 'icu-i18n' found

Using the path from the above install output:

% PKG_CONFIG_PATH="$HOME/local/lib/pkgconfig/" pkg-config --modversion icu-i18n
73.1

I was then able to run the following successfully:

% PKG_CONFIG_PATH="$HOME/local/lib/pkgconfig/" cargo run 
filmil commented

Yes, this is documented at https://github.com/google/rust_icu#cargo