oven-sh / bun

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

"ENOENT: No such file or directory" on fs.realpathSync(tmpdir()) #8681

Open sidesteps opened 9 months ago

sidesteps commented 9 months ago

What version of Bun is running?

[SYS] read(3[/mnt/ssd/bun/build/bun-debug], 4096) = 4096 (0.417ms) [fs] close(3[/mnt/ssd/bun/build/bun-debug]) 1.0.26-debug+c3faf4228

What platform is your computer?

Linux 6.7.1-arch1-1 x86_64 unknown

What steps can reproduce the bug?

when runing sqlite tests: ./build/bun-debug test test/js/bun/sqlite/

What is the expected behavior?

test passing

What do you see instead?

it("upsert cross-process, see #1366", () => {
60 |   const dir = realpathSync(tmpdir()) + "/";
                   ^
ENOENT: No such file or directory
   errno: -2
 syscall: "readlink"
   path: "/tmp"

      at /mnt/ssd/bun/test/js/bun/sqlite/sqlite.test.js:60:15

Additional information

My bun source code is on a symlinked dir. Maybe that has something to do with it.

Jarred-Sumner commented 9 months ago

Does /tmp exist?

sidesteps commented 9 months ago

yes tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=1048576,inode64)

sidesteps commented 9 months ago

test.js

import { realpathSync } from 'fs'
import { tmpdir } from 'os'
console.log(realpathSync(tmpdir()))

works fine on bun 1.0.25

on 1.0.26-debug, when running bun/build/bun-debug test.js I get:

[SYS] read(3[/mnt/ssd/bun/build/bun-debug], 4096) = 4096 (0.135ms)
[fs] close(3[/mnt/ssd/bun/build/bun-debug])
[SYS] openat(-100, /mnt/ssd/bunfig.toml) = 18446744073709551614
[SYS] openat(-100, test.js) = 3
[SYS] fstat(3[/mnt/ssd/test.js]) = 0
[fs] close(3[/mnt/ssd/test.js])
[fs] close(4[/])
[fs] close(5[/mnt])
[fs] close(6[/mnt/ssd])
[SYS] openat(-100, /mnt/ssd/test.js) = 12
[fs] openat([invalid_fd], /mnt/ssd/test.js) = 12
[fs] close(12[/mnt/ssd/test.js])
[alloc] new() = src.bun.js.node.node_fs_binding.NodeJSFS@20000321400
[alloc] new() = src.bun.js.node.node_fs_binding.NodeJSFS@20000322800
[SYS] openat(-100, /tmp) = 12
[fs] close(12[/tmp])
[SYS] openat(-100, /mnt/ssd/test.js) = 12
[fs] openat([invalid_fd], /mnt/ssd/test.js) = 12
[fs] close(12[/mnt/ssd/test.js])
1 | 
2 | import { realpathSync } from 'fs'
3 | import { tmpdir } from 'os'
4 | console.log(realpathSync(tmpdir()))
                ^
ENOENT: No such file or directory
   errno: -2
 syscall: "readlink"
   path: "/tmp"

      at /mnt/ssd/test.js:4:13
      at asyncFunctionResume (:1:21)
      at promiseReactionJobWithoutPromiseUnwrapAsyncContext (:1:21)
      at promiseReactionJob (:1:21)
dylan-conway commented 9 months ago

/proc/self/fd also exists?

sidesteps commented 9 months ago

stat /proc/self/fd

  File: /proc/self/fd
  Size: 3           Blocks: 0          IO Block: 1024   directory
Device: 0,21    Inode: 93950       Links: 2
Access: (0500/dr-x------)  Uid: ( 1000/   sstep)   Gid: ( 1000/   sstep)
Access: 2024-02-04 19:22:50.646543239 +0100
Modify: 2024-02-04 19:22:50.646543239 +0100
Change: 2024-02-04 19:22:50.646543239 +0100
 Birth: -
sidesteps commented 9 months ago

Does /tmp exist?

did you run the test mentioned?