denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.97k stars 5.35k forks source link

Deno compile crash when try chdir #26175

Open jlucaso1 opened 2 weeks ago

jlucaso1 commented 2 weeks ago

Version: Deno 2.0.0

I've tried to compile a nextjs standalone compiled project and got this error when try to execute the compiled denojs version of this project:

error: Uncaught (in promise) NotSupported: The operation is not supported
    at Process.chdir (ext:deno_fs/30_fs.js:155:3)

Minimal repro:

import { fileURLToPath } from 'node:url'
import process from 'node:process'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

process.chdir(__dirname)

deno compile -A main.js ./main

MohammadSu1 commented 2 weeks ago

@jlucaso1 I tried reproducing the issue using the same code you attached, but I added a log to see the output. As you can see in the attached pictures, it runs without any problem on my side. PS: I'm using Windows next_js_code next_js_terminal

jlucaso1 commented 2 weeks ago

@MohammadSu1 i tested early in linux. Curious that works fine in windows :thinking: . Can you try in wsl?

littledivy commented 2 weeks ago

This happens because import.meta.url points to a non-existent temp directory for compiled executables.

This seems to work:

$ deno compile main.js
$ mkdir /tmp/deno-compile-chdir-deno-compile/chdir-deno-compile # replace with tmp dir for your executable
$ ./chdir-deno-compile