clear env, dont inherit nix wrapper env
This commit is contained in:
@@ -27,6 +27,7 @@ public final class ShellSession implements AutoCloseable {
|
||||
Map<String, String> environment = new HashMap<>(System.getenv());
|
||||
environment.put("TERM", "xterm-kitty");
|
||||
environment.put("COLORTERM", "truecolor");
|
||||
sanitizeWrapperEnvironment(environment);
|
||||
environment.putAll(envOverride);
|
||||
|
||||
LinuxPty pty = LinuxPty.spawn(
|
||||
@@ -42,6 +43,30 @@ public final class ShellSession implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the variables injected by the Nix launcher wrapper from the shell's
|
||||
* environment so they do not leak into terminal subprocesses.
|
||||
*
|
||||
* <p>jprototerm is launched from a Nix wrapper that prepends Nix store paths to
|
||||
* {@code LD_LIBRARY_PATH} (and adds a GL shim) so the bundled JavaFX/ghostty natives
|
||||
* resolve. If the shell inherited that path, host programs run inside the terminal
|
||||
* (e.g. {@code flatpak}, {@code pdftoppm}) would load the Nix copies of libraries such
|
||||
* as freetype/fontconfig/glib, which in turn drag in the Nix glibc through their
|
||||
* RUNPATHs and clash with the host {@code libc.so.6}. We restore the user's original
|
||||
* {@code LD_LIBRARY_PATH}, captured by the wrapper before it prepended anything.
|
||||
*/
|
||||
private static void sanitizeWrapperEnvironment(Map<String, String> environment) {
|
||||
String hostLibraryPath = environment.remove("JPROTOTERM_HOST_LD_LIBRARY_PATH");
|
||||
if (hostLibraryPath == null || hostLibraryPath.isEmpty()) {
|
||||
environment.remove("LD_LIBRARY_PATH");
|
||||
} else {
|
||||
environment.put("LD_LIBRARY_PATH", hostLibraryPath);
|
||||
}
|
||||
// These are jprototerm's own runtime settings, not the user's shell environment.
|
||||
environment.remove("GDK_BACKEND");
|
||||
environment.remove("JLIBGHOSTTY_LIBRARY");
|
||||
}
|
||||
|
||||
public void startReading(TerminalPane pane) {
|
||||
reader.submit(() -> readOutput(pane));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user