deploy_feedback icon indicating copy to clipboard operation
deploy_feedback copied to clipboard

Deno.mkdir doesn't exist

Open bobvanderlinden opened this issue 3 years ago • 7 comments

I expected the following to run:

await Deno.mkdir("example");

But on Deno Deploy I get the following:

TypeError: Deno.mkdir is not a function
    at file:///src/server/index.ts:1:12

Whereas running this locally works fine:

deno run --allow-write server/index.ts

I ran into this because esbuild uses Deno.mkdir: https://deno.land/x/[email protected]/mod.js#L1571-L1574

What made this a bit more confusing was that I also ran into https://github.com/denoland/deploy_feedback/issues/98.

bobvanderlinden avatar Jan 09 '22 19:01 bobvanderlinden

I believe you do not have write permissions on Deno Deploy, as it runs in multiple instances and they would desync one another.

Duplicate of #112 (kinda).

pedropaulosuzuki avatar Jan 10 '22 03:01 pedropaulosuzuki

I believe you do not have write permissions on Deno Deploy, as it runs in multiple instances and they would desync one another.

You're right. We want to consider providing "write" abilities in the future, but not anytime soon.

satyarohith avatar Jan 10 '22 04:01 satyarohith

I think it should result in a permission error. Right now the method doesn't exist at all, which makes it not compatible with running Deno locally.

Knowing that it will result in a permission denied, I consider this issue less pressing atm.

bobvanderlinden avatar Jan 10 '22 08:01 bobvanderlinden

Check out the docs, that function is straight up not available in Deno Deploy: https://deno.com/deploy/docs/runtime-fs

I believe it is intentional. You'll need an abstraction that writes those files to a database or object storage likely.

justinmchase avatar Jan 25 '22 07:01 justinmchase

Shouldn't it just be giving a permission error instead of the method missing? Now developers cannot presume any of the Deno method to be available. Libraries should be supporting this next to supporting permission errors.

If libraries should support methods like mkdir missing: those libraries are using Deno for their CI, so this cannot be tested. They should also test for Deno Deploy, which is quite hard to do.

The type of Deno describes a mkdir method always being there (it isn't optional). Therefore the method should just exist in Deno Deploy as well.

Not that I demand this, it's fine to close this issue, but other (library) developers will run into this when their code is run on Deno Deploy, which blocks further adoption.

bobvanderlinden avatar Jan 25 '22 12:01 bobvanderlinden

Ok, if this issue is just what kind of an error should be thrown in this case, then I agree, something consistent would be very helpful.

justinmchase avatar Jan 25 '22 13:01 justinmchase

@bobvanderlinden @justinmchase Expect an update here in the next few days. Deploy's FS is read-only (for now) so if we add these functions they would throw a PermissionDenied.

AaronO avatar Jan 25 '22 13:01 AaronO

We rolled the new error in early Feb 2022 as Alon mentioned. Closing the issue as resolved.

PermissionDenied: Requires write access to 'hello', but the file system on Deno Deploy is read-only.
    at Object.mkdir (ext:deno_fs/30_fs.js:148:14)
    at Server.handler (file:///src/main.tsx:10:14)
    at Server.#respond (https://deno.land/[email protected]/http/server.ts:299:37)
    at Server.#serveHttp (https://deno.land/[email protected]/http/server.ts:346:20)
    at eventLoopTick (ext:core/01_core.js:181:11) {
  name: "PermissionDenied"
}

satyarohith avatar May 20 '23 06:05 satyarohith