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

Dependency on system git command #9

Closed
rileyinman opened this issue Jul 25, 2019 · 4 comments
Closed

Dependency on system git command #9

rileyinman opened this issue Jul 25, 2019 · 4 comments

Comments

@rileyinman
Copy link

I was trying to build a project using cargo-deb in a minimal Docker container, and had to spend a while debugging why I couldn't get it to build. Eventually I tracked it down to the build.rs of this project, namely these few lines.

While depending on the user having git installed is usually a reasonable assumption, it might be a good idea to instead use something like git2 instead, since it's both something you can declare in Cargo.toml and more programmatic than calling a system command and unwrapping its return value. Thanks! :)

@BurntSushi
Copy link
Owner

This has an optional dependency on git. If the git command doesn't exist, then that code doesn't run. Otherwise, you should be able to either build this library with the system installation of PCRE2, or by providing the full repository contents in order to build.

@rileyinman
Copy link
Author

rileyinman commented Jul 25, 2019

That's really odd, I have libpcre2-dev installed (which provides libpcre2-8) and the build does fail without git... maybe the problem is something else? Here's a backtrace from a fresh rebuild in that environment:

error: failed to run custom build command for `pcre2-sys v0.2.0`
process didn't exit successfully: `/usr/src/ripgrep/target/release/build/pcre2-sys-f7ab5c38ecf7d723/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=PCRE2_SYS_STATIC

--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:997:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
             at /usr/src/rustc-1.34.2/src/libcore/macros.rs:17
   9: build_script_build::main
             at /usr/src/rustc-1.34.2/src/libcore/result.rs:798
             at ./build.rs:75
  10: std::rt::lang_start::{{closure}}
             at /usr/src/rustc-1.34.2/src/libstd/rt.rs:64
  11: std::panicking::try::do_call
  12: __rust_maybe_catch_panic
  13: std::rt::lang_start_internal
  14: main
  15: __libc_start_main
  16: _start

warning: build failed, waiting for other jobs to finish...
error: build failed
cargo-deb: build failed

Sorry in advance if I'm being dumb about something here :P

Edit: This is with rustc 1.34.2 and cargo 1.34.0 if that's important

@BurntSushi
Copy link
Owner

Hmm, not sure. As long as you aren't specifically requesting a static build, then pkg-config should run on this line. So I don't quite understand why your build script is even making it to the git command. Moreover, the git command is only run when has_git returns true, which should only occur when git is installed.

It looks like you'll need to do some debugging unfortunately. Maybe insert some print statements into the build script.

@rileyinman
Copy link
Author

rileyinman commented Jul 25, 2019

It looks like the problem was a combo of a few things. The project I'm building is ripgrep, which has its own build_deb.sh wrapper around cargo deb (to make sure manpages and completion get installed). What I didn't realise is that the script also sets PCRE2_SYS_STATIC=1 because it doesn't assume the user has pcre2 installed. Calling cargo deb without it set also failed, but because I didn't have pkg-config installed 🤦‍♀️ It looks like someone opened a related issue on the pkg_config crate over a year ago that hasn't been fixed, and the error that actually mentions pkg-config by name doesn't propagate for some reason.

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