From d86a49ba3fc05bf20ec4a7e5f07bf3bcef0508d2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 1 Jun 2026 09:18:20 +0200 Subject: [PATCH] When RecordCurrentDirectory fails, only log the error If we return the error here, we don't switch repos, but the chdir happened already, so this would be an inconsistent state (a lot of lazygit's code assumes that the current directory is always the worktree root). Only log the error; failing to record the current directory is not the end of the world. Also, it is very unlikely to happen; RecordCurrentDirectory only writes to a small file, and if this fails, then either there is filesystem corruption of the disk is full, and in both cases the user likely has much bigger problems. --- pkg/gui/controllers/helpers/repos_helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index 156c0ab30..4da15fa13 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -171,7 +171,7 @@ func (self *ReposHelper) DispatchSwitchTo(path string, errMsg string, contextKey } if err := self.recordDirectoryHelper.RecordCurrentDirectory(); err != nil { - return err + self.c.Log.Errorf("error recording current directory: %v", err) } self.c.Mutexes().RefreshingFilesMutex.Lock()