Skip to content

Conversation

@renehernandez
Copy link
Contributor

@renehernandez renehernandez commented Jul 4, 2025

Fixes issue #28 where bunv incorrectly reports "Failed to install Bun" despite successful installation.

Problem

The installation process was checking exit codes incorrectly in src/vm.zig line 220:

if (installProcess.term.Exited == 0) {
    std.debug.print("Failed to install Bun:\n\nSTDERR:\n{s}\n\nSTDOUT:\n{s}\n", .{ installProcess.stderr, installProcess.stdout });
    std.process.exit(1);
}

In Unix/Linux systems:

  • Exit code 0 means SUCCESS
  • Exit code != 0 means FAILURE

The condition was backwards, treating successful installations (exit code 0) as failures.

Example of the Bug

❯ bun --version
Bun v1.2.18 is not installed. Do you want to install it? [y/N] y
Installing...
Failed to install Bun:

STDOUT:
-e bun was installed successfully to ~/.bunv/versions/1.2.18/bin/bun 
Run 'bun --help' to get started

Solution

Changed the condition from == 0 to != 0 to correctly detect failures:

if (installProcess.term.Exited != 0) {
    std.debug.print("Failed to install Bun:\n\nSTDERR:\n{s}\n\nSTDOUT:\n{s}\n", .{ installProcess.stderr, installProcess.stdout });
    std.process.exit(1);
}

Now:

  • ✅ Successful installation (exit code 0) → Shows success message
  • ✅ Failed installation (exit code ≠ 0) → Shows error message and exits

Changes

  • 1 character change in src/vm.zig line 220: ==!=
  • Makes the code consistent with other exit code checks in the same file (line 186)

Closes #28

@aklinker1
Copy link
Owner

aklinker1 commented Jul 4, 2025

🤦 Maybe I was testing it and forgot to revert the change before committing? Who knows lol

@aklinker1 aklinker1 merged commit 623ed6d into aklinker1:main Jul 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reports install failure despite success

2 participants