Skip to content

MCP server fails with "Could not determine current working directory" error on WSL/Ubuntu #1583

@akapug

Description

@akapug

Bug Report

Summary

The elide mcp command fails with a "Could not determine current working directory" error when run from certain directories in WSL/Ubuntu environments, but works correctly from the home directory.

Environment

  • OS: Windows 11 with WSL2
  • Distribution: Ubuntu (WSL)
  • Elide Version: 1.0.0-beta8
  • Installation Method: curl -sSL --tlsv1.2 elide.sh | bash -s -
  • Shell: bash

Error Details

Exception in thread "main" java.lang.Error: Properties init: Could not determine current working directory.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.PosixSystemPropertiesSupport.userDirValue(PosixSystemPropertiesSupport.java:62)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.SystemPropertiesSupport$LazySystemProperty.computeValue(SystemPropertiesSupport.java:375)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeProperty(SystemPropertiesSupport.java:317)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.SystemPropertiesSupport.ensureInitialized(SystemPropertiesSupport.java:307)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.SystemPropertiesSupport.ensurePropertyInitialized(SystemPropertiesSupport.java:301)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.SystemPropertiesSupport.getInitialProperty(SystemPropertiesSupport.java:221)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.SystemPropertiesSupport.getInitialProperty(SystemPropertiesSupport.java:216)
        at [email protected]/jdk.internal.util.StaticProperty.userDir(Target_jdk_internal_util_StaticProperty.java:270)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.UnixFileSystemAccessors.reinitialize(FileSystemProviderSupport.java:322)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.UnixFileSystemAccessors.getNeedToResolveAgainstDefaultDirectory(FileSystemProviderSupport.java:269)
        at [email protected]/sun.nio.fs.UnixFileSystem.needToResolveAgainstDefaultDirectory(UnixFileSystem.java:116)
        at [email protected]/sun.nio.fs.UnixPath.getByteArrayForSysCalls(UnixPath.java:145)
        at [email protected]/sun.nio.fs.UnixNativeDispatcher.copyToNativeBuffer(UnixNativeDispatcher.java:39)
        at [email protected]/sun.nio.fs.UnixNativeDispatcher.lstat(UnixNativeDispatcher.java:272)
        at [email protected]/sun.nio.fs.UnixFileAttributes.get(UnixFileAttributes.java:79)
        at [email protected]/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:52)
        at [email protected]/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:161)
        at [email protected]/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
        at [email protected]/java.nio.file.Files.readAttributes(Files.java:1699)
        at [email protected]/java.nio.file.Files.isSymbolicLink(Files.java:2078)
        at elide.tool.cli.MainKt.initializeEntry(main.kt:194)
        at elide.tool.cli.MainKt.initializeEntry$default(main.kt:186)
        at elide.tool.cli.MainKt.main(main.kt:252)

Reproduction Steps

  1. Install Elide in WSL/Ubuntu using the official installer
  2. Navigate to the Elide installation directory: cd ~/elide
  3. Run the MCP server command: elide mcp --server=http --http:host=0.0.0.0 --http:port=8125
  4. Observe the "Could not determine current working directory" error

Expected Behavior

The MCP server should start successfully regardless of the current working directory.

Actual Behavior

The command fails with a system property initialization error when run from certain directories (like ~/elide).

Workaround

The command works correctly when run from the home directory (~):

cd ~
elide mcp --server=http --http:host=0.0.0.0 --http:port=8125
# ✅ Works: Registering resource: Elide Project Manifest (file:///home/pug/elide.pkl)
# ✅ Works: Starting MCP services over HTTP at 0.0.0.0:8125

Root Cause Analysis

During troubleshooting, we discovered that WSL environments can sometimes have malformed HOME environment variables (e.g., HOME=C:Usersdavid instead of /home/pug). While we fixed this for the installation, there may be residual path resolution issues affecting the native image's ability to determine the current working directory in certain contexts.

Additional Context

  • This issue specifically affects WSL/Ubuntu users
  • The Elide binary is a GraalVM native image
  • The error occurs in the native image's POSIX system properties support
  • Other Elide commands may be affected by similar path resolution issues
  • This affects MCP server functionality, which is important for AI integration workflows

Suggested Fix

The native image path resolution logic should be more robust when dealing with WSL environments and edge cases in working directory determination. Consider:

  1. Adding fallback logic for working directory detection
  2. Better error handling for malformed environment variables
  3. More comprehensive path resolution for WSL-specific scenarios

This bug affects developer productivity in WSL environments and could prevent adoption among Windows+WSL users who want to use Elide's MCP functionality.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmodule:cliCLI module issues and features

Type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions