V3.2.1 - Wrong Working Directory? - Could not create service of type TaskHistoryStore using TaskExecutionServices.createCacheAccess()


#1

Gradle gives me the follow error when I do run it with no arguments.

Could not create service of type TaskHistoryStore using TaskExecutionServices.createCacheAccess().
> Failed to create parent directory '/opt/local/bin/.gradle' when creating directory '/opt/local/bin/.gradle/3.2.1/taskArtifacts'

I installed gradle using macports and it placed the gradle bin in /opt/local/bin

I have defined GRADLE_USER_HOME=~/.gradle and created the directory with appropriate permissions.
The gradle daemon is running. Previously the daemon refused to start for the same error quoted above and thats why I defined GRADLE_USER_HOME.

I still get the parent error though and it is still trying to refer to the install location for gradle when I would rather it was trying to create stuff in my user area rather than a area defined to be writable only to root.

Looking at the debug output from gradle, it would seem to be defining the current directory to be equal to the location where the gradle bin is found, so /opt/local/bin which is not the current directory from which I am executing gradle.

$ which gradle
/opt/local/bin/gradle
$ pwd
/Users/Me

$ gradle --debug

06:00:19.626 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: /Users/Me/.gradle/native
06:00:20.124 [INFO] [org.gradle.internal.buildevents.BuildLogger] Starting Build
06:00:20.128 [DEBUG] [org.gradle.internal.buildevents.BuildLogger] Gradle user home: /Users/Me/.gradle
06:00:20.129 [DEBUG] [org.gradle.internal.buildevents.BuildLogger] Current dir: /opt/local/bin
06:00:20.129 [DEBUG] [org.gradle.internal.buildevents.BuildLogger] Settings file: null
06:00:20.130 [DEBUG] [org.gradle.internal.buildevents.BuildLogger] Build file: null
06:00:20.133 [DEBUG] [org.gradle.initialization.buildsrc.BuildSourceBuilder] Starting to build the build sources.
06:00:20.133 [DEBUG] [org.gradle.initialization.buildsrc.BuildSourceBuilder] Gradle source dir does not exist. We leave.
06:00:20.134 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found env project properties: []
06:00:20.134 [DEBUG] [org.gradle.initialization.DefaultGradlePropertiesLoader] Found system project properties: []
06:00:20.308 [DEBUG] [org.gradle.initialization.ScriptEvaluatingSettingsProcessor] Timing: Processing settings took: 0.174 secs
06:00:20.310 [INFO] [org.gradle.internal.buildevents.BuildLogger] Settings evaluated using settings file '/master/settings.gradle'.

I’ve looked through the forums and thats where I got the tip about the GRADLE_USER_HOME and it solved part of the problem but not all of it. I think its getting the current dir wrong. Any suggestions ?


(sbc ds) #2

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 :slight_smile: