Gradle build crashes when network is disabled


(Pavel Dudka) #1

I have a build machine with super restricted network access (network access is not allowed), so gradle build crashes (stack trace below).

I tried to provide --offline flag, but it didn’t help.
Build command: gradle assemble --offline
Gradle version: 2.10

Any help is much appreciated

11:27:53.622 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface en0
11:27:53.631 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
11:27:53.635 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
11:27:53.636 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /\redacted
11:27:53.636 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /\redacted
11:27:53.637 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote multicast interface en0
11:27:53.637 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface lo0
11:27:53.638 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? true
11:27:53.639 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
11:27:53.639 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Ignoring remote address on loopback interface /fe80:0:0:0:0:0:0:1%lo0
11:27:53.640 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback address /0:0:0:0:0:0:0:1
11:27:53.640 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback address /127.0.0.1
11:27:53.641 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface lo0
11:27:53.649 [ERROR] [org.gradle.BuildExceptionReporter]
11:27:53.650 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
11:27:53.651 [ERROR] [org.gradle.BuildExceptionReporter]
11:27:53.651 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
11:27:53.652 [ERROR] [org.gradle.BuildExceptionReporter] java.net.BindException: Operation not permitted
11:27:53.653 [ERROR] [org.gradle.BuildExceptionReporter]
11:27:53.653 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
11:27:53.654 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.UncheckedIOException: java.net.BindException: Operation not permitted
11:27:53.655 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:43)
11:27:53.655 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.FileLockCommunicator.(FileLockCommunicator.java:40)
11:27:53.655 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler.getCommunicator(DefaultFileLockContentionHandler.java:153)
11:27:53.656 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler.reservePort(DefaultFileLockContentionHandler.java:145)
11:27:53.656 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:79)
11:27:53.657 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:67)
11:27:53.657 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.OnDemandFileAccess.readFile(OnDemandFileAccess.java:36)
11:27:53.657 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.SimpleStateCache.get(SimpleStateCache.java:40)
11:27:53.658 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.FileIntegrityViolationSuppressingPersistentStateCacheDecorator.get(FileIntegrityViolationSuppressingPersistentStateCacheDecorator.java:31)
11:27:53.658 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getAll(PersistentDaemonRegistry.java:62)
11:27:53.659 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getIdle(PersistentDaemonRegistry.java:77)
11:27:53.659 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:80)
11:27:53.659 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:123)
11:27:53.660 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:80)
11:27:53.660 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
11:27:53.662 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
11:27:53.662 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
11:27:53.663 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
11:27:53.663 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
11:27:53.663 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
11:27:53.664 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
11:27:53.664 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
11:27:53.664 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
11:27:53.665 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
11:27:53.665 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(Main.java:33)
11:27:53.665 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
11:27:53.666 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:27:53.666 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
11:27:53.666 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:27:53.667 [ERROR] [org.gradle.BuildExceptionReporter] at java.lang.reflect.Method.invoke(Method.java:497)
11:27:53.667 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
11:27:53.667 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
11:27:53.668 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
11:27:53.668 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.net.BindException: Operation not permitted
11:27:53.668 [ERROR] [org.gradle.BuildExceptionReporter] at java.net.PlainDatagramSocketImpl.bind0(Native Method)
11:27:53.669 [ERROR] [org.gradle.BuildExceptionReporter] at java.net.AbstractPlainDatagramSocketImpl.bind(AbstractPlainDatagramSocketImpl.java:94)
11:27:53.669 [ERROR] [org.gradle.BuildExceptionReporter] at java.net.DatagramSocket.bind(DatagramSocket.java:392)
11:27:53.669 [ERROR] [org.gradle.BuildExceptionReporter] at java.net.DatagramSocket.(DatagramSocket.java:242)
11:27:53.670 [ERROR] [org.gradle.BuildExceptionReporter] at java.net.DatagramSocket.(DatagramSocket.java:299)
11:27:53.670 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.cache.internal.FileLockCommunicator.(FileLockCommunicator.java:38)
11:27:53.671 [ERROR] [org.gradle.BuildExceptionReporter] … 31 more
11:27:53.671 [ERROR] [org.gradle.BuildExceptionReporter]


(Mark Vieira) #2

This is happening due to the Gradle daemon trying to bind to a local address. If you don’t have local permissions to bind to any network interfaces then you cannot use the daemon unfortunately. You can perhaps try running with --no-daemon.

That said, other issues will arise like executing tests or forked compilation, which are also done in an external process which the main build needs to communicate with. I’d suggest, if possible, relaxing these restrictions to at least allow applications to listen on the loopback interface.


(Pavel Dudka) #3

Tried to use --no-daemon flag - previous error is gone now, but I’m not sure I understand stack trace now… It seems like Gradle is still trying to start a daemon process… :

gradle assemble --offline --no-daemon

