From 35c550ac9f20bd360dcc932945ea6f833df1fb19 Mon Sep 17 00:00:00 2001
From: Zubarev Alexander <astrike@avride.ai>
Date: Tue, 10 Dec 2024 18:34:38 +0200
Subject: [PATCH] fix: Do not fail chown on dummy symlinks

---
 envbuilder.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/envbuilder.go b/envbuilder.go
index ea1031ce..ad2c84ff 100644
--- a/envbuilder.go
+++ b/envbuilder.go
@@ -815,7 +815,7 @@ func run(ctx context.Context, opts options.Options, execArgs *execArgsInfo) erro
 			if err != nil {
 				return err
 			}
-			return os.Chown(path, execArgs.UserInfo.uid, execArgs.UserInfo.gid)
+			return os.Lchown(path, execArgs.UserInfo.uid, execArgs.UserInfo.gid)
 		}); chownErr != nil {
 			opts.Logger(log.LevelError, "chown %q: %s", execArgs.UserInfo.user.HomeDir, chownErr.Error())
 			endStage("⚠️ Failed to the ownership of the workspace, you may need to fix this manually!")
@@ -832,7 +832,7 @@ func run(ctx context.Context, opts options.Options, execArgs *execArgsInfo) erro
 			if err != nil {
 				return err
 			}
-			return os.Chown(path, execArgs.UserInfo.uid, execArgs.UserInfo.gid)
+			return os.Lchown(path, execArgs.UserInfo.uid, execArgs.UserInfo.gid)
 		}); chownErr != nil {
 			opts.Logger(log.LevelError, "chown %q: %s", execArgs.UserInfo.user.HomeDir, chownErr.Error())
 			endStage("⚠️ Failed to update ownership of %s, you may need to fix this manually!", execArgs.UserInfo.user.HomeDir)