rust-lang / rust-lang/git2-rs

Removing ssh dependency does not remove dependency on openssl{-sys}

Open
#812 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
450
Avg merge
11m
Merged PRs (30d)
1

Description

Via the README: https://github.com/rust-lang/git2-rs#building-on-osx-1010

If the ssh feature is enabled (and it is by default) then this library depends on libssh2 which depends on OpenSSL. To get OpenSSL working follow the openssl crate's instructions.

However disabling the feature only removes the dependency on openssh{-sys}. git2 still depends on openssl when the Cargo.toml only has the https feature:

git2 = { version = "0.13.25", default_features = false, features = [ "https" ] }

Reproducible example with git2 version: 0.13.25:
https://gitlab.com/DarrienG/git-sample2/-/blob/main/Cargo.lock#L99

Is this intended? Based on the README it looked like removing ssh should have removed the openssl dependency in its entirety.

I noticed this when intending to remove the openssl dependency in one of my larger projects:
https://gitlab.com/ttyperacer/terminal-typeracer/-/merge_requests/86

I can confirm there are still attempts to bind with the C library with an attempt to cross compile to Linux from macOS:

🜛 libgit-test [main] cargo zigbuild --target aarch64-unknown-linux-gnu
...
  --- stderr
  thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = aarch64-apple-darwin
  $TARGET = aarch64-unknown-linux-gnu
  openssl-sys = 0.9.72

  ', /Users/darrien/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.72/build/find_normal.rs:180:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

If it is intended that's ok, I just want to make sure I understand. It would be nice for me to remove another C dep though :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the README's macOS build guidance and inspect Cargo.toml feature definitions, then compare the generated Cargo.lock from the linked reproducible example. Determine whether the https-only feature is intended to retain openssl, and verify the dependency graph and documentation reflect the decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.