Skip to content
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

Git fails to innitialize with create t3-app #96

Closed
matovu-farid opened this issue Jul 4, 2022 · 17 comments · Fixed by #127
Closed

Git fails to innitialize with create t3-app #96

matovu-farid opened this issue Jul 4, 2022 · 17 comments · Fixed by #127
Labels
🙋‍♂️ help wanted Extra attention is needed 🐞 confirmed bug Something isn't working

Comments

@matovu-farid
Copy link

matovu-farid commented Jul 4, 2022

Describe the bug
When I run the create yarn create t3-app
After choosing my preferred options, the scaffold builds successfully, however during the build, it attempts to initialise git and it fails.
Git can be initialised manually later by running git init after the build

To Reproduce
Steps to reproduce the behaviour:

  • Run yarn create t3-app
  1. See error ✖ Failed: could not initialise git

Expected behaviour
The git initialisation should not fail

Additional information

  • I am on a linux distro i.e Zorin Os
  • I have git installed

Screenshots
t3

@nexxeln
Copy link
Member

nexxeln commented Jul 4, 2022

Unable to replicate. Is this happening every time you use the CLI? Have you tried using a different package manager?

@matovu-farid
Copy link
Author

Hello @nexxeln,
Yes, it also happened when I used npm.
This time I run npx create-t3-app@latest
t32

@matovu-farid
Copy link
Author

My git version
git_version

@nexxeln
Copy link
Member

nexxeln commented Jul 4, 2022

Maybe it's something OS specific. As far as I know, zorin is based on ubuntu. I'm also using ubuntu in WSL and works fine for me.

@matovu-farid
Copy link
Author

@nexxeln Okay just wanted to let you know about it. It is not detrimental to the creation of the app and someone can manually initialize git themselves. It's an awesome project 👍

@nexxeln nexxeln added the 🙋‍♂️ help wanted Extra attention is needed label Jul 4, 2022
@nexxeln
Copy link
Member

nexxeln commented Jul 4, 2022

Maybe try updating git?

@nexxeln nexxeln added 🐞 confirmed bug Something isn't working and removed 🐞❔ unconfirmed bug labels Jul 4, 2022
@nexxeln
Copy link
Member

nexxeln commented Jul 4, 2022

Found the issue, for initialising git we use

git init --initial-branch=main

This is a new feature released in git 2.28 https://github.blog/2020-07-27-highlights-from-git-2-28/#introducing-init-defaultbranch

Working on a fix right now

@asrvd
Copy link
Member

asrvd commented Jul 4, 2022

revert back?

@juliusmarminge
Copy link
Member

Is commit d2e4d87 considered a "fix" so we can close this? Or should we make it work for older git versions too?

@asrvd
Copy link
Member

asrvd commented Jul 5, 2022

i don't think forcing people to update git to use the cli is a good thing to do though..

@Dhravya
Copy link
Contributor

Dhravya commented Jul 5, 2022

I think this was discussed in the server right? that we can just initialise the repository with git init, and then change the branch using git checkout -b main

@juliusmarminge
Copy link
Member

juliusmarminge commented Jul 5, 2022

I think this was discussed in the server right? that we can just initialise the repository with git init, and then change the branch using git checkout -b main

That had the side-effect of leaving behind an unused branch. Wouldn't something like:

const { stdout: gitVersion } = await execa("git --version");
// e.g. gitVersion = "git version 2.32.0 (Apple Git-132)"
const asNumber = ...; // parse the output
if (asNumber >= 2.28) {
  await execa("git init --initial-branch=main", { cwd: projectDir });
} else {
  await execa("git init", { cwd: projectDir });
  await execa("git checkout -b main", { cwd: projectDir }); // maybe?
}

be better?

@Dhravya
Copy link
Contributor

Dhravya commented Jul 5, 2022

Yeah. I think that's a better approach, leave an extra branch depending on the git version

@juliusmarminge
Copy link
Member

Yeah. I think that's a better approach, leave an extra branch depending on the git version

Leaving for work but I can have a PR out tonight.

Is the git --version output the same for every OS? So its parsable the same for all.

@Dhravya
Copy link
Contributor

Dhravya commented Jul 5, 2022

Yep, just checked the documentation, pretty sure it's the same command and the same response on every OS

I'm not sure about different versions though, maybe in an old version it was different? But this can just be YOLO'd and fixed as more users report issues

@asrvd
Copy link
Member

asrvd commented Jul 5, 2022

I think this was discussed in the server right? that we can just initialise the repository with git init, and then change the branch using git checkout -b main

That had the side-effect of leaving behind an unused branch. Wouldn't something like:

const { stdout: gitVersion } = await execa("git --version");
// e.g. gitVersion = "git version 2.32.0 (Apple Git-132)"
const asNumber = ...; // parse the output
if (asNumber >= 2.28) {
  await execa("git init --initial-branch=main", { cwd: projectDir });
} else {
  await execa("git init", { cwd: projectDir });
  await execa("git checkout -b main", { cwd: projectDir }); // maybe?
}

be better?

this would be a better approach i think 👍🏼

@Temez1
Copy link

Temez1 commented Sep 21, 2022

Got the same problem still with git version 2.25.1. WSL2, Ubuntu.

Initializing Git...
⠋ Creating a new git repo...
✖ Failed: could not initialize git. Update git to the latest version!

Worked with git version 2.37.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋‍♂️ help wanted Extra attention is needed 🐞 confirmed bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants