Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

RLS fails to build with cbindgen in build.rs #586

Open
str4d opened this issue May 8, 2019 · 0 comments
Open

RLS fails to build with cbindgen in build.rs #586

str4d opened this issue May 8, 2019 · 0 comments

Comments

@str4d
Copy link

str4d commented May 8, 2019

Cargo.toml:

[package]
name = "libfoo"
version = "0.0.1"
edition = "2018"
build = "rust/build.rs"

[build-dependencies]
cbindgen = "0.8"

[lib]
name = "foo"
path = "rust/src/lib.rs"
crate-type = ["staticlib"]

build.rs:

extern crate cbindgen;

use std::env;

fn main() {
    let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

    cbindgen::Builder::new()
        .with_crate(crate_dir)
        .with_language(cbindgen::Language::C)
        .generate()
        .expect("Unable to generate bindings")
        .write_to_file("foo.h");
}

Building via the command-line, this works fine. But when opening the crate in VSCode, the Cargo.toml is annotated with a build error:

failed to run custom build command for `libfoo v0.1.0 (C:\Users\me\Documents\dev\rust\libfoo)`
process didn't exit successfully: `c:\Users\me\Documents\dev\rust\libfoo\target\rls\debug\build\libfoo-d3abfb7100f32bd4\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to generate bindings: CargoMetadata("c:\\Users\\me\\Documents\\dev\\rust\\libfoo\\Cargo.toml", Metadata(Output { status: ExitStatus(ExitStatus(101)), stdout: "Unknown argument \'metadata\'. Supported arguments:\n\n    --version or -V to print the version and commit info\n    --help or -h for this message\n    --cli starts the RLS in command line mode\n    No input starts the RLS as a language server\n    \n", stderr: "" }))', src\libcore\result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

I believe this is being triggered by the following code from cbindgen:

https://github.com/eqrion/cbindgen/blob/5ec5a82d268c8fe907767394ee7ad15718f3f09d/src/bindgen/cargo/cargo_metadata.rs#L181-L197

What I don't know is whether this is a problem with rls or rls-vscode exposing cargo metadata, or a problem with cbindgen assuming how to access it.

Plailect added a commit to Bram-Hub/aris-java that referenced this issue Mar 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant