Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS-Ubuntu-Git Setup error fatal: $HOME not set

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.

like image 981
user1811107 Avatar asked Nov 04 '16 14:11

user1811107


1 Answers

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.

like image 128
mohifleur Avatar answered Oct 03 '22 12:10

mohifleur