Skip to content

Commit dbd8e2c

Browse files
committed
Errno.handle when getcwd fails in FeatureLoader, as if it was in Ruby
1 parent 5885969 commit dbd8e2c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,10 @@ public DynamicObject getKernelModule() {
10881088
return kernelModule;
10891089
}
10901090

1091+
public DynamicObject getErrnoModule() {
1092+
return errnoModule;
1093+
}
1094+
10911095
public GlobalVariables getGlobalVariables() {
10921096
return globalVariables;
10931097
}

src/main/java/org/truffleruby/language/loader/FeatureLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public String getWorkingDirectory() {
154154
final Pointer buffer = GetThreadBufferNode.getBuffer(context, bufferSize);
155155
final long address = nfi.asPointer((TruffleObject) getcwd.call(buffer.getAddress(), bufferSize));
156156
if (address == 0) {
157-
throw new UnsupportedOperationException("getcwd() failed");
157+
context.send(context.getCoreLibrary().getErrnoModule(), "handle");
158158
}
159159
final byte[] bytes = buffer.readZeroTerminatedByteArray(context, 0);
160160
final Encoding localeEncoding = context.getEncodingManager().getLocaleEncoding();

0 commit comments

Comments
 (0)