Windows packaged app shows only `Asset not found`: bundled frontend assets resolve against the process cwd, not the artifact
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 56/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- zig
- Domain
- desktop
Research direction
Read src/platform/windows/webview2_host.cpp around assetFilePath and compare its asset resolution with the root_path handling described for macOS and Linux in platform/macos/root.zig and platform/linux/root.zig. Then trace how the packaged artifact sets the asset root in src/tooling/package.zig. Done means a Windows package finds and renders its bundled frontend when launched from bin/, with the existing package layout intact.
Written by the indexing model from the issue text.
Description
Environment
@native-sdk/cli0.11.1, Windows 11, Zig 0.16.0app.jsonhas"frontend": { "dist": "frontend/dist", "entry": "index.html", "spa_fallback": true },"capabilities": ["webview"],"web_engine": "system"
Steps
native build shelltest --yes
native package --target windows --manifest app.json --assets frontend/dist \
--output zig-out/package/win --binary zig-out/bin/shelltest.exe \
--web-engine system --web-layer include
Packaging reports success:
info[package.created]: created windows artifact at zig-out/package/win
web layer: webview2 (declared: .frontend)
subsystem: gui
The artifact is laid out as:
win/
bin/shelltest.exe
bin/WebView2Loader.dll
resources/frontend/dist/index.html
resources/frontend/dist/asset-manifest.zon
Expected — per /docs/packaging: "Production packages serve these through zero://app/, so paths like /assets/app.js work without file:// URLs", and native build + native package is described as "the complete path from source to distributable". Double-clicking bin/shelltest.exe should render index.html.
Actual — the window opens with a single line of body text:
Asset not found
That string comes from the Windows scheme handler's 404 branch
(src/platform/windows/webview2_host.cpp:5244,
return textWebResourceResponse(environment, 404, L"Not Found", "Asset not found")),
i.e. the file lookup failed rather than the document being empty. There is no console
error, no dialog, and no hint about which path was tried. Note that the runtime log line
webview.load ... kind="assets" bytes=10 is printed on both the working and the
failing run (it reports the asset id length, not the payload), so it is not a signal.
Why
The packaged assets live at <output>/resources/<frontend.dist>:
// src/tooling/package.zig:503,765
const assets_output = try assetOutputPath(allocator, options.output_path, "resources", options);
// -> <output>/resources/<frontend.dist>
But on Windows the webview resolves an asset URL by concatenating the manifest's
dist string onto the process working directory:
// src/platform/windows/webview2_host.cpp:1128
static std::wstring assetFilePath(const ChildWebView &webview, const std::string &relative) {
std::string path = webview.asset_root.empty() ? std::string(".") : webview.asset_root;
...
path += native_relative; // "frontend/dist" + relative, relative to cwd
asset_root is the literal frontend/dist baked in by
frontend.productionSource(.{ .dist = "frontend/dist" }) — it is never rebased onto the
artifact directory. On macOS and Linux the platform layer receives root_path
(platform/macos/root.zig:1388, platform/linux/root.zig:770) and is described in the
docs as resolving "against Contents/Resources", so the package layout and the resolver
agree there. On Windows they do not: when the app is launched by double-click, the cwd is
bin/, so <cwd>/frontend/dist/index.html does not exist.
Controlled experiment (same binary, no rebuild)
| setup | cwd | result |
|---|---|---|
as packaged (resources/frontend/dist) |
bin/ |
body text Asset not found (404 from the scheme handler) |
resources/frontend/dist copied to bin/frontend/dist |
bin/ |
renders normally |
Same binary, same working directory, same command — only the asset location changed.
Nothing else changed, so the missing piece is the app-relative resolution.
Note on the obvious workaround
Computing an absolute asset_root from the executable directory in Zig is not a one-liner
on 0.16: std.fs.selfExePath* no longer exists (grep -rn selfExe zig/lib/std returns
nothing; path handling moved to std.Io.Dir). Users have no supported way to fix this
from application code, which is why the cwd-relative lookup matters.
Expected fix
Resolve asset_root against the artifact/executable directory on Windows (mirroring
macOS/Linux), so the default build + package output works when double-clicked.
- Dominant language
- Zig
- Stars
- 7.9k
- Forks
- 335
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 147
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel-labs/native
-
Per-view widget layout budget (1024 nodes) drops whole frames on real multi-pane app viewsPossibly taken @slicenferqin claimed this 100 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vercel-labs/native#408 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
vercel-labs/native#387 ·
Maintainers usually reply within 1 day
-
macOS: the window frame event reports the frame size where everything else expects the content sizeOpen
Difficulty 1/5 Under an hour Newbie friendliness 84/100
vercel-labs/native#355 ·
Maintainers usually reply within 1 day
-
cef.zig: InstallResult.archive_path leaks on successPossibly taken @versecafe claimed this 206 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vercel-labs/native#32 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
vercel-labs/native#957 ·
Maintainers usually reply within 1 day
All issues in vercel-labs/native
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
GUI: the space panel stays stale after a run stops with no spacePossibly taken @nikkexe0-del claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
xevrion/hatchzip#237 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
flathub/org.ardour.Ardour#89 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Javis603/token-monitor#1861 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 1 day