'Why are the changes I make to my Rust program from VS Code not reflected when I compile?
I'm having a problem with Rust that I strongly suspect has do with a disconnect between Cargo and VS Code.
I build my Cargo project with
cargo new project
I edit my src/main.rs with VS Code and save it.
I issue
cargo run
I see the result from the hello world main.rs instead of the results of the changes I made.
What I find interesting is that if I do a cat src/main.rs
from the terminal, I see the original Rust code, even though VS Code assures me that it saved it and shows me that code even if I restart VS Code.
I've had this problem on a couple of computers now (same OS, Fedora 28). I strongly suspect that Cargo is doing some buffering somewhere that is defeating VS Code. Has anyone else seen this behavior or know the cause? Are there any cures or work-arounds?
Solution 1:[1]
@Tau turned out to be correct. Using Kwrite, the changes seemed to propagate correctly. What's really odd is that Kwrite and VS Code seemed to synchronize with one another. That's really annoying for me as I am a VS Code fanatic. Maybe I post an issue about this for VS Code. Thanks to all for their suggestions.
Solution 2:[2]
Make sure autosave is enabled in VSCode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tigger |
Solution 2 | Maurice Leong Tim |