Closed gvwilson closed 6 years ago
@gvwilson I don't think the user thunk
was given root privileges, so cannot use the --global flag in git config --global ...
, as it changes something for all users.
My understanding is that git config --global
writes to ~/.gitconfig
so that the setting applies across all of the particular user's projects; git config --system
writes to the system-wide file (requiring root), and git config --local
applies only to the particular project. Want me to try git config --local
to see if that will do what I need?
Ah, sorry--you're right. I'm not sure why these lines seem to be trying to change the root config...
[91mwarning: unable to access '/root/.gitconfig': Permission denied
warning: unable to access '/root/.config/git/config': Permission denied
error: could not lock config file /root/.gitconfig: Permission denied
[0m[91mwarning: unable to access '/root/.gitconfig': Permission denied
warning: unable to access '/root/.config/git/config': Permission denied
error: could not lock config file /root/.gitconfig: Permission denied
It seems like it could have something to do with the $HOME variable when running sudo -u thunk
, which I think remains whatever $HOME was prior to the command. See this stack exchange post. I'll message to try to set up a time to pair, so you can run these builds on your laptop.
But shouldn't sudo -u thunk
take care of that? sigh
On Mon, Sep 11, 2017 at 11:04 AM, Michael Chow notifications@github.com wrote:
Ah, sorry--you're right. I'm not sure why these lines seem to be trying to change the root config...
[91mwarning: unable to access '/root/.gitconfig': Permission denied warning: unable to access '/root/.config/git/config': Permission denied error: could not lock config file /root/.gitconfig: Permission denied �[0m�[91mwarning: unable to access '/root/.gitconfig': Permission denied warning: unable to access '/root/.config/git/config': Permission denied error: could not lock config file /root/.gitconfig: Permission denied
It seems like it could have something to do with the $HOME variable when running sudo -u thunk, which I think remains whatever $HOME was prior to the command. See this stack exchange post https://unix.stackexchange.com/questions/91384/how-is-sudo-set-to-not-change-home-in-ubuntu-and-how-to-disable-this-behavior. I'll message to try to set up a time to pair, so you can run these builds on your laptop.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/datacamp/courses-intro-to-git/issues/8#issuecomment-328558313, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3ozjrvA72EN_MfgqSO2Pk24L5RbyjUks5shUvsgaJpZM4PTCSs .
The easiest way to debug putting things in the course image is to...
git clone https://github.com/datacamp/docker-shell-base.git
cd docker-shell-base
docker build -t testshell .
docker run --rm -it testshell /bin/bash
This will open an interactive shell which should be identical to the one used to run requirements.sh
, so you can test different commands in it.
I have it running right now, and will look into why it's not running (give me a couple minutes to get back to you).
@gvwilson you need the interactive sudo flag, so this works...
sudo -u thunk -i git config --global user.email "thunk@datacamp.com"
I think the issue is the one mentioned in the stack exchange post, that without -i
, $HOME
remains set to /root
. Also, I think when you set git config at the very top of requirements, it's not setting it for repl, but for root, also.
Fingers crossed :)
Edit: just for illustration, here's the command I used to test
# /home/thunk
sudo -u thunk -i echo '$HOME'
requirements.sh
updated to sudo
to repl
to set Git config correctly, but is failing :-(
you also need the interactive flag there, too, sudo -u repl -i ...
Solved by moving code into its own script and running that with sudo
.
requirements.sh
contains these lines:The
useradd
appears to work (as evidenced by the creation of/home/thunk
, but the attempt to configure Git for this user fails, so subsequent Git operations sudo'd by this user ID also fail:cc @machow @ncarchedi