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

There is no task provider registered for tasks of type "cargo" for VSCode workspace, again #16949

Closed
CrendKing opened this issue Mar 25, 2024 · 20 comments
Labels
C-bug Category: bug

Comments

@CrendKing
Copy link

I'm experiencing the exact same issue as #9093, but in the latest version. The previous 0.3.1885 does not have issue.

rust-analyzer version: 0.3.1896

rustc version: 1.77.0 stable

@CrendKing CrendKing added the C-bug Category: bug label Mar 25, 2024
@eduarddejong
Copy link

eduarddejong commented Mar 26, 2024

Same here.
Using the same Rustc and Analyzer version.

Using VSCodium on Linux.

I didn't change anything in my project configuration, today it does not build using Ctrl+Shift+B or explicitly entering "Run: Tasks" -> "rust: cargo build" and the error is shown for me as well.

However, clicking the "Run", "Debug" and "Run Tests" hyperlinks shown inside the code editor above main and tests does still work and also F5 to start debugging (which I have configured to launch with LLDB) works as always.

So it seems quite specifically related to the cargo build task.

@pbl-pw
Copy link

pbl-pw commented Mar 26, 2024

Same too.

@Paperback
Copy link

Likewise, experiencing this issue :(

@lnicola
Copy link
Member

lnicola commented Mar 28, 2024

The previous 0.3.1885 does not have issue.

Are you sure? I get the same error in v0.3.1868 and v0.3.1885.

@ldericher
Copy link

Same issue, vscode with RA 0.3.1896 (on Linux 6.5.0-26), no issue on 0.3.1885

@lnicola
Copy link
Member

lnicola commented Mar 28, 2024

Can anyone bisect this?

@ldericher
Copy link

ldericher commented Mar 28, 2024

Can anyone bisect this?

Hmmm … now I've built a binary to check, but how do I use it with my VSCode?

git checkout "2024-03-25"
git bisect start
git bisect bad
git bisect good "2024-03-18"
cargo build --release

@lnicola
Copy link
Member

lnicola commented Mar 28, 2024

cargo xtask install will install it to ~/.cargo/bin and also build and install the Code extension. Make sure you have nodejs and npm and you'll need to restart Code to make sure it's using the new one (i.e. don't trust "Reload window").

@ldericher
Copy link

2e109c7da8fb5b4adc809f30035472512e7ac7cd is the first bad commit
commit 2e109c7da8fb5b4adc809f30035472512e7ac7cd
Author: Wilfred Hughes <wilfred@meta.com>
Date:   Wed Mar 13 16:46:57 2024 -0700

    refactor: Use a single CLI args array rather than a separate subcommand field

 editors/code/src/run.ts   |  4 +---
 editors/code/src/tasks.ts | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 13 deletions(-)

This refers to commit 2e109c7, but someone deeper involved should take it from here, I know nothing about the vscode extension API.

@lnicola
Copy link
Member

lnicola commented Mar 28, 2024

CC @Wilfred

I wonder why these were broken for me though.

@Wilfred
Copy link
Contributor

Wilfred commented Mar 28, 2024

Thanks for the ping, I'll take a look. Sorry about this.

@Wilfred
Copy link
Contributor

Wilfred commented Mar 28, 2024

OK, this is an issue with how tasks are defined, because they're a user-facing API through tasks.json or .code-workspace.

If you need a workaround right now and can't downgrade, you can define your task as a shell command:

{
	"version": "2.0.0",
	"tasks": [
		 {
			"type": "shell",
			"command": "cargo build",
			"problemMatcher": [
			  "$rustc"
			],
			"group": "build",
			"label": "my example cargo build task"
		 }
	]
}

@Wilfred
Copy link
Contributor

Wilfred commented Mar 28, 2024

I think there's another issue with the task declaration in package.json, it doesn't allow cwd at all. That looks like a pre-existing problem though.

bors added a commit that referenced this issue Apr 1, 2024
Fix tasks in tasks.json

#16839 refactored the representation of tasks inside the VS Code extension. However, this data type is exposed to users, who can define their own tasks in the same format in `tasks.json` or `.code-workspace`.

Revert the data type to have a `command` field rather than a `program` field, and document the different fields. This code is also a little complex, so split out a `cargoToExecution` to handle the Task to Execution conversion logic.

After this change, any tasks.json with a `command` field works again. For example, the following tasks.json works as expected:

```
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cargo",
			"command": "build",
			"problemMatcher": [
			  "$rustc"
			],
			"group": "build",
			"label": "my example cargo build task"
		}
	]
}
```

Fixes #16943 #16949
@Barugon
Copy link

Barugon commented Apr 1, 2024

Still broken in v0.3.1906.

@Veykril
Copy link
Member

Veykril commented Apr 1, 2024

The fix got merged today so it will land on next monday (or tomorrow for the nightly / 0.4 version)

@sandersaares
Copy link

I confirm that the prerelease version currently available fixes the issue for me. Thanks for fast action!

@Veykril
Copy link
Member

Veykril commented Apr 2, 2024

Will close this then, thanks for confirming!

@Coi-l
Copy link

Coi-l commented Jun 18, 2024

This started happening to me yesterday. I upgraded to the pre-release version but it is still broken for me there.

@Veykril
Copy link
Member

Veykril commented Jun 18, 2024

Do you have an example task? The ones I tested worked fine

@kryptan
Copy link

kryptan commented Jun 18, 2024

I have bindings for commands like workbench.action.tasks.runTask|rust: cargo build using the 'Shortcut Menu Bar' extension and they stopped working in v0.3.2002. Downgrading to v0.3.1995 fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests