Skip to content

process.cwd() casing inconsistent across platforms #8237

@Urthen

Description

@Urthen
  • Version: Node 6.4
  • Platform: OSX, Windows 10 64bit
  • Subsystems: process, path

In various case-insensitive platforms - namely, Windows and OSX - it is possible to cd into an incorrectly-cased path. Node handles this differently on Windows than it does in OSX when attempting to resolve process.cwd(). This affects other modules - namely, how path.resolve() cases its absolute paths.

In OSX, process.cwd() resolves to the correctly cased path, regardless of which path you have cded into. I believe this to be correct behavior.

~/my-app$ node
> process.cwd()
'/Users/michael.pratt/my-app`
~/my-app$ cd ../My-app
~/My-app$ node
> process.cwd()
'/Users/michael.pratt/my-app`

In Windows default console, it is not possible to cd into an incorrect path. However, using PowerShell or the new Bash for Windows, it is possible, but process.cwd() resolves to the incorrect path casing - not matching what is on disk.

PS C:\Users\Michael Pratt\my-app> node             
> process.cwd()                                   
'C:\\Users\\Michael Pratt\\my-app'                 
PS C:\Users\Michael Pratt\my-app> cd ../My-app   
PS C:\Users\Michael Pratt\My-app> node             
> process.cwd()                                   
 'C:\\Users\\Michael Pratt\\My-app'  

Again, I feel the OSX behavior is correct, as it matches what is on the filesystem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libuvIssues and PRs related to the libuv dependency or the uv binding.processIssues and PRs related to the process subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions