I have some cloudinit scripts to execute when my AWS EC2 Ubuntu instance starts up.
I want to setup GIT config variables, with the code below.
#cloud-config
runcmd:
- [ sh, -c, "git config --global user.name 'myname'"]
When logged into the terminal. I can execute git config --global user.name 'myname' with no problem.
However when I attempt to start my instance with the cloudinit code. I get an error message
fatal: $HOME not set
My understanding is this is because the HOME is not set when the instance starts up.
Looking for a solution, to get the git variable to be set on startup or an alternate solution.
I ran into the same problem...
git config --system http.sslVerify false
git config --system user.email "[email protected]"
This resolved the error message. I got this solution after reading CodeCommit with EC2 Role Credentials. The reason is stated in the blog... "But when I ran this as root, I ran into the error fatal: $HOME not set, because git config --global is trying to read/write the current user's $HOME/.gitconfig file, and root seems to be $HOME-less in this context.
After being thoroughly schooled in git settings management, I can tell you that there is another option -- to set the system-wide git preferences with git config --system, which results in modifications to /etc/gitconfig, no errors. "
P.S. I realize that I'm answering this question almost 3 years later, but I'm hoping that this might help others who face the same issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With