We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 618e259 commit 1832f58Copy full SHA for 1832f58
1 file changed
src/osx/Installer.Mac/scripts/postinstall
@@ -31,7 +31,10 @@ mkdir -p /usr/local/bin
31
/bin/ln -Fs "$INSTALL_DESTINATION/git-credential-manager" /usr/local/bin/git-credential-manager
32
33
# Configure GCM for the current user (running as the current user to avoid root
34
-# from taking ownership of ~/.gitconfig)
35
-sudo -u ${USER} "$INSTALL_DESTINATION/git-credential-manager" configure
+# from taking ownership of ~/.gitconfig).
+# Use stat to determine the console user since the installer may be invoked with
36
+# USER unset (e.g. when run via Homebrew which explicitly clears USER).
37
+REAL_USER=$(stat -f%Su /dev/console)
38
+sudo -u "${REAL_USER}" "$INSTALL_DESTINATION/git-credential-manager" configure
39
40
exit 0
0 commit comments