10:58:22.577 [LIFECYCLE] [org.gradle.launcher.daemon.client.SingleUseDaemonClient] To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.12/userguide/gradle_daemon.html.
10:58:22.611 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonStarter] Using daemon args: [/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java, -XX:+HeapDumpOnOutOfMemoryError, -Xmx4g, -Dfile.encoding=UTF-8, -Duser.country=US, -Duser.language=en, -Duser.variant, -cp, /usr/local/gradle/lib/gradle-launcher-2.12.jar]
10:58:22.623 [INFO] [org.gradle.launcher.daemon.client.DefaultDaemonStarter] Starting daemon process: workingDir = /private/var/tmp/gradle/daemon/2.12, daemonArgs: [/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java, -XX:+HeapDumpOnOutOfMemoryError, -Xmx4g, -Dfile.encoding=UTF-8, -Duser.country=US, -Duser.language=en, -Duser.variant, -cp, /usr/local/gradle/lib/gradle-launcher-2.12.jar, org.gradle.launcher.daemon.bootstrap.GradleDaemon, 2.12]
10:58:22.730 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process ‘Gradle build daemon’. Working directory: /private/var/tmp/gradle/daemon/2.12 Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -XX:+HeapDumpOnOutOfMemoryError -Xmx4g -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/local/gradle/lib/gradle-launcher-2.12.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.12

10:58:23.765 [INFO] [org.gradle.launcher.daemon.client.DefaultDaemonStarter] An attempt to start the daemon took 1.141 secs.
10:58:23.769 [ERROR] [org.gradle.BuildExceptionReporter]
10:58:23.770 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
10:58:23.771 [ERROR] [org.gradle.BuildExceptionReporter]
10:58:23.771 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
10:58:23.772 [ERROR] [org.gradle.BuildExceptionReporter] Unable to start the daemon process.
10:58:23.772 [ERROR] [org.gradle.BuildExceptionReporter] This problem might be caused by incorrect configuration of the daemon.
10:58:23.772 [ERROR] [org.gradle.BuildExceptionReporter] For example, an unrecognized jvm option is used.
10:58:23.773 [ERROR] [org.gradle.BuildExceptionReporter] Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.12/userguide/gradle_daemon.html
10:58:23.773 [ERROR] [org.gradle.BuildExceptionReporter] Please read the following process output to find out more:
10:58:23.774 [ERROR] [org.gradle.BuildExceptionReporter] -----------------------
10:58:23.774 [ERROR] [org.gradle.BuildExceptionReporter]
10:58:23.775 [ERROR] [org.gradle.BuildExceptionReporter]
10:58:23.775 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
10:58:23.776 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.GradleException: Unable to start the daemon process.
10:58:23.777 [ERROR] [org.gradle.BuildExceptionReporter] This problem might be caused by incorrect configuration of the daemon.
10:58:23.777 [ERROR] [org.gradle.BuildExceptionReporter] For example, an unrecognized jvm option is used.
10:58:23.777 [ERROR] [org.gradle.BuildExceptionReporter] Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.12/userguide/gradle_daemon.html
10:58:23.778 [ERROR] [org.gradle.BuildExceptionReporter] Please read the following process output to find out more:
10:58:23.778 [ERROR] [org.gradle.BuildExceptionReporter] -----------------------
10:58:23.778 [ERROR] [org.gradle.BuildExceptionReporter]
10:58:23.779 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.bootstrap.DaemonGreeter.parseDaemonOutput(DaemonGreeter.java:35)
10:58:23.779 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(DefaultDaemonStarter.java:152)
10:58:23.779 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startDaemon(DefaultDaemonStarter.java:133)
10:58:23.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:110)
10:58:23.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.SingleUseDaemonClient.execute(SingleUseDaemonClient.java:53)
10:58:23.780 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.daemon.client.SingleUseDaemonClient.execute(SingleUseDaemonClient.java:37)
10:58:23.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
10:58:23.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
10:58:23.781 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
10:58:23.782 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
10:58:23.782 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
10:58:23.782 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
10:58:23.783 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
10:58:23.783 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
10:58:23.783 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
10:58:23.784 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
10:58:23.784 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(Main.java:33)
10:58:23.784 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
10:58:23.785 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:58:23.785 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:58:23.785 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:58:23.785 [ERROR] [org.gradle.BuildExceptionReporter] at java.lang.reflect.Method.invoke(Method.java:497)
10:58:23.786 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
10:58:23.786 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
10:58:23.786 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
10:58:23.787 [ERROR] [org.gradle.BuildExceptionReporter]


(Mark Vieira) #4

Looks like there are some custom JVM arguments configured somewhere (probably a gradle.properties file or environment variable) that is causing Gradle to fork a separate build process.

Unfortunately, Gradle’s operation is highly dependent network access (at least via the loopback interface). All interprocess communication is done this way and most builds have at least a few worker process involved. There really isn’t a good solution for this besides relaxing the security on the box to at least allow communication over the loopback interface.