{"record":{"id":"c1d7396ce18456ed","repo":"denoland/deno","slug":"is-not-supported-for-an-embedded-deno-compile-f","errorCode":null,"errorMessage":"{} is not supported for an embedded deno compile file","messagePattern":"(.+?) is not supported for an embedded deno compile file","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"cli/rt/file_system.rs","lineNumber":738,"sourceCode":"  fn is_socket(&self) -> std::io::Result<bool> {\n    Ok(false)\n  }\n\n  fn file_attributes(&self) -> std::io::Result<u32> {\n    Ok(0)\n  }\n}\n\n/// `statfs` result for a path within the embedded read-only file system.\n///\n/// There is no real backing device, so this reports an empty read-only file\n/// system (no free space) rather than failing or leaking host disk stats.\nfn vfs_statfs() -> FsStatFs {\n  FsStatFs::default()\n}\n\nfn not_supported(name: &str) -> std::io::Error {\n  std::io::Error::new(\n    ErrorKind::Unsupported,\n    format!(\n      \"{} is not supported for an embedded deno compile file\",\n      name\n    ),\n  )\n}\n\nimpl sys_traits::FsDirEntry for FileBackedVfsDirEntry {\n  type Metadata = BoxedFsMetadataValue;\n\n  fn file_name(&self) -> Cow<'_, std::ffi::OsStr> {\n    Cow::Borrowed(self.metadata.name.as_ref())\n  }\n\n  fn file_type(&self) -> std::io::Result<sys_traits::FileType> {\n    Ok(self.metadata.file_type)\n  }","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/rt/file_system.rs#L720-L756","documentation":"The embedded filesystem of a `deno compile` binary is read-only and backed by a snapshot, so mutating operations cannot work. Affected ops return io::ErrorKind::Unsupported with '<op> is not supported for an embedded deno compile file' — the op names include 'writing files', 'setting file length', 'setting file times', 'locking files', 'unlocking files', 'cloning files', and timestamp reads ('accessed/created/changed/modified time' are not stored).","triggerScenarios":"A compiled app calling Deno.open with write:true / Deno.writeFile / truncate / utime / flock on a path inside the VFS (e.g. relative paths resolving under /deno-dir/...); Node-compat libraries trying to create lock files, temp files, or update timestamps next to the executable; SQLite or bundlers attempting to write caches into their own directory.","commonSituations":"Apps that worked under `deno run` but break under `deno compile` because they write next to their sources; tools writing config/cache beside the binary; flock-based mutexes in ported Node libraries; utime calls in deployment scripts.","solutions":["Write to a real filesystem location instead: use the OS temp dir (Deno.env.get('TMPDIR') || '/tmp') or a user data dir, not paths inside the compiled VFS","Branch behavior when running compiled: detect via a build-time constant (e.g. Deno build substitution or an env var you set in the compile recipe) and pick writable locations","Read embedded assets from the VFS but materialize writable copies (Deno.readFile -> write to temp) before APIs that need write/lock access","Replace timestamp/lock dependencies (utime, flock) with no-ops or alternatives when operating on embedded files"],"exampleFix":"// before (fails when compiled)\nconst dbPath = new URL('./app.db', import.meta.url).pathname;\nconst db = await Deno.open(dbPath, { write: true, create: true });\n\n// after\nconst dbPath = await Deno.makeTempFile({ prefix: 'app-', suffix: '.db' });\nawait Deno.copyFile(new URL('./seed.db', import.meta.url), dbPath);\nconst db = await Deno.open(dbPath, { write: true });","handlingStrategy":"fallback","validationCode":"// Route writes away from the embedded VFS before any mutation\nconst IS_COMPILED = !!Deno.env.get(\"DENO_COMPILE\") /* or your build-time flag */;\nexport function writablePath(rel: string): string {\n  if (!IS_COMPILED) return rel;\n  const tmp = Deno.env.get(\"TMPDIR\") ?? \"/tmp\";\n  return `${tmp}/${crypto.randomUUID().slice(0, 8)}-${rel}`;\n}","typeGuard":"async function isWritableDir(dir: string): Promise<boolean> {\n  try {\n    const probe = await Deno.makeTempFile({ dir });\n    await Deno.remove(probe);\n    return true;\n  } catch { return false; }\n}","tryCatchPattern":"try {\n  await Deno.writeTextFile(configPath, data);\n} catch (e) {\n  if (e instanceof Error && /not supported for an embedded deno compile file/i.test(e.message)) {\n    // VFS is read-only: redirect to a real writable location and retry once\n    configPath = await Deno.makeTempFile({ suffix: \".json\" });\n    await Deno.writeTextFile(configPath, data);\n  } else throw e;\n}","preventionTips":["Never write next to import.meta assets; use temp/user-data directories","Skip flock/utime/truncate calls on embedded files in compiled builds","Audit dependencies for lock-file and timestamp behavior before shipping compiled binaries"],"tags":["compile","vfs","read-only","filesystem","locking","unsupported-operation"],"backgroundTag":"read-only-filesystem","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}