Ignore symlinks in project (indexing, code-completion etc)
Is there a feature for telling PHPStorm on a global basis to completly ignore symlinks in a project?
Either hiding them completly or just stop indexing them.
From reading various articles about this topic I already know that I can simly mark the folder as excluded. But it would be really nice, to just tell PHPStorm to stop doing this for every symlink in every project. I read about scopes but I am not sure if this can be configured that way...is there a pattern that matches only symlinks?
请先登录再写评论。
Well it would be easy to fix:
Hi yes I'd like to add my support for this:
I have a project with a number of docker containers as subprojects under the root, but they share common code using symlinks ( and docker build context ).
Every time I search, I find 10 occurrences of the code I'm looking for, and I'm constantly fighting 'background changes / load from disk' when trying to refactor anything.
Having intellJidea etc ignore symlinks for the purpose of search and refactor would be desireable
> Right now only marking such folders as Excluded [...] is the real way to go.
Fine by me, if it would actually work.
I'm developing a composer package - and one common way to do this, is to have the source code in /packages in your project, and that same path added as repository to your composer.json. This causes composer to install your package by creating a symlink to that path in your vendor folder.
All my classes are now found twice, and various refactoring options no longer work because of that. And I can exclude the symlink, the parent folder above the symlink, even the entire vendor folder - does not help. Even after invalidating the cache and re-indexing everything, the classes are still found twice - once in the /packages folder, and once via the EXCLUDED symlink.
I'd have to delete the symlink, re-index the project, do the refactor, and run composer install to re-create the symlink and make the app work again.
If it's not possible to ignore symlinks, then PLEASE at least make it so that excluding the symlink actually works!
Sorry that it didn't help. Seems like there's no other options atm, here are corresponding reports at our tracker: https://youtrack.jetbrains.com/issue/IDEA-127022 & https://youtrack.jetbrains.com/issue/IDEA-189247.
I can confirm that the `indexer.follows.symlinks` does NOT help for projects with symlinks to other large projects in IDEA 2024.1.1. The indexer may skip symlinks, but other tasks don't.
Steps to reproduce:
0) Uncheck `indexer.follows.symlinks` to supposedly stop indexing things behind symlinks.
1) Add a directory to a project with symlinks many to other projects.
2) Open that project in IDEA for the first time (or delete .idea/ before opening).
Idea will get stuck at “Opening a project”. Even closing that project, while having other window opened, makes IDEA stuck at “Project analysis update”.
In the end, the only think left to do is `killall -9 java`.
Given that symlinks can point anywhere, and can even create a loop, and that symlinks are kind of advanced/unusual aspect of projects,
I really think that IDEA should not follow symlinks by default.
Imagine a project with a symlink to `/`. Is it really wise to scan that for anything, and risk crashing IDEA? Or is it better to be on the safe side by default?
This just affected me. REALLY freaking annoying and quite frankly absurd this hasn't been resolved.
Beep We REALLY need a solution to this. I am working on a 3rd party project that has symlinks in the web subdirectory pointing to millions of files. IDEA is just freezing. It can't be that hard to turn off indexing for symlinks or directories with some sort of IGNORE directive surely (like "ignore" in the project hierarchy directory tagging)? I have set both my HUGE hierarchies to "ignore" and no dice. PLEASE fix this.
I see. Please open Help > Find Action and open Registry...
Then find "indexer.follows.symlinks" and disable it. You can use search-as-you-type there to find it. Check if that helps with the issue.
Probably that plugin https://plugins.jetbrains.com/plugin/16110-symlink-excluder may be helpful
Searching by "simlink" in plugin marketplace from inside PHPStorm I can see these plugins exist too:
Exclude Symlinks
https://plugins.jetbrains.com/plugin/9613-exclude-symlinks
IDEA Resolve Symlinks
https://plugins.jetbrains.com/plugin/16429-idea-resolve-symlinks
Symlink Excluder (already linked above by Pavel)
https://plugins.jetbrains.com/plugin/16110-symlink-excluder
Each offers similar but not identical functionality, read the description for which does best for you.
Sorry, Michael, missed your comment.
Is there any chance that you have your package also added to "Settings/Preferences | PHP > Include path"?
My situation is ridiculously trivial… I have two repositories side-by-side in a folder/project, and one has a symlink to the other.
.git in linked repo is now discovered and I see all the changes twice.
That did not happen until recently.
I'm running PHPStorm 2023.3.2
Hi there,
There are no such options AFAIK. And such option does not make much sense in general -- what if somebody wants to keep some big shared library outside of the project and use it via symlink (think about old style projects where no composer or any other dependency management system is used (e.g. not even git)) .. or just some other helper code that is not needed beyond development environment (IDE helpers etc).
Right now only marking such folders as Excluded or marking individual files (if there few of them) as Plain Text is the real way to go. Custom scopes will not help here at all (they are not taken into consideration when doing Code Completion/Indexing)
On related note:
Did you get anywhere Michael? Symlink indexing (I think) is locking up my system and I can't work. I excluded the web directory but the indexer still goes there. I followed the advice at this link and it's still locking up. Maybe it's not even the indexer as there is no "indexing" status on the bottom status bar.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000556530-IntelliJ-2017-2-2-constantly-freezing-in-a-Symfony-project-
@Richard Riley I think you misunderstood. It would be easy to fix (for Jetbrains), but it's not fixed until now.
Still waiting for a feedback...
No I didn't misunderstand. Jetbrains have refused it as their issue, There is a another list on this - probably at the github for the symfony extension. Putting my PC into "low power mode" fixes it btw.
Yup.
Replied in another thread
Marking them symlink directories as Excluded sounds about right to me.
Dmitry Tronin which thread?
I believe it's that one.
What issue are you experiencing exactly?
Thanks for the prompt reply.
I'm using PyCharm and a virtualenv typically creates two folders `lib` and `lib64` where `lib64` is a symbolic link to `lib`, during indexing I see that PyCharm scans both directories.
I can manually exclude one of them but I was wondering if there is anything in PyCharm that can help with this and stumbled upon this thread.
After all, there might be some sense in not indexing twice the same directory.
Thanks for the tip; I disabled the flag but `lib64` is still scanned during indexing after restarting PyCharm with 'Invalidate Cache'
@Michael Huber Could you please try one trick?
You may want to open the internal IDE Registry (Help > Find action > "Registry") and untick the "indexer.follows.symlinks" option and restart the IDE. Does it help?
What finally did work for me, after quite a bit of trial and error, is to exclude everything BELOW the Symlink.
It would seem that excluding works recursively through folders - but does stop at symlinks.
I can try fiddling with the Registry... I guess
Nope, that does not work.
After removing the Exclusions, removing the checkbox "indexer.follows.symlinks" and restarting the IDE the classes in the package are back to being shown twice, and refactoring options like "move method" fail with the Error "There are several classes with specified name ...".
Setting the checkbox again, adding the Exclusions again, and restarting the IDE... and move method still fails...
Oh come on... I remember that working yesterday, after I set the Exclusions like this...
Oh, yes, it would seem that everything in composers' vendor folder is in the include path.
I don't remember adding all that stuff though.
Thanks, that did the trick.
Removing the include and unchecking the indexer.follows.symlinks allows me to move methods from one class to another now.
@Ondrej Zizka Hi, I have created a related issue here https://youtrack.jetbrains.com/issue/IDEA-353859 (Project-wide analysis doesn't follow "indexer.follows.symlinks" registry).
As a workaround, you could disable the `pwa.enabled` registry, or you could open `.idea/misc.xml` folder from a text editor, remove `<component name="PWA">` section in it, and reopen the IDE.