Can't run a subprocess with a program in /usr/bin from a Gradle build

Consider the following example;

import java.lang.*;

class test {
  public static void main(String[] args) throws IOException {
    ProcessBuilder pb = new ProcessBuilder("/usr/bin/alacritty");

This code, run with java, opens the target program

Now, consider the same code snippet, but run from this Gradle build
This second example, the same code, runs into this error; Cannot run program "/usr/bin/alacritty": error=2, No such file or directory
	at Method)
	at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(

We can rule out this “No such file or directory” as the first example, opening the same program, worked

I’m lost on what could be the cause. I’m using the same direct path in both examples, so it’s not a problem with environments (although they are different quite different, both include /usr/bin)


I tried your sample, and it works fine here:


public class test {

	public static void main(String... args) throws Exception {
		ProcessBuilder builder = new ProcessBuilder("/usr/bin/alacritty");
		// Required because my GPU does not meet requirements otherwise
		builder.environment().put("LIBGL_ALWAYS_SOFTWARE", "1");


plugins {
	id 'application'

application {
	mainClass = 'test'

Both executions open the terminal and immediately return:

/tmp/foo$ alacritty --version
alacritty 0.8.0 (a1b13e68)
/tmp/foo$ ./gradlew --version
Gradle 7.0.2
JVM:          11.0.11 (Oracle Corporation 11.0.11+9)

/tmp/foo$ java --version
openjdk 11.0.11 2021-04-20
/tmp/foo$ java src/main/java/
/tmp/foo$ echo $?
/tmp/foo$ ./gradlew run

2 actionable tasks: 2 executed
/tmp/foo$ echo $?

There must be something else related to your environment that prevents the process to start.
It could be worth trying to disable most of user specific programs, scripts running automatically when the terminal spawns (bashrc, profile, …). Maybe by creating a new user from scratch on your environment. It could help you narrowing the issue.

If your example works for you, then this is probably a problem with my machine specifically. I just set up a new Gradle build with the minimal build.gradle you gave and the same code snippet and it results in the same error I was getting with my main project

Edit: I’ve done a complete reinstall of my distro (PopOS) and the issue is persisting. I’ll try with another distro

Edit: Installed Ubuntu Budgie, no more error. I guess it’s a PopOS bug?