Spring Boot project can't be checked out on Windows due to very long file names. git pull and every other operation fails with following error -
error: cannot stat 'spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/JavaPluginActionIntegrationTests-additionalMetadataLocationsCompilerArgumentIsNotAddedWhenAnnotationProcessorIsNotOnTheClasspath.gradle': Filename too long
Comment From: philwebb
What version of Windows are you running? Have you tried checking out the project to somewhere higher up on your drive?
If you're on Windows 10 you could also try this: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
Comment From: kedar-joshi
I am running Windows 10 and I am at D: with long paths already enabled. IMO the problem is with file name length and not the total path length. If it helps, the file name is 134 characters long -
JavaPluginActionIntegrationTests-additionalMetadataLocationsCompilerArgumentIsNotAddedWhenAnnotationProcessorIsNotOnTheClasspath.gradle
Comment From: wilkinsona
Please try to be constructive. Describing something as a “monstrosity” is not.
Comment From: kedar-joshi
@wilkinsona I apologies if it was perceived in a wrong way and I assure you it wasn't my intention. I have great respect for the whole team and I just wanted to state that the file name was 'too long'.
Nonetheless, I have corrected the language. Sorry for the inconvenience.
Comment From: kedar-joshi
@philwebb Further analysis revealed that registry change alone doesn't resolve the issue. Git also needs to be configured to support long file names. Setting git config --system core.longpaths true seems to work for me.
This stackoverflow thread discuss this very issue from git perspective.
https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows
Comment From: wilkinsona
@kedar-joshi Thank you. Does it work on Windows without the registry change but with the long paths config option enabled?
Comment From: kedar-joshi
@wilkinsona Interestingly yes. Windows registry setting plays no role in this context. Enabling long paths in git alone works.
Comment From: wilkinsona
I think this is fixed by https://github.com/spring-projects/spring-boot/commit/9bbccb093a8f0d3840266519605f5abcf468fe76. I can now clone master on Windows 7 without enabling long paths.
Comment From: kedar-joshi
Yup, I can confirm that it works on Windows 10 without long paths. Thank you for the quick turnaround.
Comment From: paulplatteg
Hope this solution work otherwise you can also try long path tool it solved most of my long path problems in windows.
Comment From: glaredark
set git global setting git config --system core.longpaths true or set local setting git config core.longpaths true
check the setting value git config core.longpaths
hope that helps
Comment From: kpouer
I think this is fixed by 9bbccb0. I can now clone master on Windows 7 without enabling long paths.
Hey, I think the problem is back now, however the configuring git to support it helped me (on Windows 11)
Comment From: wilkinsona
Configuring git is the recommended approach.