Skip to content

Commit 9e1500c

Browse files
committed
Do not use user.dir to pass PWD to JRuby
Various releases of Java have ignored user.dir updates, which causes this form of PWD-passing to fail on those versions. Just use JRuby's -C flag, which bypasses user.dir. See https://bugs.openjdk.org/browse/JDK-8291662
1 parent 41c3cf2 commit 9e1500c

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

ruby-tools/src/main/java/de/saumya/mojo/ruby/script/EmbeddedLauncher.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,10 @@ protected void doExecute(final File launchDirectory,
108108
private void doExecute(final File launchDirectory, final File outputFile,
109109
final List<String> args, final boolean warn)
110110
throws ScriptException, IOException {
111-
final String currentDir;
112111
if (launchDirectory != null) {
113-
currentDir = System.getProperty("user.dir");
114-
logger.debug("launch directory: "
115-
+ launchDirectory.getAbsolutePath());
116-
System.setProperty("user.dir", launchDirectory.getAbsolutePath());
117-
}
118-
else {
119-
currentDir = null;
112+
// pass -C <dir> to JRuby
113+
args.add(0, "-C");
114+
args.add(1, launchDirectory.getAbsolutePath());
120115
}
121116

122117
args.addAll(0, this.factory.switches.list);
@@ -197,9 +192,6 @@ private void doExecute(final File launchDirectory, final File outputFile,
197192
Thread.currentThread().setContextClassLoader(current);
198193
}
199194
System.setOut(output);
200-
if (currentDir != null) {
201-
System.setProperty("user.dir", currentDir);
202-
}
203195
if (this.classRealm != null) {
204196
try {
205197
this.classRealm.getWorld().disposeRealm("pom");

0 commit comments

Comments
 (0)