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

Unexpected Activation of rust-analyzer in a Swift Project #17018

Open
mole828 opened this issue Apr 5, 2024 · 6 comments
Open

Unexpected Activation of rust-analyzer in a Swift Project #17018

mole828 opened this issue Apr 5, 2024 · 6 comments
Labels
C-bug Category: bug

Comments

@mole828
Copy link

mole828 commented Apr 5, 2024

Hello,

I am currently working on a Swift project in Visual Studio Code and have encountered an unexpected behavior with the rust-analyzer extension.

When I press the F5 key to debug my Swift project, the rust-analyzer extension is being triggered. This is unexpected as the rust-analyzer extension should ideally only respond to Rust projects.

Here are the steps to reproduce the issue:

Minimum Reproduction Code: https://github.com/mole828/SwiftLearning/tree/02435b6a83b9c09d936cae252cd5821a74ffcd4c
Clone the Swift project from this repository.
Open the project in Visual Studio Code.
Press F5 to start debugging.
Expected Behavior: The Swift debugger should start.

Actual Behavior: The rust-analyzer extension is triggered.

I have checked my workspace settings and confirmed that they are correctly set up for a Swift project. I have also verified that the launch.json file in the .vscode directory is correctly configured for Swift debugging.

I would appreciate any guidance on how to prevent rust-analyzer from being activated when working on a Swift project.

Thank you for your time and assistance.

@mole828 mole828 added the C-bug Category: bug label Apr 5, 2024
@Veykril
Copy link
Member

Veykril commented Apr 5, 2024

Can you check the extension host logs? It should tell you what the activation event is that triggered rust-analyzer. Also please check if this also happens with only rust-analyzer and your swift extension enabled and nothing else. There are certain VSCode APIs that some extensions use that activate all extensions registering task providers iirc (something we cant do anything about)

@mole828
Copy link
Author

mole828 commented Apr 5, 2024

I tried on Windows (an environment that has detached from the Swift language) and removed all extensions.
The complete Extension Host Log is as follows:

2024-04-06 00:48:17.768 [info] Extension host with pid 21424 started
2024-04-06 00:48:17.768 [info] Skipping acquiring lock for c:\Users\mrx80\AppData\Roaming\Code\User\workspaceStorage\f1b118e238b3ec25b6cb80abf3574418.
2024-04-06 00:48:17.782 [info] ExtensionService#_doActivateExtension vscode.emmet, startup: false, activationEvent: 'onLanguage'
2024-04-06 00:48:17.813 [info] ExtensionService#_doActivateExtension vscode.git-base, startup: true, activationEvent: '*', root cause: vscode.git
2024-04-06 00:48:17.828 [info] ExtensionService#_doActivateExtension vscode.git, startup: true, activationEvent: '*'
2024-04-06 00:48:17.879 [info] ExtensionService#_doActivateExtension vscode.github, startup: true, activationEvent: '*'
2024-04-06 00:48:17.945 [info] Eager extensions activated
2024-04-06 00:48:18.002 [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch, startup: false, activationEvent: 'onStartupFinished'
2024-04-06 00:48:18.005 [info] ExtensionService#_doActivateExtension vscode.merge-conflict, startup: false, activationEvent: 'onStartupFinished'
2024-04-06 00:48:18.189 [info] ExtensionService#_doActivateExtension vscode.github-authentication, startup: false, activationEvent: 'onAuthenticationRequest:github'
2024-04-06 00:48:33.741 [info] ExtensionService#_doActivateExtension vscode.debug-server-ready, startup: false, activationEvent: 'onDebugResolve'
2024-04-06 00:48:33.746 [info] ExtensionService#_doActivateExtension vscode.grunt, startup: false, activationEvent: 'onTaskType:grunt'
2024-04-06 00:48:33.749 [info] ExtensionService#_doActivateExtension vscode.gulp, startup: false, activationEvent: 'onTaskType:gulp'
2024-04-06 00:48:33.751 [info] ExtensionService#_doActivateExtension vscode.jake, startup: false, activationEvent: 'onTaskType:jake'
2024-04-06 00:48:33.753 [info] ExtensionService#_doActivateExtension vscode.npm, startup: false, activationEvent: 'onTaskType:npm'
2024-04-06 00:48:33.772 [info] ExtensionService#_doActivateExtension vscode.typescript-language-features, startup: false, activationEvent: 'onTaskType:typescript'
2024-04-06 00:48:33.817 [info] ExtensionService#_doActivateExtension rust-lang.rust-analyzer, startup: false, activationEvent: 'onTaskType:cargo'

@roife
Copy link
Member

roife commented Apr 6, 2024

It seems to be working fine for me on macOS. Could you create a new project for testing? What debugging extension are you using (CodeLLDB or others)? Could you share your configuration?

@Veykril
Copy link
Member

Veykril commented Apr 6, 2024

Something in your setup is kicking off all onTaskType events starting every extension that has such an activation event (including rust-analyzer).

@lnicola
Copy link
Member

lnicola commented Apr 6, 2024

CC #14231

@mole828
Copy link
Author

mole828 commented Apr 6, 2024

{
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "sourceLanguages": [
                "swift"
            ],
            "args": [],
            "cwd": "${workspaceFolder:SwiftLearning}",
            "name": "Debug SwiftLearning",
            "program": "${workspaceFolder:SwiftLearning}/.build/debug/SwiftLearning",
            "preLaunchTask": "swift: Build Debug SwiftLearning"
        },
        {
            "type": "lldb",
            "request": "launch",
            "sourceLanguages": [
                "swift"
            ],
            "args": [],
            "cwd": "${workspaceFolder:SwiftLearning}",
            "name": "Release SwiftLearning",
            "program": "${workspaceFolder:SwiftLearning}/.build/release/SwiftLearning",
            "preLaunchTask": "swift: Build Release SwiftLearning"
        }
    ]
}

This is the launch.json, it seems the problem lies with the "preLaunchTask".
If this parameter is removed, the problem does not occur.
If it is changed to “${defaultBuildTask}”, in the part that is entirely handled by vscode before selecting tasks, it starts rust-analyzer.
This seems to have been confirmed as an issue in vscode.

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

4 participants