Change the default path of Import Project in intellij - intellij-idea

I am trying to open an existing Maven project in Intellij. I am running intellij off of a development server because, directly running Intellij from windows would block me from accessing the databases, services etc.,
Now it opens /home/my-username by default in the open project popup. The problem is that /home is a nfs directory and it is the home folder of 3000+ developers and as soon as the popup opens, it starts indexing everything in that directory. I literally let it run for like an hour+ and it got no where. How do I set the default path of this popup so it only points to my home directory?

You can go to Settings -> Appearance & Behavior -> System Settings and under Project Opening, set the Default directory.

Related

File created through Intellij IDEA not show on window's file system

I have been used Intellij for couple years, recent I found a weird thing, I use Maven to auto import my dependencies, and Maven downloads all libraries and put under "~.m2\repository\" folder, when I open that folder using window file explorer, the folder is not exist. I manually create that folder, it's empty. but if I right click on the project in Intellij IDEA, and click "show in explorer", then go to "~.m2\repository\" folder, I can see all libraries there, and the folder is a little slow to open, seems like it's from some network storage.
any idea?
Thanks

Change home directory for opening projects in IntelliJ

I've been searching around and confused with the results here as the others here in stackoverflow are saying its not possible or is via the vmoptions file. But all I wanted was just simply change the projects home directory showing when I'm opening my projects as I have to navigate too many folders just to get to my directory where all my projects are. Hence I'm posting this question.
To do so, after opening IntelliJ with any existing project,
Go to File > Settings / Ctrl + Alt + S
On the left pane, navigate to Appearance & Behavior . System Settings
Find the Project Opening section, and then click the folder icon to find the directory to set the new home directory for opening projects.
Click Apply
Then you'd now be able to automatically navigate to this directory whenever trying to open your projects 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.

PhpStorm Deployment menu greyed out

I've added a server in PhpStorm deployment settings but the Tools -> Deployment -> Upload to menu is still greyed out.
You need to specify a deployment path mapping in your server. Even if it's just the root path, you need to enter /. PhpStorm doesn't do it automatically.
Go to your server in deployment settings, click the 'Mappings' tab and enter slash (or your mapping) in the 'Deployment path on server' field. You don't need to enter a web path. Deployment menu should be ungreyed now.
In version 2019.2, if you dont set the path to / in mapping, it will grayed out.
Previous version, you could leave it blank
Also, if your local path (inside mappings configuration) is not your project root, you have to click on the deployable folder in the project tree to enable the menu.
Also, if the Deployment menu is completely missing at the bottom of the context menu, then set up a default server.
Click the server with the check mark to make a server the default option for a project.
Then you will get this additional menu when you right click on a file, folder, or the project.
I also encountered this issue in PyCharm Professional 2022.1.
Since the aforementioned solutions did not work for me, and it took me some time to resolve, I am providing the solution I found.
Clicking on Tools -> Deployment -> upload to servername was not working for me no matter what I tried.
However, I could right-click on the main project folder (on the left of the PyCharm window, where the project folder/file structure is visible). This right-click opens a menu, where there is an option for deployment -> upload to servername.
Once I clicked this, not only it worked, but the classical way (Tools -> Deployment -> upload to ) ceased to be grayed out also.
If deployment was available and suddenly no longer works, confirm that your credentials didn't get wiped from the deployment settings (Connection tab).
If any of these answers don't help, because you can't even see the server menu, you probably have the Remote Hosts Access plugin disabled.
Go to settings, go to the plugins, and enable Remote Hosts Access.
Please check if the following options are enabled in settings(Ctrl+Alt+S). It goes uncheck if Php Storm crashes. Check the below options and restart the editor.
This works for ver 2017.2.1
Also, check Windows->Store current layout as the default just to make sure in the future you can restore the layout.
It's possible the opened file in the editor belongs to a External Library (bottom of project tree).
These External library files can't be deployed.

How to configure custom PYTHONPATH with VM and PyCharm?

