Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory

Im trying to execute a build script using the -b command line option to specify the build.gradle location

$gradlew -b $MYVAR/dir1/dir2/build.gradle mytask --debug

The following error is thrown:

 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.internal.service.ServiceCreationException: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:816)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:749)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectServiceProvider.getInstance(DefaultServiceRegistry.java:540)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:597)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:762)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:748)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectServiceProvider.getInstance(DefaultServiceRegistry.java:540)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:597)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:762)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:748)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectServiceProvider.getInstance(DefaultServiceRegistry.java:540)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:597)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.find(DefaultServiceRegistry.java:296)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:280)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:275)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncherFactory.doNewInstance(DefaultGradleLauncherFactory.java:132)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncherFactory.newInstance(DefaultGradleLauncherFactory.java:81)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.composite.internal.DefaultRootBuildState.<init>(DefaultRootBuildState.java:45)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.composite.internal.DefaultIncludedBuildRegistry.createRootBuild(DefaultIncludedBuildRegistry.java:85)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:45)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:31)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:42)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:28)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:52)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:59)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:36)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:68)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:38)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:37)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:26)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:60)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:55)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:208)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:394)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:367)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:37)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:23)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:360)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:292)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.Main.doAction(Main.java:36)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:31)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.internal.service.ServiceCreationException: Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:816)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:749)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectServiceProvider.getInstance(DefaultServiceRegistry.java:540)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:597)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:762)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:748)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectServiceProvider.getInstance(DefaultServiceRegistry.java:540)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:597)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.find(DefaultServiceRegistry.java:296)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:280)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:275)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.scopes.BuildScopeServices.defaultScriptPluginFactory(BuildScopeServices.java:311)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.scopes.BuildScopeServices.createScriptPluginFactory(BuildScopeServices.java:289)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:34)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:814)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 54 more
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.UncheckedIOException: Failed to create parent directory '/r1/r2/.gradle' when creating directory '/r1/r2/.gradle/5.4.1/fileHashes'
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.util.GFileUtils.mkdirs(GFileUtils.java:327)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:75)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:42)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultCacheFactory.doOpen(DefaultCacheFactory.java:94)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultCacheFactory.open(DefaultCacheFactory.java:68)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultCacheRepository$PersistentCacheBuilder.open(DefaultCacheRepository.java:118)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.changedetection.state.CrossBuildFileHashCache.<init>(CrossBuildFileHashCache.java:45)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.scopes.BuildSessionScopeServices.createCrossBuildFileHashCache(BuildSessionScopeServices.java:164)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:34)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:814)
 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 69 more

Note:
GRADLE_USER_HOME=$MYVAR/dir1/dir2
$MYVAR/dir1/dir2/build.gradle is a symlink pointing to /r1/r2/build.gradle, and folder /r2 is read only, so at this point the error makes

However if i move to the directory where build.gradle is, the task is successfully executed

$ cd $MYVAR/dir1/dir2
$gradlew mytask --debug

Why when i use the -b option, the process is following the symlink and tries to create the .gradle folder there?

For now im stuck with gradle 5.4.1

Thanks