-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installing Cask on macOS changes ~/.gitconfig ownership to root #186
Comments
You can work around the discrepancy by using if test -z "$SUDO_USER"
then
git config --global ...
elif test 0 != "$(id -u)"
then
echo "Uh oh! SUDO_USER is set, but not running as root?" >&2
exit 1
else
su -c "git config --global ..." "$SUDO_USER"
fi |
You might also use |
I'm pinging this issue because microsoft/scalar#443 was marked as stale. I'm closing that one. |
@mjcheetham we should discuss more. |
Because we're opting to use Casks rather than Formulae we must run as sudo. Casks install via pkg files. The Mac pkg file installer needs sudo (unless you do some terrible things that are pretty much unsupported these days). I originally added microsoft-git as a formula but we took this out and replaced it with a Cask because we didn't want consumers to have to sit and wait for a build of Git to happen (and GCM Core). In the upstream Homebrew core tap, there is considerable infrastructure and automation that creates Bottles that are pre-built binaries, for each OS version supported. This avoids the compile from source, but on our custom tap we don't have that infra. Not to mention the fact that GCM Core requires the .NET SDK and that isn't available in Homebrew. |
I see. Ugh, a mess.
Is that intentional on Git's part? I realize that this isn't exactly the same thing, but merely mattc % echo foo > test.txt
mattc % ls -l
total 8
-rw-r--r-- 1 mattc staff 4 Mar 8 10:24 test.txt
mattc % sudo echo bar >> test.txt
mattc % ls -l
total 8
-rw-r--r-- 1 mattc staff 8 Mar 8 10:24 test.txt
mattc %
|
I think it might have to do with the way Git handles files. Doesn't Git do the "write & rename" to avoid an interrupted write? |
I have a PR up that should aim to "de-elevate(?)" from root to the real user identity when calling |
The
git-credential-manager-core
Cask requires installation as root because root is required to install the internal .pkg file.GCM Core has a postinstall action that calls the
configure
command, that internally callsgit config --global ... ...
which, being run as root, will change the ownership of the~/.gitconfig
file.We need a way to have these post install actions not run as root OR change the Cask to run
configure --system
which will update thegit config --system
config file (/etc/gitconfig
) instead.The latter suggested change of course will make GCM Core a machine-level installation, and not per user. Perhaps this is the 'correct' design however.
Also see microsoft/scalar#443.
The text was updated successfully, but these errors were encountered: