Backport of fix in master ecl repo. See trac 20845.
diff --git a/src/c/unixfsys.d b/src/c/unixfsys.d
index d3dd4d1..287eded 100644
--- a/src/c/unixfsys.d
+++ b/src/c/unixfsys.d
@@ -158,7 +158,7 @@ current_dir(void) {
                 output = ecl_alloc_adjustable_base_string(size);
                 ecl_disable_interrupts();
                 ok = getcwd((char*)output->base_string.self, size);
-                if (ok == NULL && errno != ENAMETOOLONG) {
+                if (ok == NULL && errno != ERANGE) {
                         perror("ext::getcwd error");
                         ecl_internal_error("Can't work without CWD");
                 }
