intellij-rust / intellij-rust

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

On some projects, clicking "Run External Linter" gives false error about JDK configuration #8324

Open AlyoshaVasilieva opened 2 years ago

AlyoshaVasilieva commented 2 years ago

Environment

Problem description

When clicking on the "Run External Linter" button to run Cargo Check/Clippy, IDEA says:

Error

The JDK is not configured properly for this project.
Inspection cannot proceed.

After clicking OK, a popup to select the JDK appears. It can be totally ignored as inspection then proceeds fine in the background.

Steps to reproduce

  1. File > New > Project from Version Control
  2. Checkout https://github.com/ngirard/lolcate-rs
  3. Wait for project to finish indexing, click "Run External Linter"

In my case, I eventually noticed that the project's IML has two weird things:

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
      <excludeFolder url="file://$MODULE_DIR$/target" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

It is listed as a "JAVA_MODULE" and contains an entry for the JDK. Changing type to "RUST_MODULE" and removing "inheritedJdk" entry fixes the issue.

The source repo contains no IDEA files or Java code, IDEA is generating this erroneously for some reason. Maybe this is a bug in IDEA rather than this plugin, I'm not sure. If possible though the Rust plugin shouldn't be prompting me to set the JDK as it is unrelated to Cargo Check/Clippy.

sebr74 commented 2 years ago

Changing type to "RUST_MODULE" and removing "inheritedJdk" entry fixes the issue.

I was also affected by this bug. Thanks for providing the workaround. I confirm that this made it work for me.