I am using IntelliJ with the Python plugin and the Remote Interpreter feature to communicate with my Vagrant VM. It sets up the remote interpreter correctly to use my VM's interpreter. But, I use a custom PYTHONPATH in my VM, and I would like IntelliJ to recognize that path and include the modules in that path when developing.
How do I configure IntelliJ/PyCharm's remote interpreter to use a custom PYTHONPATH on the VM?
For PyCharm 5 (or 2016.1), you can:
select Preferences > Project Interpreter
to the right of interpreter selector there is a "..." button, click it
select "more..."
pop up a new "Project Interpreters" window
select the rightest button (named "show paths for the selected interpreter")
pop up a "Interpreter Paths" window
click the "+" buttom > select your desired PYTHONPATH directory (the folder which contains python modules) and click OK
Done! Enjoy it!
Instructions for editing your PYTHONPATH or fixing import resolution problems for code inspection are as follows:
Open Preferences (On a Mac the keyboard short cut is ⌘,).
Look for Project Structure in the sidebar on the left under Project: Your Project Name
Add or remove modules on the right sidebar
EDIT: I have updated this screen shot for PyCharm 4.5
To me the solution was to go to
Run > Edit Configuration > Defaults > Python
then manage the
"Add content roots to PYTHONPATH" and
"Add source root to PYTHONPATH"
checkboxes, as well as setting the "Working directory" field.
If you have set up your own Run/Debug Configurations then you might want to go to
Run > Edit Configuration > Python > [Whatever you called your config]
and edit it there.
My problem was that I wanted to have my whole repository included in my PyCharm 2016.2 project, but only a subfolder was the actual python source code root. I added it as "Source Root" by right clicking the folder then
Mark directory as > Source Root
Then unchecking "Add content roots to PYTHONPATH" and checking "Add source root to PYTHONPATH" in the Run/Debug config menu. I then checked the folder pathing by doing:
import sys
logger.info(sys.path)
This outputed:
[
'/usr/local/my_project_root/my_sources_root',
'/usr/local/my_project_root/my_sources_root',
'/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages'
]
However, without the fix it said:
[
'/usr/local/my_project_root/my_sources_root',
'/usr/local/my_project_root', <-- NOT WANTED
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages'
]
Which meant I got the project root folder included. This messed up the pathing for me.
This was done with PyCharm Community 2019.1
Go to Project Settings
Go to Project Structure and right click on the directory you want to add and click "Sources"
This should add the directory to your pythonpath
An update to the correct answer phil provided, for more recent versions of Pycharm (e.g. 2019.2).
Go to File > Settings and find your project, then select Project Interpreter. Now click the button with a cog to the right of the selected project interpreter (used to be a ...).
From the drop-down menu select Show All... and in the dialog that opens click the icon with a folder and two sub-folders.
You are presented with a dialog with the current interpreter paths, click on + to add one more.
In my experience, using a PYTHONPATH variable at all is usually the wrong approach, because it does not play nicely with VENV on windows. PYTHON on loading will prepare the path by prepending PYTHONPATH to the path, which can result in your carefully prepared Venv preferentially fetching global site packages.
Instead of using PYTHON path, include a pythonpath.pth file in the relevant site-packages directory (although beware custom pythons occasionally look for them in different locations, e.g. enthought looks in the same directory as python.exe for its .pth files) with each virtual environment. This will act like a PYTHONPATH only it will be specific to the python installation, so you can have a separate one for each python installation/environment. Pycharm integrates strongly with VENV if you just go to yse the VENV's python as your python installation.
See e.g. this SO question for more details on .pth files....
Latest 12/2019 selections for PYTHONPATH for a given interpreter.
Well you can do this by going to the interpreter's dialogue box. Click on the interpreter that you are using, and underneath it, you should see two tabs, one called Packages, and the other called Path.
Click on Path, and add your VM path to it.
In pycharm 5 follow this,
https://www.jetbrains.com/pycharm/help/configuring-python-interpreter-for-a-project.html
1)Open the Settings dialog box, and click Project Interpreter page.
2)In the Projects pane, choose the desired project.
3)For the selected project, choose SDK from the list of available Python interpreters and virtual environments.
In Intellij v2017.2 you can go to:
run > edit configurations > click ... next to the field 'Environment variables' > click the green + sign
Name= PYTHONPATH
value= your_python_path
Pycharm 2020.3.3 CE ZorinOS(Linux) File>Settings > Project Structure > {select the folder} > Mark as Source(blue folder icon) > Apply
To verify:
import sys
print(sys.path)
Selected path should be listed here.