2

I'm unable to compile a basic example using Actix. I suspect I might be missing some libraries but I have no clue of what it could be. I also upgraded to Mojave a few days ago, but I'm not sure if this is related.

It seems to complain about ar crs and about an internal error happening in ranlib when running this command.

main.rs:

extern crate actix_web;
use actix_web::{server, App, HttpRequest};

fn index(_req: &HttpRequest) -> &'static str {
    "Hello world!"
}

fn main() {
    server::new(|| App::new().resource("/", |r| r.f(index)))
        .bind("127.0.0.1:8088")
        .unwrap()
        .run();
}

Cargo.toml:

actix-web = "0.7.8"

Backtrace I obtain:

    mbp-de-matthieu:hello-world matthieu$ RUST_BACKTRACE=1 cargo build
   Compiling backtrace-sys v0.1.24                                                                                                                                                                     
   Compiling miniz-sys v0.1.10
   Compiling brotli-sys v0.3.2
   Compiling ring v0.13.2
   Compiling tokio-current-thread v0.1.3
error: failed to run custom build command for `miniz-sys v0.1.10`
process didn't exit successfully: `/Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-dc81523acb01e9e7/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("true")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-o" "/Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-d59b36acd5b3db67/out/miniz.o" "-c" "miniz.c"
exit code: 0
AR_x86_64-apple-darwin = None
AR_x86_64_apple_darwin = None
HOST_AR = None
AR = None
running: "ar" "crs" "/Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-d59b36acd5b3db67/out/libminiz.a" "/Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-d59b36acd5b3db67/out/miniz.o"
cargo:warning=/usr/local/Cellar/cctools/855/bin/ranlib: object: /Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-d59b36acd5b3db67/out/libminiz.a(miniz.o) malformed object (unknown load command 1)
cargo:warning=ar: internal ranlib command failed
exit code: 1

--- stderr
thread 'main' panicked at '

Internal error occurred: Command "ar" "crs" "/Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-d59b36acd5b3db67/out/libminiz.a" "/Users/matthieu/Documents/Rust/actix/hello-world/target/debug/build/miniz-sys-d59b36acd5b3db67/out/miniz.o" with args "ar" did not execute successfully (status code exit code: 1).

The complete backtrace is too large to include on Stack Overflow.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Matt
  • 41
  • 1
  • 2
  • [Update your Xcode and associated Command Line Tools](https://stackoverflow.com/q/10390186/155423). – Shepmaster Oct 13 '18 at 15:55
  • I already tried installing it twice along with Xcode and I still get the error (using xcode-select --install and by downloading it from the Apple Developper website). – Matt Oct 13 '18 at 17:25
  • Did you attempt compiling this before upgrading to Mojave? Does `cargo clean` before building help? – Shepmaster Oct 13 '18 at 22:36
  • I didn't compile this before upgrading to Mojave, but I never saw an issue like this one with other crates in my projects. I also tried compiling an old project on Mojave that was compiling before and it looks fine as well. I tried using `cargo clean` before as well and the error still show up. – Matt Oct 14 '18 at 09:28

2 Answers2

2

It seems to work after installing cctools through MacPorts.

For some reason, installing it through brew didn't seem to work.

Matt
  • 41
  • 1
  • 2
2

I had the same error.

When I replaced cctools 855 with 921 from this tap then cargo build worked: https://github.com/dgsga/homebrew-cctools

brew unlink cctools
brew tap dgsga/cctools
brew install dgsga/cctools/mtoc

Mojave 10.14.3, Rust 1.33.0, actix-web 0.7.18

fey
  • 1,289
  • 1
  • 10
  • 20