Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dependencies to Cargo.toml requires restarting VScode #98

Closed
rohel01 opened this issue Jul 26, 2017 · 21 comments

Comments

@rohel01
Copy link

commented Jul 26, 2017

Fedora 25 x86_64
VSCode 1.14.2
Rust (rls) 0.1.0

Rust toolchain installed with rustup and up to date.

When adding new crates as dependencies of my library crate, I find that I have to manually restart VSCode so that newly added crates are taken into accound by Rust (rls).

Without restarting, I get the following error in the problem view, although my crate compiles just fine through the command line

severity: 'Error'
message: 'use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, and unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? (see issue #27812)'
at: '7,1'
source: 'rustc'
@nrc

This comment has been minimized.

Copy link
Member

commented Jul 26, 2017

This should be fixed by updating the RLS (run rustup update from the command line).

@rohel01

This comment has been minimized.

Copy link
Author

commented Jul 27, 2017

Thanks for the quick response.

I have just updated RLS and it seems to work: RLS monitors my Cargo.toml file and triggers a new analysis when it changes.

The update changed the error message I got and I am not sure it is intended. I am working on the mpq crate which contains both a library and a binary. So, I am using the "rust.build_lib": true setting.

If my Cargo.toml file is missing a crate dependency, I now get the following error

file: 'file:///<removed>/mpq-rust/src/main.rs'
severity: 'Error'
message: 'can't find crate for `mpq`'
at: '3,1'
source: 'rustc'

Also, warning display no longer works ("rust.show_warnings": true in my VSCode settings)

@nrc

This comment has been minimized.

Copy link
Member

commented Jul 27, 2017

The update changed the error message I got and I am not sure it is intended.

This sounds like the right error? Does it go away when you add the dep for mpq to the Cargo.toml?

You usually don't get warnings if there are any errors - could that be the problem with warnings?

@rohel01

This comment has been minimized.

Copy link
Author

commented Jul 30, 2017

mpq is the crate I am working on. So basically, RLS cannot find the current project.
Also, this error comes from the main.rs file, while I am working on the library part of the crate. I assumed setting rust.build_lib": true would prevent RLS from analysing that file.

I have experimented a bit and found that warnings and errors are no longer shown in VSCode. I edited both the source code and the Cargo.toml to introduce syntax errors but they remain unflagged in the UI.

The can't find crate for mpq error appears randomly after a few edit/save cycles of my files. When it appears, I usually have to restart VSCode to make it disappear.

I have made available my current repo here if you want to reproduce the issues

For reference, here are my Rust related settings in VSCode

  "rust.build_lib": true,
  "rust.show_warnings": true,
  "rust.unstable_features": false

@nrc nrc added the bug label Jul 30, 2017

@nrc

This comment has been minimized.

Copy link
Member

commented Jul 30, 2017

cc @Xanewok maybe a problem with lib/bin stuff after a forced rebuild?

@rohel01

This comment has been minimized.

Copy link
Author

commented Aug 1, 2017

I believe this issue is related to rust-lang/rls#431

@Xanewok

This comment has been minimized.

Copy link
Member

commented Aug 1, 2017

cc @Xanewok maybe a problem with lib/bin stuff after a forced rebuild?

I'll take a look at why the settings doesn't work as expected now.

@nrc

This comment has been minimized.

Copy link
Member

commented Aug 21, 2017

@rohel01 is this all fixed now?

@rohel01

This comment has been minimized.

Copy link
Author

commented Aug 21, 2017

@nrc nrc closed this Aug 21, 2017

@rlguarino

This comment has been minimized.

Copy link

commented Dec 30, 2017

I seem to still have this issue:

2017-12-30_10-44-10

rustup run nightly rls --version
rls-preview 0.124.0-nightly (299a6a9 2017-12-25)
@chamons

This comment has been minimized.

Copy link

commented Feb 25, 2018

I can confirm this issue still exists, and is pretty trivial to hit for new users

  1. Work through https://doc.rust-lang.org/book/second-edition/ch02-00-guessing-game-tutorial.html until you hit "Generating a Secret Number"
  2. Hit "use of unstable library feature 'rustc_private`" warning and google until you hit this issue.

@nrc nrc added the P-High label Mar 22, 2018

@sylints

This comment has been minimized.

Copy link

commented Apr 7, 2018

Can confirm, am new user working through the Guessing Game tutorial and hit this bug, google'd it and landed here.

@sagudev

This comment has been minimized.

Copy link

commented May 3, 2018

@sylints

Can confirm, am new user working through the Guessing Game tutorial and hit this bug, google'd it and landed here.

same here

@wukann

This comment has been minimized.

Copy link

commented Jun 16, 2018

I encountered the same problem through the Guessing Game tutorial.
When restarting VSCode, the problem no longer occurred.

@dlukes

This comment has been minimized.

Copy link

commented Jul 21, 2018

FWIW, I wasn't able to reproduce this, so maybe it has been fixed? (macOS, VSCode 1.25.1, rls-vscode 0.4.9, rustup toolchain stable, rustc 1.27.2)

@covertbert

This comment has been minimized.

Copy link

commented Jul 29, 2018

It's definitely still an issue as I just encountered it! Restarting VSCode fixed it for me

@Xanewok

This comment has been minimized.

Copy link
Member

commented Jul 29, 2018

Unfortunately this occured for Windows for me, fix is pending at https://github.com/Xanewok/rls/tree/windows-watch-cargo

@TallonRain

This comment has been minimized.

Copy link

commented Aug 4, 2018

As sylints said. Same here, running through the Guessing Game tutorial with the latest stable releases as of this writing, ran into the error. Compiles and runs fine regardless. Can also confirm that restarting VSCode fixes it.

@BarePotato

This comment has been minimized.

Copy link

commented Oct 16, 2018

Working through the book, chapter 2 guessing game tutorial generated this problem as well. build and run fine, restart vscode clears, and continues to build and run fine.

@plstreatmewell

This comment has been minimized.

Copy link

commented Oct 23, 2018

I've also been working on the tutorial and encountered this problem as well.
Build and run work fine via command line.
But unlike the cases above, restarting vscode doesn't fix the problem.
I also rebooted the computer but the error still occurs.
Any idea?

Thanks for reading.

jamesray1 added a commit to jamesray1/rust-libp2p that referenced this issue Jan 17, 2019
* Bump libp2p version to 0.2.2 (didn't update via
pulling,
this is probably due to an issue with rls-vscode: e.g.
rust-lang/rls-vscode#364 and
rust-lang/rls-vscode#98.
* Other changes that were again meant to be in the
previous commit, as mentioned there (rm unused imports,
custom_error fixes, compiler fixes such as adding
imports and removing unused ones, use the type Error =
rror and connection_keep_alive for ProtocolsHandler,
etc.)
* gossipsub v 0.2.2 -> 0.2.0
* Change remove and remove_peer_from_topic methods of
mesh, using a match to return peers or an added custom
error. Use in layer.
* Compiler fixes: add cloning, return types, etc.
*
@Xanewok

This comment has been minimized.

Copy link
Member

commented Apr 7, 2019

I just tested the guessing game and it works as expected using RLS from master (should be most recent nightly but is curently breaked for a couple of days) and the most recent VSCode extension. Please reopen if this is still an issue.

@Xanewok Xanewok closed this Apr 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.