signalapp / libsignal

Home to the Signal Protocol as well as other cryptographic primitives which make Signal possible.
GNU Affero General Public License v3.0
3.08k stars 362 forks source link

Failure at cargo build in README.md instuctions #441

Closed umop closed 1 year ago

umop commented 2 years ago

While following the instructions in https://github.com/signalapp/libsignal-client#building, the Building step says to

The build currently uses a specific version of the Rust nightly compiler, which will be downloaded automatically by cargo. To build and test the basic protocol libraries:

$ cargo build
...
$ cargo test
...

But doing so causes the following error:

error[E0658]: use of unstable library feature 'proc_macro_is_available'
  --> /Users/ericarnold/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.36/src/detection.rs:28:21
   |
28 |     let available = proc_macro::is_available();
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71436 <https://github.com/rust-lang/rust/issues/71436> for more information
   = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
ERROR: cargo failed

Thus, the dependency of the required nightly Rust build does not allow for building of libsignal-client

jrose-signal commented 2 years ago

Hm, that doesn't sound like it's using the lockfile, even if it is using the standard nightly. Where are you running this command? Just the root directory of the repository?

umop commented 2 years ago

Yep. Just in ~/projects/Signal/libsignal-client/node

umop commented 2 years ago

While running using yarn install from these instructions

umop commented 2 years ago

So I guess no. Not the root, but ./node. Is it possible this is an issue with being in the ./node directory and I should have run cargo build / cargo test from the root?

jrose-signal commented 2 years ago

I wouldn't expect so, that's not a problem for me when I test locally. Let's find out, though: what does happen when you cargo build from the root? And for good measure, what does cargo --version give you?

umop commented 2 years ago

Yep. It's the same.

% cargo --version
cargo 1.56.0-nightly (e515c3277 2021-09-08)
% pwd
/Users/ericarnold/projects/Signal/libsignal-client
% cargo build
   Compiling proc-macro2 v1.0.36
   Compiling num-traits v0.2.14
   Compiling cipher v0.3.0
   Compiling universal-hash v0.4.1
   Compiling crypto-mac v0.11.1
   Compiling aead v0.4.3
   Compiling petgraph v0.6.0
   Compiling sha2 v0.9.9
error[E0658]: use of unstable library feature 'proc_macro_is_available'
  --> /Users/ericarnold/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.36/src/detection.rs:28:21
   |
28 |     let available = proc_macro::is_available();
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71436 <https://github.com/rust-lang/rust/issues/71436> for more information
   = help: add `#![feature(proc_macro_is_available)]` to the crate attributes to enable
   Compiling regex v1.5.4
   Compiling sha-1 v0.9.8
   Compiling sha3 v0.9.1
For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
% _
jrose-signal commented 2 years ago

All right, this does show that the lockfile isn't being honored (or got updated implicitly), because sha2 also got bumped. Next check: if you redownload (or git reset --hard if you git-cloned) and run cargo check --locked, what happens?

umop commented 2 years ago

Thanks! Closer this time:

% pwd
/Users/ericarnold/projects/Signal/libsignal-client
% git reset --hard
HEAD is now at a2bc7c0 Merge pull request #436 from ZabeMath/patch-1
% cargo check --locked
  Downloaded tempfile v3.2.0
...
    Checking device-transfer v0.1.0 (/Users/ericarnold/projects/Signal/libsignal-client/rust/device-transfer)
    Finished dev [unoptimized + debuginfo] target(s) in 15.56s
% cargo build         
   Compiling smallvec v1.7.0
...
   Compiling chrono v0.4.19
error: failed to run custom build command for `openssl-sys v0.9.67`

Caused by:
  process didn't exit successfully: `/Users/ericarnold/projects/Signal/libsignal-client/target/debug/build/openssl-sys-1c85ad0dd546d0d5/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR
  AARCH64_APPLE_DARWIN_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR
  AARCH64_APPLE_DARWIN_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=AARCH64_APPLE_DARWIN_OPENSSL_DIR
  AARCH64_APPLE_DARWIN_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-darwin
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_darwin
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: "Failed to run `\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"`: No such file or directory (os error 2)"

  --- 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-apple-darwin
  openssl-sys = 0.9.67

  ', /Users/ericarnold/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.67/build/find_normal.rs:174: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
% _
umop commented 2 years ago

Ah. Didn't see that it's a SSL config issue this time.

jrose-signal commented 2 years ago

The default workspace includes some crates that don't build on M1 Macs right now, but that's okay. The thing we discovered here is that something modified the lockfile (I guess git diff would have said that too). What I don't understand is why. cargo build / cargo check will modify the lockfile if you've changed Cargo.toml in an incompatible way, but it shouldn't otherwise. (And yarn install does just end up calling cargo build.)

umop commented 2 years ago

Gotcha. And for openssl, it is installed and I tried setting OPENSSL_DIR to $(which openssl), but I still get the above. Is there a step I'm missing?

umop commented 2 years ago

Even though I had it installed, running brew install openssl@1.1 resolved the above. Perhaps needs to be added to the instructions.

jrose-signal commented 2 years ago

It looks like this is the relevant line from that:

run pkg_config fail: "Failed to run \"pkg-config\" \"--libs\" \"--cflags\" \"openssl\": No such file or directory (os error 2)"

i.e. openssl-sys needs pkg-config installed as well (brew install pkg-config if you're using Homebrew). I'll add that to the build instructions later, but for now I'm still interested in why your lockfile is getting modified.

umop commented 2 years ago

Sure. What can I do to help troubleshoot that?

umop commented 2 years ago

@jrose-signal side-note: I have a general question about how to use this library (or if I should be using it at all for my project), but I'm not sure how to do so on GitHub. Should I open a new issue for that, or is there a general forum for these kinds of questions?

jrose-signal commented 2 years ago

Sure. What can I do to help troubleshoot that?

I'm still trying to figure that out myself. :-/ Maybe I'll see if I can replicate in a VM that's never touched Rust before.

I have a general question about how to use this library (or if I should be using it at all for my project), but I'm not sure how to do so on GitHub. Should I open a new issue for that, or is there a general forum for these kinds of questions?

The Development section of the unofficial forums https://community.signalusers.org/ is probably the best place (though it'll just be me responding again).

jrose-signal commented 1 year ago

We never managed to track this down but no one else has reported it or reacted to this issue, so I'm going to close it.