3

I'm relatively new to IntelliJ. I'm using IntelliJ IDEA 2019.2.4.

When I try to do an Import From Existing Source - I get the following error:

Could not create parent directory for lock file C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.4\jbr\bin\proxy\wrapper\dists\gradle-5.3-all\b2xqo51qjs5t4spu8wb5tlf15\gradle-5.3-all.zip.lck

That's new - I didn't used to get that.

Any suggestions?

Thanks much

Tim Mitchell
  • 643
  • 2
  • 13
  • 29
  • 1
    Related: https://stackoverflow.com/questions/45527316/could-not-create-parent-directory-for-lock-file This question is about Android Studio. The solution should be similar since Android Studio is based on IntelliJ. – Code-Apprentice Dec 03 '19 at 00:10
  • What is the project you are attempting to import? Is it an Android app? What directory is the source code in? Is it under `C:\Program Files`? Or somewhere else? – Code-Apprentice Dec 03 '19 at 00:12
  • No - not an android app. Just a regular IntelliJ web app. – Tim Mitchell Dec 03 '19 at 00:32
  • Right now I'm not even sure where to find the "Use default gradle wrapper" option – Tim Mitchell Dec 03 '19 at 00:33
  • Press Ctrl-Shift-A (Cmd+Shift-A on Mac) and type "default gradle wrapper". This will search all the menus and settings in IntelliJ and give you a clue where it is. I always use this keyboard shortcut constantly as I work with IntelliJ, so it's a good one to know. – Code-Apprentice Dec 03 '19 at 02:50
  • Does this answer your question? [Gradle sync failed: Could not create parent directory for lock file](https://stackoverflow.com/questions/56450134/gradle-sync-failed-could-not-create-parent-directory-for-lock-file) – Amin Soheyli Apr 15 '21 at 11:50

5 Answers5

2

Delete C:\Users\yourname.gradle

Then go to File>Settings>Build, Execution, Deployment>Build Tools>Gradle, and edit Gradle user home, to empty, when it's empty, it will automatically set to default.

1

This issue has been discussed by another already (in Android Studio) but I will quickly summarize the issue as it should be quite similar using IntelliJ. Thanks to Mike Hill this will remedy your problem. Here is his answer Could not create parent directory for lock file

The issue you discussed appears to have been caused by using the "Use gradle 'wrapper' task configuration" option in IntelliJ..this option causes IntelliJ to override the Gradle wrapper task (which is sort of expected).

The solution that Mike Hill suggests is to select "Use default gradle wrapper (recommended)" instead. Seems that this caused a conflict with the customized GRADLE_USER_HOME environment variable in IntelliJ for the directory where the final wrapper files actually get stored.

He then provides an absolute path example which may be what is throwing the error for you as well.

Gradle was trying (and failing) to create C:\ProgramData\chocolatey\lib\gradle\tools\gradle-4.5.1\wrapper\dists\gradle-4.5.1-all\87kuriyahurjjkki3zii366f2\gradle-4.5.1-all.zip.lck when run through IntelliJ, although his system uses the file C:\work.gradle\wrapper\dists\gradle-4.5.1-all\87kuriyahurjjkki3zii366f2\gradle-4.5.1-all.zip.lck when working correctly.

Switching and then running the Gradle refresh through IntelliJ seems to have fixed it for Mike. It also succeeds when switching back to "Use gradle 'wrapper' task configuration", now. Hopefully this helps you out Tim!

Tanner Dolby
  • 4,253
  • 3
  • 10
  • 21
0

I did hours of research and I discovered that the localhost:8080 on my program had never fully detached last time I stopped running the program. The program refused to start because really it never stopped from last time. Detach you localhost. If you don't know how just restart the computer--it will detach everything

Kenan
  • 1
  • 1
0

Encountered on Mac. Seems like a bug in IntelliJ IDEA. Changing Gradle user home from ~/.gradle to an absolute path /Users/username/.gradle has actually helped

0

For Android studio on mac (it helps me):

  1. Click settings in top-right
  2. Click preferences
  3. Click "Build, Executio, Deployment" -> Build Tools -> Gradle
  4. Gradle user home: /Users/yourUsername/.gradle
  5. Apply