Skip to content

Creating a new source file results in an unhelpful "This rust file does not belong to a loaded cargo project" notification #14523

Closed
@Zalathar

Description

@Zalathar

rust-analyzer version: 0.3.1463-standalone (2365762 2023-04-02)

Steps to reproduce:

  • In an existing VSCode project, right-click on your source directory and choose “New File...”
  • Enter a file name (e.g. foo.rs)
  • Open the file

Actual behaviour:

When the file is opened, a popup immediately appears warning that:

This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at file:///path/to/Cargo.toml, do you want to add it to the linked Projects?
[Yes] [No] [Don't show this again]

This is pretty confusing, since I'm about to add the file to my project with the “Insert mod foo;” quick-fix, and none of the options provided seem to have anything to do with that.

Also, the Cargo.toml file mentioned in the popup is the one that RA has already loaded, so trying to load it more isn't going to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vscodevscode plugin issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions