I had the same issue, which I haven’t fully understood. However, I have gotten passed this by trying out the Getting Started Guide for building Java Projects with Gradle.
Prior to the guide, I made sure I had GRADLE_HOME and GRADLE_USER_HOME set.
Then I just made a Java project folder, switched to that folder, created the src/main/java/hello/ directory and the java classes. Executed gradle
command in that project folder, and it created the .gradle folder without error.
Created the build.gradle file with the java plugin and executed gradle build
and that built the project.
TLDR: I guess you need some kind of project structure to execute gradle in.
UPDATE: I think I understand a little more now. Seems I can run the gradle
command in any other directory without much fuss except the user home directory where ~/.gradle lives. This is because that’s the directory where the gradle daemon runs. I tried to delete the ~/.gradle directory, and it basically killed the daemon. I’m sure I messed up my system by doing this