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

Could not create an empty Git repository, see debug logs with --verbose #2297

Closed
mcnaveen opened this issue Feb 14, 2024 · 16 comments
Closed

Comments

@mcnaveen
Copy link

mcnaveen commented Feb 14, 2024

Environment

  • react-native@0.73.4
  • Darwin macbook-air 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:34 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8103 arm64

Description

Trying to init a new react native project.

Upon running npx react-native@latest init myapp It throws the following error. Also the create folder is empty.

Downloading template error
✖ Downloading template
✖ Could not create an empty Git repository, see debug logs with --verbose

I have attached a screenshot of the error below.

image

Similar issue #2212 | Proposed/Merged fix: #2215 But it's still occuring.

Reproducible Demo

Create a new React Native project with the command npx react-native@latest init myapp


Also, when you run npx react-native info it says unknown command.

@szymonrybczak
Copy link
Collaborator

hey @mcnaveen, can you run with --verbose?

@mcnaveen
Copy link
Author

Hi @szymonrybczak Sure, here it is.

$ npx react-native init watermelon --verbose
debug We couldn't find a package.json in your project. Are you sure you are running it inside a React Native project?
debug Failed to load configuration of your project. Only a subset of commands will be available.
debug Initializing new project


                  Welcome to React Native!
                 Learn once, write anywhere

debug Installing template from react-native@latest
yarn init v1.22.19
warning The yes flag has been set. This will automatically answer yes to all questions, which may have security implications.
success Saved package.json
✨  Done in 0.08s.
yarn config v1.22.19
success Set "nodeLinker" to "node-modules".
✨  Done in 0.09s.
yarn add v1.22.19
info No lockfile found.
[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "Invalid URL".
info If you think this is a bug, please open a bug report with the information provided in "/private/var/folders/j8/6l83d1h53s1_10sqlgdn2drc0000gn/T/rncli-init-template-XI48fR/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Installing pods failed. This doesn't affect project initialization and you can safely proceed.
However, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.



info 💡 To enable automatic CocoaPods installation when building for iOS you can create react-native.config.js with automaticPodsInstallation field.
For more details, see https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation

debug Error: Command failed with exit code 1: git commit -m Initial commit


On branch main

Initial commit

nothing to commit (create/copy files and use "git add" to track)


  Run instructions for Android:
    • Have an Android emulator running (quickest way to get started), or a device connected.
    • cd "/Users/mcnaveen/Documents/dev/watermelon" && npx react-native run-android

  Run instructions for iOS:
    • cd "/Users/mcnaveen/Documents/dev/watermelon/ios"

    • Install Cocoapods
      • bundle install # you need to run this only once in your project.
      • bundle exec pod install
      • cd ..

    • npx react-native run-ios
    - or -
    • Open watermelon/ios/watermelon.xcodeproj in Xcode or run "xed -b ios"
    • Hit the Run button

  Run instructions for macOS:
    • See https://aka.ms/ReactNativeGuideMacOS for the latest up-to-date instructions.

and I can't find this log /private/var/folders/j8/6l83d1h53s1_10sqlgdn2drc0000gn/T/rncli-init-template-XI48fR/yarn-error.log

@szymonrybczak
Copy link
Collaborator

Can you try with --npm?

@mcnaveen
Copy link
Author

mcnaveen commented Feb 14, 2024

I feel like this is more of a yarn issue. Because, With --npm it seems to be working normally. The project is initialized.

Also, here is the yarn config.

$yarn config list
yarn config v1.22.19
info yarn config
{
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.npmjs.org',
  'strict-ssl': true,
  'user-agent': 'yarn/1.22.19 npm/? node/v18.13.0 darwin arm64',
  lastUpdateCheck: 1707900363661,
  nodeLinker: 'node-modules'
}
info npm config
{
  editor: 'code',
  'registry.npmjs.org/:_authToken': 'npm_XXXXXXXXXXXXXX'
}

@szymonrybczak
Copy link
Collaborator

szymonrybczak commented Feb 14, 2024

After initializing the project, can you install dependencies with Yarn inside project? Or do you have the same error as when initializing?

@mcnaveen
Copy link
Author

Once the project is initialized, I can install the dependencies with yarn. It seems to be working fine.

@szymonrybczak
Copy link
Collaborator

Hm, very strange. Unfortunately I cannot reproduce it myself :(

@mcnaveen
Copy link
Author

mcnaveen commented Feb 14, 2024

Happy to provide more info if needed. Will try this on my Linux machine after I wake up. Think I face this only on Mac OS M1

@szymonrybczak
Copy link
Collaborator

I see that there's a log file that probably contain more useful information about the failure:

info If you think this is a bug, please open a bug report with the information provided in "/private/var/folders/j8/6l83d1h53s1_10sqlgdn2drc0000gn/T/rncli-init-template-XI48fR/yarn-error.log".

Maybe you could run init one more time and look inside this file?

@mcnaveen
Copy link
Author

Hi @szymonrybczak This is strange, I can't reproduce this on my Linux machine. Happens only on Mac M1. Also, I can't access the log fie. It says file not found.

Linux mcnaveen 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

@mcnaveen
Copy link
Author

So, here is the update on the issue.:

It of course fails with the yarn v1.22.19. But after enabling the Yarn v4 via corepack this seems to be working normally.

Here are the steps to set the yarn to v4. By default, the corepack is being shipped with node latest version.

  1. corepack enable
  2. yarn set version stable
  3. now run the init command again.

This time it'll use yarn v4 and works without any issue.

@szymonrybczak
Copy link
Collaborator

Alright, so let's keep the latest version of Yarn, as it's faster and more secure. Thanks for digging into this issue! 🙏

@anamK4923
Copy link

this also happend on windows 11
image

@anamK4923
Copy link

this also happend on windows 11 image

I have solved this problems by deleting yarn.lock, package.json, package-lock.json in C:\Users\ACER
image

@Heliosoto1987
Copy link

this also happend on windows 11 image

I have solved this problems by deleting yarn.lock, package.json, package-lock.json in C:\Users\ACER image

That work for me, thanks

@Andreas-UI
Copy link

this also happend on windows 11 image

I have solved this problems by deleting yarn.lock, package.json, package-lock.json in C:\Users\ACER image

This works for me too, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants