IntelliJ Content root resets after closing Project - intellij-idea

I have a simple project with 1 module in IntelliJ. I go to File -> Project Structure -> Module -> Add Content Root and set the root of the project folder to be the project root, but after I close the project, or quit IntelliJ and open the project again, the content root is not set.
IntelliJ Community v2020.2
MacOSX Big Sur 11.0.1

I fix it by:
quit IntelliJ
delete .idea file in the folder
open the project again

Related

How to fix a broken Intellij Idea?

When I open an existing Maven project, the IDE shows only those files on the root directory, but not any directories in the project. After a while, the IDE will show the project as what it is in the file structure, but not the directory types such as source code, test when I reopen the project. I reinstall the community edition, but the problem still resists. I have experienced the same issue for a few Java projects lately.
How to resolve this issue?
1, Please ask another teammate to check if that project really works. Sometimes the application structure already broken, then it is not your local problem.
2, There is a .idea folder in the application, delete it. Or simply, you git clone a new place Important: Please notice if you have edited / created some new files in the original directory, otherwise you would lost them if you delete the application.
3, Open intellij, and File -> Invalite caches
Personally, the second point is recommendated.
Try to click on Reload All Maven Projects in Maven tool window:
If it doesn't help you can try to perform the following actions:
Close the project with File | Close Project.
Close the IDE.
Open your project in OS file manager and remove all .iml files and the .idea directory.
Reimport the project.
If the problem remains contact JetBrains support and attach a compressed log folder along with the project structure tree.

IntelliJ IDEA does not recognize JAVA source directory

Recently I imported the source code of Flink, but IDEA did not recognize the JAVA source directory, resulting in the failure of normal compilation and reading. I found that the generated .Iml file does not contain the JAVA source directory, I can manually mark the source directory. Flink's module has 188+, manual mark is too difficult, what should I do? Thank you
Pictures are as follows
You can try to do:
Close the project File | Close Project
Close the IDE.
Open the project directory in File Explorer and delete all .iml files and the .idea directory.
Re-import the project into IntelliJ from Existing sources.

open a directory with intellij without creating a project

I want to be able to open a directory with intellij without creating a project.
how to do it?
every time I open a folder, a project is automatically created with an .idea folder
When you use the Intellij IDE to open a directory,
It assumes that you are going to open a project (as it is the main reason to use IDEs). By default all of jetbrains's IDEs put the project specific settings for project in the .idea folder.
It is also safe to delete it if you are just opened a directory. There would be no problem in deleting this.
You can also use Terminal tab to change or open a directory (Alt+F12)
and use terminal commands to traverse between directories without creating any .idea folder.

IntelliJ IDEA Ultimate project loading issue

So, today in the morning I closed down IntelliJ(2017.3.3) after doing some programming as usual and everything worked great. Now suddenly when I try to open any of my projects this is the view I am greeted with:
After searching for a solution for this issue I managed to get the projects working by doing the following steps:
File -> Project Structure -> Modules -> + -> Import -> The project .iml file
File -> Project Structure -> Project -> Project SDK -> Java 8 in my case
File -> Project Structure -> Project -> Project language level -> 8
File -> Project Structure -> Project -> Project compiler output -> The path to the out folder of the specific project(the whole path from D:\ to it)
Navigate to Main class in project structure and alt+enter to add it to run configurations.
Finally able to run the project
Now this would be fine if I had to do it once, configuration corruption or whatever happens, but I have to do this every single time I open a project for some reason. I tried restarting my PC, reinstalling 2017.3.3, installing 2018.1 and the issue persists whatever I do. Also there were no visible errors in relation to this issue in any of the above scenarios, steps, installs and so on.
Well it turns out the issue was related to me using OneDrive to backup my data. I assume OneDrive updated at some point and activated Files On-Demand. The issue is documented here. For me personally a solution that worked was:
Right click the OneDrive tray icon
Click settings
Click the settings tab
Disable the Save space and download files as you use them option under Files On-Demand.
Wait for your files to sync up completely, IntelliJ project load is back to normal.
I tried disabling Themed status bar in Material Theme Advanced Settings and it started working for me.
From: IntelliJ IDEA > Preferences > Material Theme > Advanced Settings > Other Tweaks Tab
Disable "Themed Title Bar" by unchecking the box here.

Can't see project folders in IntelliJ IDEA

Every once in a while, I open an old project and I can't see any of the folders in the intelliJ project viewer. I can see all the files at the root.. but no folders. Yes I can delete the .iml file and .idea folder and re-create the project, but come on.. there's gotta be an easier way to fix this.
Is there?
If you look in project settings (ctrl-shift-alt-s), you should see a module structure. If you instead see "Nothing to see", do the following:
In Project Structure -> Modules, press the + button,
press enter (since, for some weird reason, it won't let me click on "New Module")
In the window that pops up, click on the "..." next to Content root, find your root folder, and select it
Press ok
ignore any warning that says the name is already in use (or to that effect)
the simplest solution worked from me, just delete the .idea folder
keep in mind this will delete all of idea's current project configuration, it'll create the folder with default settings when reload the project again... but all other configuration will be lost if not properly backed-up
It might be because the project didn't have any modules defined. Try adding existing source code by hitting File > New > Module from Existing Sources and select the parent directory of the project for source code
Go to pom.xml file -> right click -> maven -> generate source and update folders. You will see your files and folder structures in left hand side.
All the project-specific settings for a project opened through Intellij IDE are stored in the .idea folder.
The .idea folder (hidden on OS X) in the solution root contains
IntelliJ’s project-specific settings files. These include per-project
details such as VCS mapping and run and debug configurations, as well
as per-user details, such as currently open files, navigation history
and currently selected configuration.
So, if you are not able to see the project file structure in your Intellij IDE, just delete the .idea folder,
rm -rf .idea
and reload the project, then after reload you'll be easily able to get your project structure displayed.
Thank you very much. I just remove the .idea folder and works in my case.
rm -rf .idea
For me, the java folder was not showing up. I went into File->Project Structure. In the second column, I selected on _main. In the third column, I selected the tab "sources". In what I call the fourth column, where the "+Add Content Root" is shown, I verified, the java source/folder was present. In my case, there was an extra source folder, which was the current location. I removed this, applied and the java folder immediately showed up.
Right click on the Project name -> Open Module Setting -> Check the application context path set it up at your project location.
Check your idea.log -- it may have some details explaining why or what is happening (Help | Reveal log in Explorer). Possibly one of the config files got corrupted.
You can always backup and delete .idea subfolder (project settings) and re-create project from scratch. When it's wroking again (after basic configuration) you may copy some of the files from that folder back to recover some of your settings (if there were many).
This happened to me on a new computer when I opened up a Java project in the newly installed Intellij.
The problem was that I had not installed any JDK on the machine.
I had to install a JDK and then go into the settings at ctrl-shift-alt-s and add a JDK by specifying the folder where I installed it. It's possible that IntelliJ would have found it if I closed it and reopened it.
In my case the solution was to create a new project, specifying the project type and creating it within the same directory path as the project that does not load the project files correctly.
PhpStorm automatically detects that the directory exists and gives you the option to create project from existing sources.
This can be found under:
File --> New project...
For gradle users: "Reload All Gradle Projects" option should help.