Skip to content

Conversation

AkihiroSuda
Copy link
Member

Fix #4167

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Oct 8, 2025
@AkihiroSuda AkihiroSuda force-pushed the fix-4167 branch 2 times, most recently from 408f507 to a1edf08 Compare October 8, 2025 09:23
Fix issue 4167

Signed-off-by: Akihiro Suda <[email protected]>
Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

I think this change is wrong. You should return a non-ExitError if you want limactl to print it. Getting a FATAL error just because a subprocess exited with a non-zero code is annoying. HandleExitError() exists to prevent it from being printed while all other errors still show up.

Now we are getting this:

cat ~/bin/limactl-false
#!/bin/sh
falselimactl false
FATA[0000] external command "/Users/jan/bin/limactl-false" failed  error="exit status 1"echo $?
1

There should be no output except when the error is internal to limactl itself. Those errors have always been reported (this is from master):

echo false > ~/bin/limactl-nohashbangchmod +x ~/bin/limactl-nohashbanglimactl-nohashbangecho $?
1limactl nohashbang
FATA[0000] external command "/Users/jan/bin/limactl-nohashbang" failed: fork/exec /Users/jan/bin/limactl-nohashbang: exec format error

)

func HandleExitError(err error) {
func HandleExitError(err error) int {
Copy link
Member

Choose a reason for hiding this comment

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

The name is now misleading because it just returns the exit error and doesn't handle it.

Suggested change
func HandleExitError(err error) int {
func ExitError(err error) int {

}

var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
Copy link
Member

@jandubois jandubois Oct 8, 2025

Choose a reason for hiding this comment

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

I think the right fix would be to change from errors.As back to a type assertion, so it doesn't match on wrapped ExitErrors (which is what networks.sudo() is returning on failure).

This is a regression that I introduced in #3938. Add a comment to make sure it isn't being changed again.

We just don't want to print a message on "naked" ExitErrors that are directly returned by cmd.Run etc. because then propagating the exit code is enough.

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.

--network lima:shared fails without printing an error when the sudoers file is missing
2 participants