All IntelliJ run configurations disappeared - intellij-idea

After IntelliJ IDEA froze and was killed from the task manager, all the Run/Debug Configurations disappeared. I have tried invalidating caches, reloading files from disk, synchronizing and restarting, but nothing helped.

You can try to restore your Run configuration using the Local History feature of IntelliJ IDEA.
If you are using .idea directory based format, then your configurations will reside in workspace.xml file under .idea directory, invoke Local History dialog from the .idea directory right click menu in IDEA Project View, select the label some time before the crash and revert the old copy of workspace.xml.
In case .ipr file based format is used, your configurations will be stored in the <project>.iws file in the project root which you can restore in a similar way.
If the configurations were Shared, they are stored in .idea\runConfigurations directory as separate XML files or in the <project>.ipr file (if old project format is used).
If the Local history is blank and you are in Windows, try Restore previous versions right clicking the workspace.xml file or the <project>.iws one in Windows Explorer.

You can go to your main project and right click on it, select local history --> show history. Find some point in time where you think that system was stable (before crash) and click revert. This worked for me.

To me, this frequently happened on switching branches. Turning off "restore workspace on branch switching" helps to prevent the run configurations from getting lost.
Edit: Not sure if it actually has an impact, it still seems to happen to me sometimes, maybe less frequently though. I'll leave it here since the answer already has some upvotes, so maybe this was the solution for someone...

For every project in intellij there's a file created with all the configurations related to it.
Under the root directory of the project there's a hidden folder .idea in it is the workspace.xml with the configuration. workspace.xml is comprised of components one of which is responsible to hold the run/debug configurations.
If this file is getting corrupted it's difficult to restore these configurations if you don't have a backup of workspace.xml. to overcome it:
1. in intellij right click the workspace.xml file under project view and choose Local History -> Show History
2. if there's no history you can copy the component from a coworker with similar configurations.
3. backup in advance the workspace.xml and retrieve the RunManager component from it..
another good choice is to use the share option.
under each project's definition there's a checkbox share
Marking this checkbox will extract the definition for this project to an external location:
under the same .idea folder a new folder is being created runConfigurations and the configurations per project are being represented there in xml files.
The advantage of using share is that it can be copied and used for similar projects under other branched like QA and production

In my case, i've accidentally pressed Alt + Home and this bar disappeared, this combination toggles run bar at the top of IDEA window for me.
Here the screen with my bound actions on this keys. I hope it should help

Run configurations are stored in your project files. When IntelliJ (or your computer with IntelliJ running) crashes hard, the project files can become corrupted and unreadable. I don't know of a way to recover this unless you have your project files are backed up somewhere.

Navigate to your project folder and check weather any .idea folder is created or not,
if created copy your project and paste it other location ant try opening it;
it will work.

I sometimes have the problem that all the run/debug configurations are not created from CMake after being lost. I solved this by just deleting the whone list of configurations from the workspace.xml (from .idea folder).

This happened to me recently and I just restarted IntelliJ and they shared ones (in .run) are now restored.

In my case what happened was I did something that made IntelliJ recognize the project as a new application type, so it thought my old configuration was not valid for my project anymore and wasn't displaying it to me. I reverted my changes and the configuration appeared as an option again.

I guess this feature can't be removed from IntelliJ but I guess this can help:
Run/Debug configuration functionality might be hidden, so to show it go to:
View/Appearance/Navigation Bar

Very annoying problem in Intellij Idea for many years.
It's quite often breaks because of broken (connection to?) Ant debugger, used to create run configs.
I was periodically searching for a solution, but no success. Then today after disappeared Run Config to display in panel I did inspect contents of workspace.xml. All the run configs were there.
And then it turns out to be 7+ years bug clue...
Always spring out non-called Ant...
Happily, contents of workspace.xml in place with all your run config items, you can just
disable infamous plugin Ant debugger,
reload the project,
and all your run configs are displayed and available again))).
Happy to share with all of you the solution).

Related

IntelliJ different project settings based on used IDE

