tauri-apps/tauri · error

embedded file asset has no parent

Error message

embedded file asset has no parent

What it means

Panic in tauri-codegen's embedded-assets generation (`EmbeddedAssets::new`). While walking asset input paths to compute the set of parent directories, any path that is not a directory must have a parent (to register its containing folder); if `Path::parent()` returns None — i.e. the path is the filesystem root "/" or an empty/relative path resolving to root — this expect panics. Effectively it means an asset input path was the root itself.

Solutions

  1. Fix `frontendDist` (or the asset input dir) in tauri.conf.json to point at your actual frontend build output directory, not `/`.
  2. Check environment variable interpolation in the config isn't producing an empty/root path.
  3. Ensure the referenced dist directory exists and contains files before building.
  4. Use a relative path like `../dist` instead of an absolute root path.

Example fix

// tauri.conf.json before
"frontendDist": "/"
// after
"frontendDist": "../dist"
Defensive patterns

Strategy: validation

Validate before calling

// before building, validate frontendDist is a real existing directory, not root
const fs = require('fs'), path = require('path');
const cfg = JSON.parse(fs.readFileSync('src-tauri/tauri.conf.json', 'utf8'));
const dist = path.resolve('src-tauri', cfg.build.frontendDist);
if (dist === path.parse(dist).root) throw new Error('frontendDist resolves to filesystem root — fix tauri.conf.json');
if (!fs.existsSync(dist)) throw new Error(`frontendDist does not exist: ${dist}`);

Prevention

When it happens

Trigger: Configuring `frontendDist`/asset input pointing at `/` (root) or a path that normalizes to root, so a non-directory entry has no parent directory to record.

Common situations: Misconfigured tauri.conf.json `build.frontendDist` set to "/" or an absolute root-like path; misconfigured env var substitution yielding an empty path resolved as root.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18). Data as JSON: /api/errors/77470e86b8061ef7. Report an issue: GitHub.

Appendix: source

Thrown at crates/tauri-codegen/src/embedded_assets.rs:117

  paths: Vec<(PathBuf, DirEntry)>,
  csp_hashes: CspHashes,
}

impl RawEmbeddedAssets {
  /// Creates a new list of (prefix, entry) from a collection of inputs.
  fn new(input: EmbeddedAssetsInput, options: &AssetOptions) -> Result<Self, EmbeddedAssetsError> {
    let mut csp_hashes = CspHashes::default();

    input
      .0
      .into_iter()
      .flat_map(|path| {
        let prefix = if path.is_dir() {
          path.clone()
        } else {
          path
            .parent()
            .expect("embedded file asset has no parent")
            .to_path_buf()
        };

        WalkDir::new(&path)
          .follow_links(true)
          .contents_first(true)
          .into_iter()
          .map(move |entry| (prefix.clone(), entry))
      })
      .filter_map(|(prefix, entry)| {
        match entry {
          // we only serve files, not directory listings
          Ok(entry) if entry.file_type().is_dir() => None,

          // compress all files encountered
          Ok(entry) => {
            if let Err(error) = csp_hashes
              .add_if_applicable(&entry, &options.dangerous_disable_asset_csp_modification)

View on GitHub (pinned to 460ec35447)