import java.io.*;
import java.lang.*;
class test {
public static void main(String[] args) throws IOException {
ProcessBuilder pb = new ProcessBuilder("/usr/bin/alacritty");
pb.start();
}
}
This code, run with java test.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;
java.security.PrivilegedActionException: java.security.PrivilegedActionException: java.io.IOException: Cannot run program "/usr/bin/alacritty": error=2, No such file or directory
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
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)
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");
builder.start();
}
}
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?