I have a Git repo with two directories:
backend (PHP/Laravel code)
frontend (TypeScript/Vue code)
I would like that backend is marked as excluded when the project is opened in WebStorm and frontend to be excluded when it is opened in PhpStorm.
This is to ensure that searches/indexing only happen for the files that I would actually edit in that specific IDE.
When I change the excluded directory it seems to automatically apply this to the other IDE as well. Is there some way to keep this setting separate?
Comments:
I intentionally have both frontend and backend in one repository.
Opening the subdirectories in their own IDEA projects does not seem
to be an option because the Git integration only works when the
project is in the root folder of the repository.
When I change the excluded directory it seems to automatically apply this to the other IDE as well.
It is expected. That's because the project settings are stored in the .idea subfolder. All IDEA-based IDEs use the same .idea settings format. So opening the same folder/project in different IDEs simply makes them use that already-made config (shared between IDEs).
Plus, both PhpStorm and WebStorm use the same module type ID (WEB_MODULE) and can have only 1 module in total in a project. IntelliJ IDEA and some other IDEs (like PyCharm for example) can work with projects that can have more than one module and of different types.
Is there some way to keep this setting separate?
Yes, with the help of a small workaround: you need to store .idea used by another IDE in another place. As simple as that.
The setup and steps:
Lets assume that you have your project in C:\Projects\MyProject.
Make a brand new empty project in another place, e.g. C:\Projects\IDEProjectsStore\MyProject-frontend. It will be used for a frontend.
Go to Settings/Preferences | Directories and remove an existing Content Root (which will be C:\Projects\IDEProjectsStore\MyProject-frontend from the previous step).
Add new Content Root instead -- point to the actual project (C:\Projects\MyProject from step #1)
Save and configure as needed.
What you will have now:
This frontend project will now have its settings stored in C:\Projects\IDEProjectsStore\MyProject-frontend\.idea while another (original project with backend) will have them in C:\Projects\MyProject\.idea.
Projects (project-specific IDE settings) are stored in 2 separate places while they both use the same folder with the code.
Basically: a project in the IDE's eyes is an .idea folder with a parent folder added as a Content Root by default. Our workaround keeps the second project in a different folder while sharing the same Content Root between them.
https://youtrack.jetbrains.com/issue/IDEA-170102/ -- that's a ticket that asks for a straightforward way of doing this.
I would like that backend is marked as excluded when the project is opened in WebStorm and frontend to be excluded when it is opened in PhpStorm.
Why do you need two IDEs for this?
In case if you do not know: PhpStorm = WebStorm + PHP + Database. You do not really need WebStorm here. Just install any missing plugins that come bundled with WebStorm.

How can I stop indexing intellij idea?

Without "excluding" folders, how can I stop Indexing intellij idea on start? It's very very annoying that it starts indexing on startup without allowing you to, for example, debug a test case making you wait until indexing has finished.
You can stop synchronizing/indexing each time you switch to the IDEA and it's quite useful when dealing with big projects and outside build process which triggers indexing.
Just disable checkbox System Settings -> Synchronize files on frame or editor tab activation.
Make sure you run indexing manually to update hints when needed through Synchronize menu (Cmd-Alt-Y on Mac) or File -> Reload All from Disk to run it manually for IDEA 2020 running under Linux
Try:
File-> Invalidate Caches / Restart.
I think that this issue happens (at least for me it seems to be the reason) if you start commit and then close the IDE in the middle of the process.
Now, "excluding" folders is the only way to disable indexing when a change occurs in one of excluded folders (except for generated sources that mustn't be excluded).
Checked with Intellij 2016.2.5
I suggest you to tune your Intellij configuration, see this post : https://stackoverflow.com/a/22508853/779338
You Can easily resolve it.
Just Go to: File -> Setting -> Directories.
Stop all the files that are going to included and need to empty ADD Content Root.
Like This:
It may be because of libraries folder is added more than one sub folder in the project. example in my case i have node_modules folder in two locations in the project. one is under root directory(app-->node_modeules) another one is under(app-->test-->node_modules)
Simply Right click on each folder and then selected Mark Directory As --> Excluded
It resolved my problem. Hope it would be helpful.
After struggling with this issue for around a week and searching all the solution I came to below conclusion:
either upgrade your intellij which gives you feature to pause the indexing ( I can't upgrade my intellij due to license issues ) so the other option was to disable all the plugins and then try enabling as per the need one by one.
After enabling any of the plugin if you see it behaving the same uninstall the plugin and download some alternative of it.
If longer indexing is an issue you can enable the shared indexes.
Add this plugin in your intellij and follow the instructions from here.
In my case i had constantly indexing files in Angular application when i remove node_modules folder.
I've tried to invalidate caches multiple times what didn't help at all.
Only solution was to remove project with clear Git state and reclone project - than everything started to work just flawlessly.

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.

How do I share IntelliJ Run/Debug configurations between projects?

I have many different versions of my app. Each one is a separate IntelliJ project. Every time I open a new one, the list of configurations starts blank:
The annoying thing about this is I deploy to 1 VM and I have to copy and paste the debug configurations each time I want to test a different version. IntelliJ makes this dialog modal per IntelliJ Instance, so I can't copy and paste the fields between Project Instances.
I end up taking a screenshot of one configuration and copying the fields by hand into the other project. It's a pretty primitive solution. Is there a more convenient way to get a run configuration from one project to another?
I'm using IntelliJ 13 on Windows 7.
Can I share settings for IntelliJ Idea across different projects? may have the answer to this, but the question is different. It's about window layout. Therefore I don't consider it a duplicate.
The best way to do this is to click the "share" checkmark next to Name field when you edit/create the configuration. You can get to this Dialog with Run > Edit Configurations.
The share check-mark pulls the setting out of your workspace.xml and instead puts it in the directory .idea\runConfigurations. This is designed so you can share the setting with others.
You could copy this file and put it in the same location in all your idea projects.
However, in the future, you might want to consider using source control branches for app versions rather than separate projects. IntelliJ handles these very well.
UPDATE (June 2021):
IntelliJ now puts this in the .run folder as its own file, no longer in .idea/runConfigurations.
Run configurations are stored in .idea/workspace.xml by default. First alternative is to share this file but it is not feasible because you also share a lot of unnecessary configurations.
As already said, the first step is to check "share" option to separate run configurations from workspace.xml.
After that, I recommend adding runConfigurations to source control. But the main problem is, probably you have already marked .idea folder as ignored.
You can unignore the folder by configuring your source control system. For example, if you are using git, you can change .gitignore file as follows:
.idea/*
!/.idea/runConfigurations
don't forget adding * after .idea/
As the last step, add your run configurations to source control and enjoy your shared configurations!
goto
Run > Edit Configuration > create or select existing configuration you want to use > click save and persist it on file system > click on share check mark
now copy this file from
PROJECT_ROOT_DIRECTORY/.idea/runConfigurations/ConfigurationName.xml
to your NEW_PROJECT_ROOT_DIRECTORY/.idea/runConfigurations at the same place and it is available now to your run configuration
You should copy the folder
~/your-old-project/.idea/runConfigurations
to
~/your-new-project/.idea/
That's the folder that contains the run configurations.
An update for this question with the new IntelliJ updates:
Now you can "Store as project file" which will create a folder named ".run" and export your setting to that folder. In the example below, I did it for all my test settings. This removes the requirement of editing .gitignore since files are now not outside of ./idea
This is not exactly an answer to your question but it answers a question similar to your question and one that I had, and I'm assuming others might as well.
That is, How to save unit and instrumentation test run configurations? I usually right-click on the test directory which brings up a menu with the option to Run whatever is in that directory. AndroidStudio then creates a run configuration on the fly and in the Run Configuration drop-down menu a new option will appear, "Save new configuration?" or something similar.
Clicking that option brings up the Run Configuration menu and at that point I check the Share box as many others have already mentioned. This then will prompt the version control system to ask me if I want to add this new run configuration file. If you haven't registered your version control system you can find the new files under .idea/runConfigurations.

Start two instances of IntelliJ IDE

Well my question is pretty simple, how do I start two instances of IntelliJ (community edition).
When I have one instance started and I try to start another one, all that happens is that my started instance gets focus.
I'm developing Android applications using IntelliJ.
Any thoughts?
Press Ctrl+Alt+SChoose Appearance & Behavior, then System Settings, check radio button: Open project in new window.
You need to configure each instance to use its own folders for config/plugins/system locations by editing idea.properties file on Windows/Linux and Info.plist on Mac. You can find the details in FAQ.
Note that normally it's not necessary since you can open multiple projects in different IDEA frames within the same instance using File | Open or Open Recent.
CrazyCoder has roughly the right idea. However, setting the config file alone was not sufficient for me to run multiple instances. Here are my steps to get this going (in GNU/Linux, I am sure you can figure out equivalent in other systems):
Create a folder/directory per instance you want to run.
mkdir -p ~/idea/instance-0
Go to the installation directory (e.g. /opt/intellij) and copy the idea.properties (in bin) file over to your instance directory.
cp /opt/intellij/bin/idea.properties ~/idea/instance-0/
Copy 3 more directories: system, plugins, and config. I highly recommend doing this without the running instance
cp -r /opt/intellij/system ~/idea/instance-0/
cp -r /opt/intellij/plugins ~/idea/instance-0/
cp -r /opt/intellij/config ~/idea/instance-0/
mkdir ~/idea/instance-0/log
Open your idea.properties file and update the configurations for your directories:
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE config folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.config.path=${user.home}/config
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE system folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.system.path=${user.home}/system
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.plugins.path=${user.home}/plugins
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.log.path=${user.home}/log
Now, you can start IntelliJ with the new setup:
IDEA_PROPERTIES=~/idea/instance-0/idea.properties /opt/intellij/bin/idea
Obviously, you probably want to put the command in a script file for invocation. This seems to work for me.
File->Settings->General and in section "Startup/Shutdown" check "Confirm window to open project in"
With Ultimate 2020.2, go to Appearance & Behavior > System Settings in the settings dialog and select the "Ask" option for "Open project in"
As per the directions from jetbrains you'll need go to the 'General' page of the 'Settings' dialog and chose 'Open project in a new window'. Then proceed to open a project as you normally do. IntelliJ should then startup a completely new instance.
There is an other very quick way of doing it. There is always an EAP version of the IDE and it can run at same time with the current one. For example I am using AppCode 2017.2 and 2017.3 EAP in parallel.
Go go to IntelliJ | Tools | Create Command-line Launcher...
Keep the defaults (which creates a binary named "idea"):
Now, go to your command line.
Cd to your project directory and type: idea .
This will create a .idea directory for IntelliJ configurations for that project, which it will re-use each time to start IntelliJ from that directory.
You can now go to a different project directory and type: idea .
Assuming you left the previous IntellJ IDE open, you will now have two IntellJ IDEs open, one for each project.
Notes:
1) If your project uses environment variables, then I'd recommending opening a separate terminal tab/window for each project and set that project's environment variables before running: idea .
2) Depending on what you're trying to accomplish, you may need to modify your classpath (or settings like Project GOPATH) for each IntelliJ instance.
My answer is not directly related to the question but its a solution for some cases where we think we need 2 Intellij instances.
For my issue I was thinking to launch 2 Intellij instances. But after careful thinking and searching for other options, I found an easy and quick solution and I wanna share with the community
If you are looking to compare files between different branches, and you wanna compare the difference, that can be done with git comparison. You don't need 2 different Intellij instances.
My Case:
In my case, I wanted to copy very specific code from 1 branch to another and I wanted to compare the difference between the code. The restriction was, I can't do git merge or cherry-pick because we didn't want full commit to be part of new branch. Just few necessary lines were required in the new branch.
My Solution:
Select the branch
Open the file where you wanna insert code
Right Click -> Git -> Compare with... (refer to pic)
Select the branch and you will get the difference
Append or Copy the difference
If you have new files or directories, you can create it manually and copy-paste the content
I know this answer doesn't directly relates to what has been asked, but sometimes we miss alternative solutions.
Hope this can be helpful as an alternative solution.
In addition to the above comments from #crazycoder and #magice, Make sure that you are not trying to load Pycharm with the same project two times which happened to me!!!.
For example, in windows10 already loaded with ONLY one project in PyCharm and tried to load another Pycharm instance by clicking on the PyCharm desktop shortcut or from task-bar if added. In this case, Pycharm will not load the second instance.
I have wasted some time here. So, wanted to share with the community as it will help someone out there!!
Cheers,