Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdlib suggests using selfExePathAlloc instead of selfExePath on wasi even though the former calls the latter #17085

Closed
xdBronch opened this issue Sep 7, 2023 · 1 comment · Fixed by #17092
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@xdBronch
Copy link
Contributor

xdBronch commented Sep 7, 2023

Zig Version

0.12.0-dev.278+0e8f130ae

Steps to Reproduce and Observed Behavior

attempt to use std.fs.selfExePath with wasi as the target OS
met with error message std.fs.selfExePath not supported for WASI. Use std.fs.selfExePathAlloc instead.

.wasi => @compileError("std.fs.selfExePath not supported for WASI. Use std.fs.selfExePathAlloc instead."),

use selfExePathAlloc as suggested but same error
return allocator.dupe(u8, try selfExePath(&buf));

Expected Behavior

compile error should give a correct message

@xdBronch xdBronch added the bug Observed behavior contradicts documented or intended behavior label Sep 7, 2023
@Vexu Vexu added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library. labels Sep 7, 2023
@Vexu Vexu added this to the 0.12.0 milestone Sep 7, 2023
@squeek502
Copy link
Collaborator

The Use std.fs.selfExePathAlloc instead. part of that compile error is obsolete and should be removed.

Here's where the compile error was added along with some special casing in selfExePathAlloc:
922d837

And here's where that special casing was moved outside the standard library since it was Zig-specific:
#11469

And here's the reasoning:
#11024 (comment)

Side note: I'm not sure it's possible to implement selfExePath for WASI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants