Skip to content

Commit 5fbc57b

Browse files
committed
Improve error when the ruby-home internal resource does not exist
1 parent 63acbe0 commit 5fbc57b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/main/java/org/truffleruby/RubyLanguage.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,15 @@ private TruffleFile searchRubyHome(Env env) {
812812
}
813813
}
814814

815-
TruffleFile homeResource;
815+
final TruffleFile homeResource;
816+
TruffleFile homeResourceRelative;
816817
try {
817-
var homeResourceRelative = env.getInternalResource("ruby-home");
818-
homeResource = homeResourceRelative == null ? null : homeResourceRelative.getCanonicalFile();
818+
homeResourceRelative = env.getInternalResource("ruby-home");
819+
if (homeResourceRelative != null && homeResourceRelative.exists()) {
820+
homeResource = homeResourceRelative.getCanonicalFile();
821+
} else {
822+
homeResource = null;
823+
}
819824
} catch (IOException e) {
820825
throw CompilerDirectives.shouldNotReachHere(e);
821826
}
@@ -828,8 +833,8 @@ private TruffleFile searchRubyHome(Env env) {
828833
}
829834

830835
throw new Error("Could not find TruffleRuby's home - not possible to parse Ruby code" + String.format(
831-
" (Truffle-reported home %s and internal resource %s do not look like TruffleRuby's home).",
832-
truffleReported, homeResource));
836+
" (Truffle-reported home %s and internal resource %s (%s) do not look like TruffleRuby's home).",
837+
truffleReported, homeResourceRelative, homeResource));
833838
}
834839

835840
private boolean isRubyHome(TruffleFile path) {

0 commit comments

Comments
 (0)