Skip to content

std.zig.system: remove assert that inspected path is absolute #22568

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/std/zig/system.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,8 @@ fn resolveElfFileRecursively(cwd: fs.Dir, start_path: []const u8) error{UnableTo
var buffer: [255 + 1]u8 = undefined;
while (true) {
// Interpreter path can be relative on Linux, but
// for simplicity we are asserting it is an absolute path.
assert(std.fs.path.isAbsolute(current_path));
// for simplicity we are assuming it is an absolute path.
// It can also be a relative path from PATH environment variable.
Comment on lines +1023 to +1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"we are assuming it is an absolute path"
"it can be a relative path"

these are contradictory statements. Can you either make the comment accurate or delete it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to mean here "assume interpreter path is absolute, and handle both absolute and relative for PATH", if it's not clear I can rewrite it

Copy link
Member

@andrewrk andrewrk Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pretty confusing, but, it's OK. Better to fix the regression now.

edit: I changed my mind, I will revert the other commit for now. Let us scrutinize the change more carefully because I do not think relative path is valid here. It is relative to the cwd on the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit: I changed my mind, I will revert the other commit for now.
OK

Let us scrutinize the change more carefully because I do not think relative path is valid here. It is relative to the cwd on the next line.

It is valid for PATH cases because they are also evaluted from the point of cwd, and for interpreters I'll try to write version which handles relative path too since work is redone anyway.

const file = cwd.openFile(current_path, .{}) catch |err| switch (err) {
error.NoSpaceLeft => unreachable,
error.NameTooLong => unreachable,
Expand Down
Loading