Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Automatically reload RLS when Cargo.toml changes, or when the git branch changes #98

Closed
mmstick opened this issue Aug 24, 2018 · 7 comments

Comments

@mmstick
Copy link

mmstick commented Aug 24, 2018

This has to be done manually at the moment, else erroneous results will occur.

@alexheretic
Copy link
Member

I think ide-rust is actually doing as much as it can right now, and this does actually work at the moment to a certain extent.

If I comment out a dependency in Cargo.toml, I'll see a red can't find crate diagnostic. Uncomment the line and the error is gone. This is because the file change events are sent to rls.

However, the rest comes down to what rls actually does with that. Generally it should try to rebuild the project. There are some issues, for example it's hard for rls to "know" that a path-dependency has changed and it should do a full rebuild but if you change the Cargo.toml it should work.

Can you give me some more precise scenarios and we can figure out if they're something we can improve here or over at rls?

@mmstick
Copy link
Author

mmstick commented Aug 24, 2018

@alexheretic What happens for every project I've worked on is that adding a new crate or modifying an existing one breaks RLS completely. Likewise with changing git branches. It's not able to recover from the changes, so restarting RLS is required to get things working again. Same thing happens with VS Code, too. Having to Alt + Shift + P and restart RLS is quite a common occurrence.

@alexheretic
Copy link
Member

Yep there are definitely times where that's happened to me before too, though I thought mostly with path = ".." dependencies.

If I take a simple project add or remove a dependency it seems to work fine, so I think we need concrete steps to reproduce in order to improve here.

@mmstick
Copy link
Author

mmstick commented Aug 25, 2018

@alexheretic It's happened with every project we have at System76, which are each around the vicinity of 500-15,000 lines of code per project. You're free to clone any of the repos we have, such as Popsicle, Distinst, and debrep.

@alexheretic
Copy link
Member

We need to nail down proper steps to reproduce before this can be traced to either rls not being notified of a change, or rls not properly rebuilding for some reason.

This isn't trivial. I checked out debrep, had two branches one of which I broke by commenting a dependency out. Switching between the branches correctly triggered a rebuild.

This also works when Cargo.toml is not open in the editor.

@alexheretic
Copy link
Member

I think there are some issues around rls modifying Cargo.lock. rust-lang/rls#1020 may improve the situation.

@alexheretic
Copy link
Member

ide-rust has moved to using rust-analyzer instead of RLS.

I'll close this issue for now, please reopen if this still applies to the new stack.

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

2 participants