intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.53k stars 380 forks source link

"Consider detaching the project `rust` from the Cargo tool window" in a non-Cargo project #10485

Open agluszak opened 1 year ago

agluszak commented 1 year ago

I have an IJ project which used to be written in Rust, but was then migrated to another language. Every time I open this project the Rust plugin tries to run a cargo sync, but fails with the following message:

Project directory `/foo/bar/rust` does not exist.
Consider detaching the project `rust` from the Cargo tool window

I'd very much like to detach the project from the Cargo tool window, but since the project is no longer a Cargo project, there's no Cargo tool window :D

image

Environment

``` IntelliJ IDEA 2023.1.1 (Ultimate Edition) Build #IU-231.8770.65, built on April 27, 2023 Licensed to JetBrains Team / Andrzej Gluszak You have a perpetual fallback license for this version. Subscription is active until December 28, 2026. Runtime version: 17.0.6+10-b829.9 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 6.2.0-20-generic This IDE is managed by JetBrains via Toolbox Enterprise.
Toolbox Enterprise version: 1.0.4917.5492-ij231, https://tbe.labs.jb.gg GC: G1 Young Generation, G1 Old Generation Memory: 4040M Cores: 16 Registry: ide.smart.update=true debugger.new.tool.window.layout=true ide.experimental.ui=true jetbrains.tbe.show.error.popup=true scala.erase.compiler.process.jdk.once=false Non-Bundled Plugins: software.amazon.smithy.intellij (2.0.8) org.rust.lang (0.4.194.5382-231) com.github.copilot (1.2.6.2594) Key Promoter X (2023.1.0) com.intellij.grazie.pro (0.3.222) jetbrains.team.auth (231.8770.72) org.jetbrains.toolbox-enterprise-client (1.0.4917.5492-ij231) com.intellij.sisyphus (231.8770.70) com.jetbrains.intellij.code.search.polaris (0.231.900.8) deno (231.8109.204) com.jetbrains.idea.safepush (231.8770.72) com.intellij.git.instant (1.3.5) com.jetbrains.intellij.api.watcher (231.8770.70) org.intellij.scala (2023.1.18) org.jetbrains.research.refactorinsight (2023.1-4.0) mobi.hsz.idea.gitignore (4.5.0) Jetbrains TeamCity Plugin (2022.12.123443) Kotlin: 231-1.8.21-IJ8770.65 Current Desktop: ubuntu:GNOME ```

Steps to reproduce

  1. Create a non-rust project in /foo/bar.
  2. Create a rust project in /foo/bar/rust and import it.
  3. Delete /foo/bar/rust and close IntelliJ
  4. Open /foo/bar
Ewan88 commented 1 year ago

I have this issue as well.

Deleted a folder from my project and now I get this message every time. It's extremely annoying.

Maksim20023 commented 1 year ago

Hi! This behavior is related to the fact that after removing the Rust module from the project, the Cargo still has project configuration. To avoid running Cargo when opening the project, it's necessary to remove Cargo configuration before removing directory with Rust module. In the opposite case, the Cargo window will not be available, but 'Cargo: failed' message will still appear upon project startup. The easiest workaround would be closing the IDE, removing /.idea folder and reimporting the project again (note that .idea might contain project specific settings) Another way would be creating your rust module again with the same name and same path like the deleted. Then open a Cargo window (View | Tool | Cargo) and detach all configurations by pressing "-" icon. After that, remove the directory with a Rust module and restart IntelliJ IDEA. Does it help?

krisnye commented 8 months ago

This is a significant pain for users who are used to simple folder based management of multiple projects. Instead of making a hidden root .idea directory, consider putting folder specific configuration within each folder. Then if we delete a folder the configuration is deleted along with it.

Or at the very least, the warning message should include a simple button to fix the problem for us.