vercel-community / rust

🦀 Rust runtime for ▲ Vercel Serverless Functions
https://rust-runtime.vercel.app
MIT License
845 stars 49 forks source link

Error: ENOENT: no such file or directory when building in vercel dev #83

Closed fanoway closed 6 months ago

fanoway commented 1 year ago

My handlers build and work properly when using vercel deploy. However using the local vercel dev results in the following error. The target\release\deps directory exists, however the rmetaXXXXX file does not, other files exist with a similair but different name.

[Error: ENOENT: no such file or directory, scandir 'C:\Users\user-name\Documents\project-name\target\release\deps\rmeta8XbjCX'] { errno: -4058, code: 'ENOENT', syscall: 'scandir', path: 'C:\\Users\\user-name\\Documents\\project-name\\target\\release\\deps\\rmeta8XbjCX' }

My vercel.json file looks like { "functions": { "api/*/*.rs": { "runtime": "vercel-rust@4.0.0-beta.1" } } }

ecklf commented 1 year ago

Hey there 👋🏻 . Seems like this is a Windows-specific error. Were you using one of the examples or do you have a reproduction repo so I can look into fixing this issue?

ecklf commented 1 year ago

I think I managed to resolve the issue. The binary name resolving didn't include .exe which is added on Windows. In case this issue is not resolved by using vercel-rust@4.0.0-beta.2 feel free to reopen.

fanoway commented 1 year ago

Thanks. I am running windows 10 for reference.

I switched to the beta.2 version. and it resulted in the same error.

A bit more info for you. The rmeta dir its looking for does not exist, but there are other rmeta dirs with different names

My repo can be found here

ecklf commented 1 year ago

Will have a look at it tomorrow

ecklf commented 1 year ago

The project was missing a vercel.json file (note that the glob in your initial post missed an *). Also make sure to add target to .vercelignore to prevent uploading it.

{
    "functions": {
        "api/**/*.rs": {
            "runtime": "vercel-rust@4.0.0-beta.2"
        }
    }
}

After applying the above I could not reproduce the error when running vercel dev. CleanShot 2023-03-16 at 09 37 52

$ rustup show
Default host: aarch64-pc-windows-msvc
rustup home:  C:\Users\ecklf\.rustup

stable-aarch64-pc-windows-msvc (default)
rustc 1.68.0 (2c8cc3432 2023-03-06)