oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.53k stars 2.79k forks source link

Bun sets incorrect path to installed dependencies on windows. Does not handle case insensitivity. #14077

Open txtyash opened 2 months ago

txtyash commented 2 months ago

What version of Bun is running?

1.1.29+6d43b3662

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

Bug: Bun sets incorrect path to installed dependencies

Background

I'm using nushell on windows and this also seems like a problem with nushell to me but I had a discussion with dylan on discord and they said this should be a bun bug and even I thought bun should handle this correctly so creating this issue. So this is what happens in nushell on windows:

textyash.com on  dev [✘!?] via 🥟 v1.1.29 via  v22.5.1
❯ : cd X:\repos\textyash.com

textyash.com on  dev [✘!?] via 🥟 v1.1.29 via  v22.5.1
❯ : pwd
X:\repos\textyash.com

textyash.com on  dev [✘!?] via 🥟 v1.1.29 via  v22.5.1
❯ : cd x:\repos\textyash.com

textyash.com on  dev [✘!?] via 🥟 v1.1.29 via  v22.5.1
❯ : pwd
x:\repos\textyash.com

Notice the output from the first pwd has a capital X and the second pwd outputs a lowercase x. This does not happen with powershell. When I run this cd x:\repos\textyash.com on powershell, the pwd outputs a uppercase x.

Steps to reproduce

Perform all these operations in nushell on windows

  1. Navigate to the any drive but with a lowercase drive name:

    cd c:\
  2. Create a project:

    mkdir bun-bug
    cd bun-bug
    bun init
  3. Add a dev dependency that can be invoked as a cli command:

    bun add -d cowsay
  4. Execute: bun run cowsay hehe. Below is the example output from the error on my system:

    
    x:\tmp\bun-bug-lowercase via 🥟 v1.1.29 via  v22.5.1
    ❯ : bun run cowsay hehe
    node:internal/modules/cjs/loader:1222
    throw err;
    ^

Error: Cannot find module 'x:\X:\tmp\bun-bug-lowercase\node_modules\cowsay\cli.js' at Module._resolveFilename (node:internal/modules/cjs/loader:1219:15) at Module._load (node:internal/modules/cjs/loader:1045:27) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:215:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5) at node:internal/main/run_main_module:30:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }



This wouldn't have happened if we had cd'd into the directory with an uppercase drive name: `cd C:\`.

Also, If we had followed the entire process in the uppercase drive name path, then after installing the packages and switching to the directory with the lowercase drive path and running the commands does not cause any problems. So I think the problem occurs with installing dependencies in lowercase drive paths.

### What is the expected behavior?

-

### What do you see instead?

-

### Additional information

-
krzysztofciombor commented 1 week ago

Can confirm that the same issue exists when using Cmder on Windows Bun 1.1.36+ededc168c Microsoft Windows NT 10.0.19045.0 x64

Installing the dependencies using npm install and then runing bun run works correctly as well.