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

Display warning message if Cargo.toml is missing #157

Merged
merged 1 commit into from
Sep 22, 2017
Merged

Display warning message if Cargo.toml is missing #157

merged 1 commit into from
Sep 22, 2017

Conversation

DSpeckhals
Copy link
Contributor

@DSpeckhals DSpeckhals commented Sep 21, 2017

If there is no Cargo.toml at the root of the workspace, display a warning message to the user informing them that not all features will be available.

This fixes #75

@Xanewok
Copy link
Member

Xanewok commented Sep 21, 2017

Maybe it'd be good to use the "workspaceContains":Cargo.toml rule in package.json instead? This looks like it will take care of appropriately calling the activate(), registering commands when needed etc.
For example omnisharp-vscode does that.

Overall, nice catch! Definitely a good idea to watch out for Cargo.toml.

@DSpeckhals
Copy link
Contributor Author

@Xanewok Unless I'm reading this wrong, the package wouldn't activate at all in that case. This includes the RLS, but also the syntax features and rls.update command. I guess it's not a big deal. I'm good either way on this one.

@Xanewok
Copy link
Member

Xanewok commented Sep 21, 2017

@DSpeckhals ah, my bad. It seems the activation events will be sent when something happens
(e.g. when vscode is initialized in a workspace folder with Cargo.toml if there's a "workspaceContains":Cargo.toml option), but that only lazily starts the extension automatically and is not a required condition for the extension to operate.

Coincidentally, I added a PR rust-lang/rls#492 that prevents the RLS from crashing and dying when the underlying Cargo routine fails and allows it to be successfully re-run, without having to restart the RLS.
Right now I tried creating an empty folder with a main.rs, initialized rls there and only after, inside vscode, I added the Cargo.toml and moved main.rs under src/ and it seemed to be able to work properly!

With that in mind, I don't think we have to go as far as not running the RLS at all if the workspace does not have a Cargo.toml, but it would be really useful to report that fact to the user, either via a status bar or a single warning like Cargo.toml has to be present in in the workspace in order to support all the features or something along the lines.

@DSpeckhals
Copy link
Contributor Author

DSpeckhals commented Sep 21, 2017 via email

@Xanewok
Copy link
Member

Xanewok commented Sep 21, 2017

Yeah, I think only presenting the warning on startup is enough now 😃
Thanks!

cc @nrc

When there is no Cargo.toml file in the workspace, display a warning
message informing users that not all features will be available.
@DSpeckhals DSpeckhals changed the title Don't start rls without a Cargo.toml Display warning message if Cargo.toml is missing Sep 22, 2017
@DSpeckhals
Copy link
Contributor Author

I force-pushed a commit on top of my previous one, changed the PR description, and changed the PR title to reflect the current state.

@nrc nrc merged commit 73d8b34 into rust-lang:master Sep 22, 2017
@nrc
Copy link
Member

nrc commented Sep 22, 2017

Thank you!

@maelvls
Copy link
Contributor

maelvls commented Dec 1, 2017

Note: it would be good to change it from

Cargo.toml must be in the workspace in order to support all features

to

A Cargo.toml file must be at the root of the workspace in order to support all features

No?

@DSpeckhals DSpeckhals deleted the missing-cargo-toml branch December 1, 2017 20:07
@Xanewok
Copy link
Member

Xanewok commented Dec 1, 2017

@maelvalais Yup! Especially since workspace mode should work better now. Mind sending a PR with the change?

maelvls added a commit to maelvls/rls-vscode that referenced this pull request Dec 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

detect a rust file outside a Cargo project and inform user
4 participants