I’ve been developing a project which requires me to spin up a lot of roots projects (Trellis/Bedrock/Sage) the past few months. I have a strict process I follow.
For the past few days I’ve been hitting a bug where my sites won’t deploy due to not connecting correctly to my github repo via SSH. The error I get:
TASK [deploy : Failed connection to remote repo] *******************************************************************************************************************************************************************************************
task path: /Users/masoninthesis/Sites/thefutur/trellis/roles/deploy/tasks/update.yml:27
System info:
Ansible 2.9.9; Darwin
Trellis version (per changelog): "Support Ansible 2.9"
---------------------------------------------------
Git repo git@github.com:masoninthesis/TheFuturLMS.git cannot be accessed.
Please verify the repository exists and you have SSH forwarding set up
correctly.
More info:
> https://roots.io/trellis/docs/deploys/#ssh-keys
> https://roots.io/trellis/docs/ssh-keys/#cloning-remote-repo-using-ssh-
agent-forwarding
fatal: [thefutur.jackalope.io]: FAILED! => {
"changed": false
}
At first I thought maybe it was the capital letters I put in the github URL. So I fixed that to no avail.
I found a couple posts on this forum that seemed similar, so I followed all the steps suggested. Especially here by @fullyint–
Note that if you test ssh-agent forwarding by running
ssh web@example.com 'ssh -T git@github.com'
When I do this, I get: Permission denied (publickey).
I configure ForwardAgent yes and AllowAgentForwarding, I still get permission denied.
But I think that’s an unrelated issue.
I found the issue for now. I’ll drop it in the next comment so I can mark it as the solution for now.
I knew the issue might have something to do with my repo, or the URL. I recreated it multiple times. Changed the git url. Changed all letters to lower case. No luck.
I followed a step suggested from the other post above, I commented out no_log: true. This gave me an interesting error I hadn’t seen before:
"error: pathspec 'master' did not match any file(s) known to git."
Followed by the same error I logged above in the OG post. This made me take notice of the master branch. Maybe the branch had been changed somehow?
Then right as I was about to post this as a potential bug, I spotted something unusual in my repository.
On github’s website, my branch was called main branch. Main branch? Wtf? Shouldn’t it be master?
I created a new branch called master, re-deployed, and voila. It worked fine.
I used the Github Desktop app for Mac, mainly because as I’m training others, it’s way easier than having to teach them Git. I think github might have updated the app so that the master branch is called main by default. That seems like a bug to me, but maybe they’re changing things? Either way, I hope this might one day help some other poor soul like myself.