I tried cargo doc --run and it doesn't load the docs properly.
Related
I have this in a Cargo.toml
rdkafka = { version = "0.29.0", features = [ "ssl", "cmake-build"] }
I tried to compile to x86_64-unknown-linux-musl using 2 options. Both failed.
cargo build --target x86_64-unknown-linux-musl --release
OUTPUT:
linking with cc failed: exit status: 1
rdkafka_ssl.c:(.text.rd_kafka_ssl_ctx_term+0x2b): undefined reference to `ENGINE_free'
collect2: error: ld returned 1 exit status
cross build --target=x86_64-unknown-linux-musl --release
OUTPUT:
rdkafka_ssl.c:(.text.rd_kafka_ssl_ctx_term+0x2b): undefined reference to `ENGINE_free'
collect2: error: ld returned 1 exit status
They both give the same error.
Does anyone know how to fix this? Or can someone try this on their machine.. I'd really appreciate it.
I expected the build to pass.
POST
I have added github repo and recreated the issue. It uses Dockerfile
https://github.com/0xDjole/rust-rdkafka-musl
To test just docker build -t muslkafka .
Here is the screenshot of the issue
I am able to build a rust crate depending on rdkafka on x86_64-unknown-linux-musl by disabling the cmake-build feature flag and using the following Dockerfile:
FROM clux/muslrust:1.63.0 AS chef
RUN cargo install cargo-chef --locked
RUN ln -s /usr/bin/musl-gcc /usr/bin/musl-g++
WORKDIR /usr/src/foo
FROM chef AS planner
COPY . .
RUN cargo chef prepare
FROM chef AS builder
COPY --from=planner /usr/src/foo/recipe.json recipe.json
RUN cargo chef cook --release
COPY . .
RUN cargo build --release \
&& strip --strip-debug target/*/release/foo \
&& cp target/*/release/foo /usr/local/bin/
FROM alpine as final
COPY --from=builder /usr/local/bin/foo /usr/local/bin
ENTRYPOINT ["/usr/local/bin/foo"]
(I'm somewhat surprised to see that this does seem to work with the ssl feature and produces a statically linked binary, I hadn't tested this before and openssl is notorious for being "difficult". I can't test right now whether said binary also actually works, so… please test.)
I am studying the following code and cannot wrap my head around why cargo run --example abigen wouldn't work. The docs state that package has to be specified like so cargo run -p ethers --example abigen. Indeed, this fixes the issue. But according to Rust docs, I should be able to use the first version. Why doesn't this first version work?
According to doc.rust-lang.org
cargo rustdoc
build[s] a package's documentation, using specified custom flags
cargo doc
build[s] a package's documentation
What is the difference between the two? From what I understand cargo rustdoc is just like cargo doc, but it allows for more lints—for instance:
#![deny(rustdoc::broken_intra_doc_links)]
Is this correct? Oddly enough, cargo rustdoc will also fail in certain situations where cargo doc doesn't. For instance
some/folder on some-branch [$!] via 🦀 v1.60.0-nightly
❯ cargo doc
Finished dev [unoptimized + debuginfo] target(s) in 0.53s
some/folder on some-branch [$!] via 🦀 v1.60.0-nightly
❯ cargo rustdoc
error: manifest path `some/folder/Cargo.toml` is a virtual manifest, but this command requires running against an actual package in this workspace
Also, cargo doc does not support adding the -D option, whereas cargo rustdoc does.
❯ cargo doc -- -D rustdoc::broken_intra_doc_links
error: Found argument '-D' which wasn't expected, or isn't valid in this context
USAGE:
cargo doc [OPTIONS]
For more information try --help
Their relationship is like between cargo build and cargo rustc: cargo doc performs all the usual work, for an entire workspace, including dependencies (by default). cargo rustdoc allows you to pass flags directly to rustdoc, and only works for a single crate.
Here is the execution code for cargo rustdoc. Here is the code for cargo doc. The only differences is that cargo rustdoc always specify to not check dependencies while cargo doc allows you to choose (by default it does, but you can specify the flag --no-deps), and that cargo rustc allows you to pass flags directly to rustdoc with the flags after the --.
The instructions to build rust-analyzer say to run this command:
cargo install-ra
It works, but how? It's not an official command and it isn't in cargo --list or Cargo.toml.
The repository in question contains a custom local Cargo configuration file in ".cargo/config". In this case, it defines a bunch of aliases, including install-ra:
[alias]
# Installs the visual studio code extension
install-ra = "run --package ra_tools --bin ra_tools -- install-ra"
install-code = "run --package ra_tools --bin ra_tools -- install-ra" # just an alias
See also:
Where can I find .cargo/config?
I'm trying to run the example code from this project. Following the instructions on the Cargo docs, I did the following:
git clone https://github.com/basiliscos/rust-procol-ftp-client
cd rust-procol-ftp-client
cargo run
cargo test
cargo test should also have compiled the example according to the Rust docs.
Although cargo test executes successfully, when I change into the target/debug directory, I don't find an executable for ftp-get (which is the example code). The target/debug/examples directory is also empty.
What is the best way to go about running this example?
You can run a specific example with:
cargo run --example name_of_example
where name_of_example is the base filename (without .rs)
or to run it in release mode:
cargo run --release --example name_of_example
To pass arguments to the example:
cargo run --example name_of_example -- arguments go here
cargo run will automatically build (or rebuild) the program first if it's out of date.
Try the following:
cd rust-procol-ftp-client
cargo build --examples
./target/debug/examples/ftp-get