diff --git a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java index 26fde4cc6b80..4d78e59b529b 100644 --- a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java +++ b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java @@ -21,8 +21,18 @@ private static void initializeLibraries() { File parser = null; try { var whereAmI = Parser.class.getProtectionDomain().getCodeSource().getLocation(); - File dir = new File(whereAmI.toURI()).getParentFile(); - parser = new File(dir, name); + var d = new File(whereAmI.toURI()).getParentFile(); + File path = null; + while (d != null) { + path = new File(d, name); + if (path.exists()) break; + d = d.getParentFile(); + } + if (d == null) { + throw new LinkageError( + "Cannot find parser in " + new File(whereAmI.toURI()).getParentFile()); + } + parser = path; System.load(parser.getAbsolutePath()); } catch (URISyntaxException | LinkageError e) { File root = new File(".").getAbsoluteFile();