How to prevent storing files in user home?


(David Resnick) #1

I have a build running gradle 1.0 milestone 7. On CI server the build is run with -Dgradle.user.home=/tmp/home but I’ve now had a failure when it was unable to access a file in the original user home. The build failed with the below error.

How can I ensure that the build will not attempt to access the user home directory?

Thanks, David

FAILURE: Build failed with an exception.
  * What went wrong:
Could not resolve group:com.trigonic, module:gradle-rpm-plugin, version:0.9.
Required by:
    :proj:1.0
Cause: several problems occurred while resolving :
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
  * Try:
Run with --info or --debug option to get more log output.
  * Exception is:
org.gradle.api.internal.artifacts.ivyservice.ModuleVersionResolveException: Could not resolve group:com.trigonic, module:gradle-rpm-plugin, version:0.9.
Required by:
    :proj:1.0
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyResolverBackedDependencyToModuleResolver$DefaultModuleVersionResolver.getDescriptor(IvyResolverBackedDependencyToModuleResolver.java:86)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ModuleVersionSelectorResolveState.resolve(DependencyGraphBuilder.java:870)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DefaultModuleRevisionResolveState.getDescriptor(DependencyGraphBuilder.java:606)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(DependencyGraphBuilder.java:309)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(DependencyGraphBuilder.java:285)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:119)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:55)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:68)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:36)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:34)
 at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:126)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:99)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:49)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:34)
 at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:42)
 at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDependencyResolver.java:78)
 at org.gradle.api.internal.artifacts.ivyservice.EventBroadcastingArtifactDependencyResolver.resolve(EventBroadcastingArtifactDependencyResolver.java:37)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:36)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:234)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:493)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:204)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
 at org.gradle.api.internal.initialization.DefaultScriptHandler.updateClassPath(DefaultScriptHandler.java:36)
 at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:118)
 at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
 at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:475)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:74)
 at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
 at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
 at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38)
 at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:35)
 at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:451)
 at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:446)
 at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:137)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:76)
 at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
 at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
 at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
 at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:238)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:222)
 at org.gradle.launcher.Main.doAction(Main.java:48)
 at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
 at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
 at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
 at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
 at org.gradle.launcher.Main.main(Main.java:39)
 at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
 at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
 at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
 at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
 at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:124)
 at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:53)
Caused by: java.lang.RuntimeException: several problems occurred while resolving :
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 Could not open cache dynamic-revisions.bin (/home/user/.gradle/caches/artifacts-7/dynamic-revisions.bin).
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.throwResolutionFailure(UserResolverChain.java:159)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.findLatestModule(UserResolverChain.java:108)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.getDependency(UserResolverChain.java:73)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyResolverBackedDependencyToModuleResolver$DefaultModuleVersionResolver.getDescriptor(IvyResolverBackedDependencyToModuleResolver.java:83)
 ... 56 more
    BUILD FAILED
  Total time: 15.09 secs

#2

To set the gradle home directory, use the ‘–gradle-user-home’ command line option:

gradle --gradle-user-home=/tmp/home

I just tried this and it works for all gradle caches. Unfortunately, there seems to be a bug where the ~/.gradle/jna directory will always be created. Not sure if this bug will effect you.


(Peter Niederwieser) #3

According to the user guide, -Dgradle.user.home and the GRADLE_USER_HOME env variable should work just as well. Has something changed here?


(David Resnick) #4

Thanks for checking, I’ll switch over to using the --gradle-user-home command line option.

The documentation does specify though that a gradle.user.home system property should also set the Gradle user home.


#5

Seems like -Dgradle.user.home is now completely ignored. Looks like a regression to me.