From 4899713ed7fdb44e844fb247356659618d2d65e1 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 21 Oct 2026 01:55:12 +0000 Subject: [PATCH] fix(cli): report a failed write of the MLX hostfile The tunnel callback ignored the error of os.WriteFile and set the hostfile variable even when the file was not written. It now logs the error and leaves the variable alone. Assisted-by: Claude Code:claude-sonnet-5-5 go Signed-off-by: Ettore Di Giacinto --- core/cli/run.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/cli/run.go b/core/cli/run.go index 491c429d4..211c2efa7 100644 --- a/core/cli/run.go +++ b/core/cli/run.go @@ -382,7 +382,10 @@ func (r *RunCMD) Run(ctx *cliContext.Context) (result error) { config.WithMLXTunnelCallback(func(tunnels []string) { hostfile := filepath.Join(os.TempDir(), "localai_mlx_hostfile.json") data, _ := json.Marshal(tunnels) - os.WriteFile(hostfile, data, 0600) + if err := os.WriteFile(hostfile, data, 0600); err != nil { + xlog.Error("failed to write MLX hostfile", "path", hostfile, "error", err) + return + } os.Setenv("MLX_DISTRIBUTED_HOSTFILE", hostfile) xlog.Debug("setting MLX_DISTRIBUTED_HOSTFILE", "value", hostfile, "tunnels", tunnels) }),