Closed NickeZ closed 7 years ago
It presumably needs some work to make this work. Perhaps passing a bin
flag to Cargo? I'm not sure exactly how this should be solved, but I would expect it should be fairly straightforward. If you want to give it a go and need any help, please let me know.
Sure, I can have a go at it. I'm new at rust though. So it seems that the crate in question, alacritty, has both a library which you can build with cargo build --lib
and a binary which you can build with cargo build --bin alacritty
or simply cargo build
. Is this confusing RLS somehow?
How to reproduce this:
Some logging output of rls
Finished release [optimized] target(s) in 0.1 secs
Running `/home/niklas/git/rls/target/release/rls`
TRACE:rls::build: cargo - `"/home/niklas/git/alacritty"`
TRACE:rls::build: cargo stdout
TRACE:rls::build: cargo stderr
TRACE:rls::build: intercepted rustc, args: ["--crate-name", "alacritty", "src/lib.rs", "--color", "never", "--crate-type", "lib", "--emit=dep-info,metadata", "-C", "debuginfo=2", "--cfg", "feature=\"err-println\"", "--cfg", "feature=\"default\"", "-C", "metadata=d3d505b18634dd27", "-C", "extra-filename=-d3d505b18634dd27", "--out-dir", "/home/niklas/git/alacritty/target/rls/debug/deps", "-L", "dependency=/home/niklas/git/alacritty/target/rls/debug/deps", "--extern", "lazy_static=/home/niklas/git/alacritty/target/rls/debug/deps/liblazy_static-420a8b42080490f8.rmeta", "--extern", "mio=/home/niklas/git/alacritty/target/rls/debug/deps/libmio-ebe23e0b68171c4d.rmeta", "--extern", "serde_json=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_json-5fcb56b050146211.rmeta", "--extern", "serde_derive=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_derive-f4e8643331fdee83.so", "--extern", "bitflags=/home/niklas/git/alacritty/target/rls/debug/deps/libbitflags-7c974e68a96277e2.rmeta", "--extern", "serde=/home/niklas/git/alacritty/target/rls/debug/deps/libserde-5b79093c8616112c.rmeta", "--extern", "clap=/home/niklas/git/alacritty/target/rls/debug/deps/libclap-37b7929d799bcf09.rmeta", "--extern", "cgmath=/home/niklas/git/alacritty/target/rls/debug/deps/libcgmath-8b1c0ebe2a840abf.rmeta", "--extern", "serde_yaml=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_yaml-8a2fcba17def6789.rmeta", "--extern", "libc=/home/niklas/git/alacritty/target/rls/debug/deps/liblibc-77bdd8b6ec347efe.rmeta", "--extern", "copypasta=/home/niklas/git/alacritty/target/rls/debug/deps/libcopypasta-c67c899180ab9bf3.rmeta", "--extern", "font=/home/niklas/git/alacritty/target/rls/debug/deps/libfont-c788a94eae849a82.rmeta", "--extern", "vte=/home/niklas/git/alacritty/target/rls/debug/deps/libvte-cf27bf42dd089d36.rmeta", "--extern", "glutin=/home/niklas/git/alacritty/target/rls/debug/deps/libglutin-350e0469ca7bbaa3.rmeta", "--extern", "parking_lot=/home/niklas/git/alacritty/target/rls/debug/deps/libparking_lot-c02586216ef83a5d.rmeta", "--extern", "notify=/home/niklas/git/alacritty/target/rls/debug/deps/libnotify-3449d4dd649e305e.rmeta", "--extern", "errno=/home/niklas/git/alacritty/target/rls/debug/deps/liberrno-2d3e691bb62d0131.rmeta", "--extern", "fnv=/home/niklas/git/alacritty/target/rls/debug/deps/libfnv-6a0b58d177428f69.rmeta", "--extern", "xdg=/home/niklas/git/alacritty/target/rls/debug/deps/libxdg-9ec362206e83f9a3.rmeta", "--extern", "unicode_width=/home/niklas/git/alacritty/target/rls/debug/deps/libunicode_width-889e75680f95fe8f.rmeta", "--extern", "log=/home/niklas/git/alacritty/target/rls/debug/deps/liblog-3587c71b69879424.rmeta", "-Zunstable-options", "-Zsave-analysis", "--error-format=json", "-Zcontinue-parse-after-error", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu"]
{"message":"couldn't read /home/niklas/git/rls/res/text.f.glsl: No such file or directory (os error 2)","code":null,"level":"error","spans":[{"file_name":"src/renderer/mod.rs","byte_start":197227,"byte_end":197302,"line_start":42,"line_end":44,"column_start":38,"column_end":2,"is_primary":true,"text":[{"text":"static TEXT_SHADER_F: &'static str = include_str!(","highlight_start":38,"highlight_end":51},{"text":" concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/res/text.f.glsl\")","highlight_start":1,"highlight_end":60},{"text":");","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
{"message":"couldn't read /home/niklas/git/rls/res/text.v.glsl: No such file or directory (os error 2)","code":null,"level":"error","spans":[{"file_name":"src/renderer/mod.rs","byte_start":197341,"byte_end":197416,"line_start":45,"line_end":47,"column_start":38,"column_end":2,"is_primary":true,"text":[{"text":"static TEXT_SHADER_V: &'static str = include_str!(","highlight_start":38,"highlight_end":51},{"text":" concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/res/text.v.glsl\")","highlight_start":1,"highlight_end":60},{"text":");","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
{"message":"environment variable `OUT_DIR` not defined","code":null,"level":"error","spans":[{"file_name":"src/lib.rs","byte_start":2244,"byte_end":2259,"line_start":83,"line_end":83,"column_start":22,"column_end":37,"is_primary":true,"text":[{"text":" include!(concat!(env!(\"OUT_DIR\"), \"/gl_bindings.rs\"));","highlight_start":22,"highlight_end":37}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
{"message":"couldn't read \"src/0/gl_bindings.rs\": No such file or directory (os error 2)","code":null,"level":"error","spans":[{"file_name":"src/lib.rs","byte_start":2227,"byte_end":2281,"line_start":83,"line_end":83,"column_start":5,"column_end":59,"is_primary":true,"text":[{"text":" include!(concat!(env!(\"OUT_DIR\"), \"/gl_bindings.rs\"));","highlight_start":5,"highlight_end":59}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
TRACE:rls::build: envs: {"CARGO_MANIFEST_DIR": Some("/home/niklas/git/alacritty"), "CARGO_PKG_VERSION_MAJOR": Some("0"), "CARGO_PKG_DESCRIPTION": Some("GPU-accelerated terminal emulator"), "OUT_DIR": Some("/home/niklas/git/alacritty/target/rls/debug/build/alacritty-c7d05bf891cdd205/out"), "CARGO_PKG_VERSION_PATCH": Some("0"), "CARGO_PKG_VERSION_PRE": Some(""), "CARGO_PKG_VERSION": Some("0.1.0"), "CARGO_PKG_NAME": Some("alacritty"), "CARGO_PKG_VERSION_MINOR": Some("1"), "CARGO_PKG_HOMEPAGE": Some(""), "CARGO_PKG_AUTHORS": Some("Joe Wilm <joe@jwilm.com>"), "LD_LIBRARY_PATH": Some("/home/niklas/git/alacritty/target/rls/debug/deps:/home/niklas/git/rls/target/release/build/libgit2-sys-459b0bc6c3aba77d/out/lib:/home/niklas/git/rls/target/release/build/miniz-sys-18005000ddedadf4/out:/home/niklas/git/rls/target/release:/home/niklas/git/rls/target/release/deps:/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib")}
TRACE:rls::build: intercepted rustc, args: ["--crate-name", "alacritty", "src/main.rs", "--color", "never", "--crate-type", "bin", "--emit=dep-info,metadata", "-C", "debuginfo=2", "--cfg", "feature=\"err-println\"", "--cfg", "feature=\"default\"", "-C", "metadata=a9c82401f1d08fc3", "-C", "extra-filename=-a9c82401f1d08fc3", "--out-dir", "/home/niklas/git/alacritty/target/rls/debug/deps", "-L", "dependency=/home/niklas/git/alacritty/target/rls/debug/deps", "--extern", "lazy_static=/home/niklas/git/alacritty/target/rls/debug/deps/liblazy_static-420a8b42080490f8.rmeta", "--extern", "mio=/home/niklas/git/alacritty/target/rls/debug/deps/libmio-ebe23e0b68171c4d.rmeta", "--extern", "serde_json=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_json-5fcb56b050146211.rmeta", "--extern", "serde_derive=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_derive-f4e8643331fdee83.so", "--extern", "bitflags=/home/niklas/git/alacritty/target/rls/debug/deps/libbitflags-7c974e68a96277e2.rmeta", "--extern", "serde=/home/niklas/git/alacritty/target/rls/debug/deps/libserde-5b79093c8616112c.rmeta", "--extern", "clap=/home/niklas/git/alacritty/target/rls/debug/deps/libclap-37b7929d799bcf09.rmeta", "--extern", "cgmath=/home/niklas/git/alacritty/target/rls/debug/deps/libcgmath-8b1c0ebe2a840abf.rmeta", "--extern", "serde_yaml=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_yaml-8a2fcba17def6789.rmeta", "--extern", "libc=/home/niklas/git/alacritty/target/rls/debug/deps/liblibc-77bdd8b6ec347efe.rmeta", "--extern", "copypasta=/home/niklas/git/alacritty/target/rls/debug/deps/libcopypasta-c67c899180ab9bf3.rmeta", "--extern", "font=/home/niklas/git/alacritty/target/rls/debug/deps/libfont-c788a94eae849a82.rmeta", "--extern", "vte=/home/niklas/git/alacritty/target/rls/debug/deps/libvte-cf27bf42dd089d36.rmeta", "--extern", "glutin=/home/niklas/git/alacritty/target/rls/debug/deps/libglutin-350e0469ca7bbaa3.rmeta", "--extern", "parking_lot=/home/niklas/git/alacritty/target/rls/debug/deps/libparking_lot-c02586216ef83a5d.rmeta", "--extern", "notify=/home/niklas/git/alacritty/target/rls/debug/deps/libnotify-3449d4dd649e305e.rmeta", "--extern", "errno=/home/niklas/git/alacritty/target/rls/debug/deps/liberrno-2d3e691bb62d0131.rmeta", "--extern", "fnv=/home/niklas/git/alacritty/target/rls/debug/deps/libfnv-6a0b58d177428f69.rmeta", "--extern", "xdg=/home/niklas/git/alacritty/target/rls/debug/deps/libxdg-9ec362206e83f9a3.rmeta", "--extern", "unicode_width=/home/niklas/git/alacritty/target/rls/debug/deps/libunicode_width-889e75680f95fe8f.rmeta", "--extern", "log=/home/niklas/git/alacritty/target/rls/debug/deps/liblog-3587c71b69879424.rmeta", "--extern", "alacritty=/home/niklas/git/alacritty/target/rls/debug/deps/libalacritty-d3d505b18634dd27.rmeta", "-Zunstable-options", "-Zsave-analysis", "--error-format=json", "-Zcontinue-parse-after-error", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu"]
{"message":"extern location for alacritty does not exist: /home/niklas/git/alacritty/target/rls/debug/deps/libalacritty-d3d505b18634dd27.rmeta","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"extern location for alacritty does not exist: /home/niklas/git/alacritty/target/rls/debug/deps/libalacritty-d3d505b18634dd27.rmeta","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"can't find crate for `alacritty`","code":{"code":"E0463","explanation":"\nA plugin/crate was declared but cannot be found. Erroneous code example:\n\n```compile_fail,E0463\n#![feature(plugin)]\n#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`\nextern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`\n```\n\nYou need to link your code to the relevant crate in order to be able to use it\n(through Cargo or the `-L` option of rustc example). Plugins are crates as\nwell, and you link to them the same way.\n"},"level":"error","spans":[{"file_name":"src/main.rs","byte_start":779,"byte_end":802,"line_start":20,"line_end":20,"column_start":1,"column_end":24,"is_primary":true,"text":[{"text":"extern crate alacritty;","highlight_start":1,"highlight_end":24}],"label":"can't find crate","suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
{"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":null}
TRACE:rls::build: envs: {"CARGO_PKG_HOMEPAGE": Some(""), "OUT_DIR": Some("/home/niklas/git/alacritty/target/rls/debug/build/alacritty-c7d05bf891cdd205/out"), "LD_LIBRARY_PATH": Some("/home/niklas/git/alacritty/target/rls/debug/deps:/home/niklas/git/rls/target/release/build/libgit2-sys-459b0bc6c3aba77d/out/lib:/home/niklas/git/rls/target/release/build/miniz-sys-18005000ddedadf4/out:/home/niklas/git/rls/target/release:/home/niklas/git/rls/target/release/deps:/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"), "CARGO_PKG_VERSION_MINOR": Some("1"), "CARGO_PKG_VERSION_MAJOR": Some("0"), "CARGO_PKG_VERSION": Some("0.1.0"), "CARGO_MANIFEST_DIR": Some("/home/niklas/git/alacritty"), "CARGO_PKG_VERSION_PATCH": Some("0"), "CARGO_PKG_AUTHORS": Some("Joe Wilm <joe@jwilm.com>"), "CARGO_PKG_DESCRIPTION": Some("GPU-accelerated terminal emulator"), "CARGO_PKG_VERSION_PRE": Some(""), "CARGO_PKG_NAME": Some("alacritty")}
thread '<unnamed>' panicked at 'could not run cargo: ChainedError { error: failed to stat `/home/niklas/git/alacritty/target/rls/debug/.fingerprint/alacritty-a9c82401f1d08fc3/dep-bin-alacritty-a9c82401f1d08fc3`, cause: Error { repr: Os { code: 2, message: "No such file or directory" } } }', /checkout/src/libcore/result.rs:860
note: Run with `RUST_BACKTRACE=1` for a backtrace.
TRACE:rls::build: rustc - args: `["rustc", "--crate-name", "alacritty", "src/main.rs", "--color", "never", "--crate-type", "bin", "--emit=dep-info,metadata", "-C", "debuginfo=2", "--cfg", "feature=\"err-println\"", "--cfg", "feature=\"default\"", "-C", "metadata=a9c82401f1d08fc3", "-C", "extra-filename=-a9c82401f1d08fc3", "--out-dir", "/home/niklas/git/alacritty/target/rls/debug/deps", "-L", "dependency=/home/niklas/git/alacritty/target/rls/debug/deps", "--extern", "lazy_static=/home/niklas/git/alacritty/target/rls/debug/deps/liblazy_static-420a8b42080490f8.rmeta", "--extern", "mio=/home/niklas/git/alacritty/target/rls/debug/deps/libmio-ebe23e0b68171c4d.rmeta", "--extern", "serde_json=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_json-5fcb56b050146211.rmeta", "--extern", "serde_derive=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_derive-f4e8643331fdee83.so", "--extern", "bitflags=/home/niklas/git/alacritty/target/rls/debug/deps/libbitflags-7c974e68a96277e2.rmeta", "--extern", "serde=/home/niklas/git/alacritty/target/rls/debug/deps/libserde-5b79093c8616112c.rmeta", "--extern", "clap=/home/niklas/git/alacritty/target/rls/debug/deps/libclap-37b7929d799bcf09.rmeta", "--extern", "cgmath=/home/niklas/git/alacritty/target/rls/debug/deps/libcgmath-8b1c0ebe2a840abf.rmeta", "--extern", "serde_yaml=/home/niklas/git/alacritty/target/rls/debug/deps/libserde_yaml-8a2fcba17def6789.rmeta", "--extern", "libc=/home/niklas/git/alacritty/target/rls/debug/deps/liblibc-77bdd8b6ec347efe.rmeta", "--extern", "copypasta=/home/niklas/git/alacritty/target/rls/debug/deps/libcopypasta-c67c899180ab9bf3.rmeta", "--extern", "font=/home/niklas/git/alacritty/target/rls/debug/deps/libfont-c788a94eae849a82.rmeta", "--extern", "vte=/home/niklas/git/alacritty/target/rls/debug/deps/libvte-cf27bf42dd089d36.rmeta", "--extern", "glutin=/home/niklas/git/alacritty/target/rls/debug/deps/libglutin-350e0469ca7bbaa3.rmeta", "--extern", "parking_lot=/home/niklas/git/alacritty/target/rls/debug/deps/libparking_lot-c02586216ef83a5d.rmeta", "--extern", "notify=/home/niklas/git/alacritty/target/rls/debug/deps/libnotify-3449d4dd649e305e.rmeta", "--extern", "errno=/home/niklas/git/alacritty/target/rls/debug/deps/liberrno-2d3e691bb62d0131.rmeta", "--extern", "fnv=/home/niklas/git/alacritty/target/rls/debug/deps/libfnv-6a0b58d177428f69.rmeta", "--extern", "xdg=/home/niklas/git/alacritty/target/rls/debug/deps/libxdg-9ec362206e83f9a3.rmeta", "--extern", "unicode_width=/home/niklas/git/alacritty/target/rls/debug/deps/libunicode_width-889e75680f95fe8f.rmeta", "--extern", "log=/home/niklas/git/alacritty/target/rls/debug/deps/liblog-3587c71b69879424.rmeta", "--extern", "alacritty=/home/niklas/git/alacritty/target/rls/debug/deps/libalacritty-d3d505b18634dd27.rmeta", "-Zunstable-options", "-Zsave-analysis", "--error-format=json", "-Zcontinue-parse-after-error", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "-L", "native=/usr/lib/x86_64-linux-gnu", "--test", "--sysroot", "/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu"]`, envs: {"CARGO_PKG_HOMEPAGE": Some(""), "OUT_DIR": Some("/home/niklas/git/alacritty/target/rls/debug/build/alacritty-c7d05bf891cdd205/out"), "LD_LIBRARY_PATH": Some("/home/niklas/git/alacritty/target/rls/debug/deps:/home/niklas/git/rls/target/release/build/libgit2-sys-459b0bc6c3aba77d/out/lib:/home/niklas/git/rls/target/release/build/miniz-sys-18005000ddedadf4/out:/home/niklas/git/rls/target/release:/home/niklas/git/rls/target/release/deps:/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib:/home/niklas/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"), "CARGO_PKG_VERSION_MINOR": Some("1"), "CARGO_PKG_VERSION_MAJOR": Some("0"), "CARGO_PKG_VERSION": Some("0.1.0"), "CARGO_MANIFEST_DIR": Some("/home/niklas/git/alacritty"), "CARGO_PKG_VERSION_PATCH": Some("0"), "CARGO_PKG_AUTHORS": Some("Joe Wilm <joe@jwilm.com>"), "CARGO_PKG_DESCRIPTION": Some("GPU-accelerated terminal emulator"), "CARGO_PKG_VERSION_PRE": Some(""), "CARGO_PKG_NAME": Some("alacritty")}, build dir: "/home/niklas/git/alacritty"
Sure, I can have a go at it. I'm new at rust though.
Awesome! Feel free to ping me on irc in #rust-tools with either Rust or RLS questions (although the folk in #rust are also very helpful for Rust questions and might be quicker to respond than I am).
So it seems that the crate in question, alacritty, has both a library which you can build with cargo build --lib and a binary which you can build with cargo build --bin alacritty or simply cargo build. Is this confusing RLS somehow?
Yes, I expect so. To be honest I'm not entirely sure why this is the case, but it is not so important for now. As you noticed, you can set the RLS to build with --lib
by using an option in rls.toml. The fix here, I think, is to also support --bin
, either by turning the bool into an enum, or by adding another option. If you start at that option in config.rs, and then search for the option name (it becomes a field on Config
with the same name), you should be able to see how it gets used and add the --bin
flag too.
This also seems a bit fishy:
couldn't read \"src/0/gl_bindings.rs\": No such file or directory
Is the 0
part an expects part of the path?
Hey @NickeZ how did you get on with this? Do you need any more pointers?
Sorry i didn't really have time to look into this yet..
I dug into this a bit and I'm fairly certain this is specifically related to RLS not executing build scripts like vanilla cargo does, specifically setting OUT_DIR
env var for those. For context, RLS is short-circuiting compilation of build script in here, meanwhile cargo sets this up deeper down while resolving deps and whatnot here. Hence why assets, which are created in build.rs and are included for compilation, in case of alacritty, are not created and build fails. Compiling in build_lib
mode also similarly fails.
On another note I tried to naively pass lib
flag and detected bin targets in Cargo.toml to CompileFilter
(https://github.com/rust-lang-nursery/rls/blob/master/src/build.rs#L446), but this didn't trigger generating analysis data for both lib and bin targets simultaneously, so I'll have to look around some more and figure out a way to make it work.
I was wondering why it didn't work on some project, it seems I have this issue as well.
For what it's worth, I'm seeing this issue with bus as well, which does not have a build script (cc @Xanewok). It does have both a binary and lib though. Specifically, I get:
{"message":"extern location for bus does not exist: /home/jon/dev/minor/bus/target/rls/debug/deps/libbus-462c062bd24a1f96.rmeta","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"extern location for bus does not exist: /home/jon/dev/minor/bus/target/rls/debug/deps/libbus-462c062bd24a1f96.rmeta","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"can't find crate for `bus`","code":{"code":"E0463","explanation":"\nA plugin/crate was declared but cannot be found. Erroneous code example:\n\n```compile_fail,E0463\n#![feature(plugin)]\n#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`\nextern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`\n```\n\nYou need to link your code to the relevant crate in order to be able to use it\n(through Cargo or the `-L` option of rustc example). Plugins are crates as\nwell, and you link to them the same way.\n"},"level":"error","spans":[{"file_name":"src/bench.rs","byte_start":0,"byte_end":17,"line_start":1,"line_end":1,"column_start":1,"column_end":18,"is_primary":true,"text":[{"text":"extern crate bus;","highlight_start":1,"highlight_end":18}],"label":"can't find crate","suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
{"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":null}
followed by
thread '<unnamed>' panicked at 'could not run cargo: ChainedError { error: failed to stat `/home/jon/dev/minor/bus/target/rls/debug/.fingerprint/bus-36e0e0ffe9ba923a/dep-bin-bench-36e0e0ffe9ba923a`, cause: Error { repr: Os { code: 2, message: "No such file or directory" } } }', /checkout/src/libcore/result.rs:859
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Another related issue is the binary crate with multiple binaries under 'bin' directory, rls is also confused with that. And it would be great to also have an option to compile examples.
So any updates? @nrc @jonathandturner
Looks like this is not as easy as first thought, other than that no update. Hopefully we'll get to it soon
I have hit this issue as well in mdBook. I was really excited to test the RLS on Atom, but with this issue it is in a unusable state on my crate. Do we know what is causing the problem?
Like the others I get the following message:
{"message":"extern location for mdbook does not exist: /Volumes/FilesOSX/Users/azerupi/Programming/Rust/mdBook/target/rls/debug/deps/libmdbook-b44f9fe365a227df.rmeta","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"extern location for mdbook does not exist: /Volumes/FilesOSX/Users/azerupi/Programming/Rust/mdBook/target/rls/debug/deps/libmdbook-b44f9fe365a227df.rmeta","code":null,"level":"error","spans":[],"children":[],"rendered":null}
{"message":"can't find crate for `mdbook`","code":{"code":"E0463","explanation":"\nA plugin/crate was declared but cannot be found. Erroneous code example:\n\n```compile_fail,E0463\n#![feature(plugin)]\n#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`\nextern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`\n```\n\nYou need to link your code to the relevant crate in order to be able to use it\n(through Cargo or the `-L` option of rustc example). Plugins are crates as\nwell, and you link to them the same way.\n"},"level":"error","spans":[{"file_name":"src/bin/mdbook.rs","byte_start":0,"byte_end":20,"line_start":1,"line_end":1,"column_start":1,"column_end":21,"is_primary":true,"text":[{"text":"extern crate mdbook;","highlight_start":1,"highlight_end":21}],"label":"can't find crate","suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
{"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":null}
thread '<unnamed>' panicked at 'could not run cargo: ChainedError { error: failed to stat `/Volumes/FilesOSX/Users/azerupi/Programming/Rust/mdBook/target/rls/debug/.fingerprint/mdbook-dd8d22ff2a809e11/dep-bin-mdbook-dd8d22ff2a809e11`, cause: Error { repr: Os { code: 2, message: "No such file or directory" } } }', src/libcore/result.rs:859
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Getting this as well in my project that has both a bin and a lib. The bin can't find the lib in this case.
Otherwise its the same kind of issue as others have reported.
@nrc can we close this now?
I also encounter this issue with the crate "mpq"
I would be happy to test any available fix !
@rohel01 Currently you have to specify build_lib
or'build_bin
(in the configuration) to select an active crate for which diagnostics will be provided, but it should be working in general; tested on the crate you mentioned.
If you want to work on the library part of your crate, then specify build_lib = true
, otherwise you can select a binary crate target to analyze (you won't get currently diagnostics for modules which aren't directly used by the binary) with build_bin = <bin_name>
(here "mpq"
).
If you're using VS Code and got a fresh version from master, then you can go to File > Preferences > Settings and add either "rust.build_lib": true
or "rust.build_bin": "mpq"
in your case (possible options can be found under Rust configuration
).
@Xanewok Which component should I update ?
I assumed you meant RLS, but the end of your answer mentions vscode-rust configuration parameters, which are currently unknown to my setup (vscode-rust 0.4.2). Then, I checked vscode-rust master branch but did not find any recent commit relevant to this issue.
From which branch does rustup fetch RLS from by default ? Is a rustup update
sufficient to get latest RLS from master ?
@rohel01 The last part (VS Code, "rust.build_lib": true"
etc.) is just an extra and probably only accessible if you're building RLS from master and using it in your client. I'm also talking about the reference extension, rls-vscode, that's co-developed with RLS, not vscode-rust.
Can you run rls --version
and see which version you have (Or rustup run nightly rls --version
, depending how you run rls
in vscode-rust)?
If you want to work on the library part of your crate, then specify build_lib = true
Is this an inherent limitation or will it be possible in the future to work on both the library and the binary without the need to switch a configuration option?
It's just how current implementation works right now - it only supports a single crate target at a time. This will change when we start supporting workspaces (prototype landing soon!), as this will mean moving the RLS operation model from single crate type to multiple crates. From there, supporting multiple crate targets, or at least lib+bin, should be fairly straightforward AFAICT.
Would it be possible to check the "thing" that you are currently modifying if that is "well-defined"? I mean, if you are modifying "main.rs" it is obvious to check the bin. But if you are modifying something that is defined in the lib.rs as a "pub mod" it is obvious that you want to check the lib.
From what I know it's technically possible to collect current targets from the Cargo.toml, along with implicit ones, e.g. main.rs or lib.rs, but noone really looked into that more thoroughly (there's not as much work required to get it working initially, but what might be tricky is ensuring consistent config across the builds, not fighting with client-side configuration etc.), as there's focus on getting the final, more complete experience right instead.
However, absolutely, I do realize that it's not ideal now and changing the options explicitly can be quite cumbersome. From what I know the build queue will be revamped by @nrc soon, but if you someone would like to take a look at the possibility of adding a feature you mention, then that'd be awesome and greatly appreciated :)
I've tried adding build_lib=true
into .rls.toml
but doesn't appear to have any effect. Is there anything else that you need to add?
@cetra3
I've tried adding build_lib=true into .rls.toml
We no longer use the rls.toml, you need to put this into the configuration settings in your editor. See https://github.com/rust-lang-nursery/rls-vscode/blob/master/README.md#configuration for details.
@nrc how would I then adjust this per-project? I only have one project that hits this rls defect.
See workspace settings in https://code.visualstudio.com/docs/getstarted/settings
I have "rust.build_lib": true in the global vscode settings, but it doesn't seem to have any effect, at least with recent rls builds (nightly 2017-07-26 and 2017-07-30).
Whenever a project both with bin and lib is opened rls only analyzes the binary. E.g. by making a syntax error in the binary rs module it is immediately highlighted but the rest of the project doesn't get parsed at all.
Yes
Another observation: when deleting 'target' folder and restarting vscode it takes very little time (few seconds) to finish the analysis. Which is not ok.
I have created issue #431 with attached minimal project.
Why is it closed?
The original error, where checking bin target of a package that also had a lib component failed has been fixed and you need to set build_bin=„
This is still broken, a crate with lib and bin, rls-vscode doesn't show any completions for local lib code used in binary.
Unknown rls config "workspace_mode"
When I use RLS with alacritty I get this error "E0463 can't find crate for
alacritty
can't find crate".Is this supposed to work?
If I add
build_lib: true
to an rls.toml file I don't get any warnings at all inmain.rs
.I'm on latest master of rls and LanguageClient-neovim