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

Add Yarn files to .gitignore #47083

Closed
wants to merge 1 commit into from

Conversation

zhongwuzw
Copy link
Contributor

@zhongwuzw zhongwuzw commented Oct 17, 2024

Summary:

After running yarn install in the root directory of a React Native project, cached files from Yarn appear when checking Git changes, which can be a bit annoying. Let's ignore them! :)

This commit references #42313.

image

Changelog:

[GENERAL] [ADDED] - Add Yarn files to .gitignore in react-native

Test Plan:

yarn cached files should ignore after exec pod install

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Oct 17, 2024
@cortinico
Copy link
Contributor

/rebase

Copy link
Member

@huntie huntie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhongwuzw How are you configuring Yarn here? Yarn should not generate any v3/v4 files in .yarn/ when it detects a Yarn Classic (1.x) project such as this repository. (Happy to be corrected on if this behaviour has changed.)

Are you instead aiming to ignore .yarn/ files in a newly created React Native project via the Community CLI? (cc @szymonrybczak)

@zhongwuzw
Copy link
Contributor Author

@zhongwuzw How are you configuring Yarn here? Yarn should not generate any v3/v4 files in .yarn/ when it detects a Yarn Classic (1.x) project such as this repository. (Happy to be corrected on if this behaviour has changed.)

@huntie I don't change any configs in my react-native repo, maybe because my yarn version is v3?

image

Are you instead aiming to ignore .yarn/ files in a newly created React Native project via the Community CLI? (cc @szymonrybczak)

No, I did some work in react-native repo , not a rn project via cli.

@huntie
Copy link
Member

huntie commented Oct 17, 2024

@zhongwuzw Thanks for clarifying!

Interesting. Can you share more about how you installed Yarn on your system?

On my Mac, I've used brew install yarn, which is currently 1.22.19 globally, and works with this repo. (Then, what I mentioned was the other way round: If I cd into a project specifying Yarn 4 (containing .yarnrc.yml), Corepack/my Yarn 1.x binary will select that newer Yarn version for that other project.)

I tried out a Corepack install (i.e. following modern Yarn's current install process). If I spin up a fresh GitHub Codespace and try this, it also resolves to Yarn 1.x:

image

The main thing to note here is this repository requires Yarn 1.x. I'll open a separate PR which helps programatically manage this via Corepack. And perhaps we should also update our contributing docs.

huntie added a commit to huntie/react-native that referenced this pull request Oct 17, 2024
Summary:
Prompted by facebook#47083, this change adds a `"packageManager"` field to the root `package.json` specifying `yarn@1.22.22`. This will configure a compatible, predictable version of Yarn for users using [Corepack](https://nodejs.org/api/corepack.html) via the Yarn Modern install process.

See https://yarnpkg.com/getting-started/install and https://nodejs.org/api/corepack.html.

Tested on a fresh system (GitHub Codespaces).

Changelog: [Internal]

Differential Revision: D64536673
@zhongwuzw
Copy link
Contributor Author

@huntie Sorry I forgot how to install and upgrade my yarn on my Mac :) , and I don't use any yml to specify yarn's version.

image

@huntie
Copy link
Member

huntie commented Oct 17, 2024

@zhongwuzw Okay 🙂 Curious if you could try again with the change from #47091.

@zhongwuzw
Copy link
Contributor Author

@zhongwuzw Okay 🙂 Curious if you could try again with the change from #47091.

@huntie I applied the changes of #47091, I removed the .yarn directory and exec yarn install again , it still creates .yarn directory.

image

@huntie
Copy link
Member

huntie commented Oct 17, 2024

@zhongwuzw Can you also check and remove any .yarnrc[.yml] in the project dir and all parent directories?

Annoyingly, if globally configured (example is contrived), Yarn can self-upgrade itself in the repo, ignoring "packageManager" and even "engines" -_-.

image
  • Do you get any similar Yarn output saying it's migrating your project?
  • Also can you try freshly cloning facebook/react-native in a separate directory?

Either way, we require Yarn 1.x in this repo, so I won't be able to accept this .gitignore change, which will mask an incorrect install.

@zhongwuzw
Copy link
Contributor Author

zhongwuzw commented Oct 17, 2024

@zhongwuzw Can you also check and remove any .yarnrc[.yml] in the project dir and all parent directories?

Not have any .yarnrc[.yml] in the project dir and all parent directories.

Annoyingly, if globally configured (example is contrived), Yarn can self-upgrade itself in the repo, ignoring "packageManager" and even "engines" -_-.

image * Do you get any similar Yarn output saying it's migrating your project?

No.

  • Also can you try freshly cloning facebook/react-native in a separate directory?

@huntie I tried it and applied your #47091, it also creates .yarn directory.

Either way, we require Yarn 1.x in this repo, so I won't be able to accept this .gitignore change, which will mask an incorrect install.

ok, I'll add the gitignore on my local env. I'll close it.

@zhongwuzw zhongwuzw closed this Oct 17, 2024
facebook-github-bot pushed a commit that referenced this pull request Oct 17, 2024
Summary:
Pull Request resolved: #47091

Prompted by #47083, this change adds a `"packageManager"` field to the root `package.json` specifying `yarn@1.22.22`. This will configure a compatible, predictable version of Yarn for users using [Corepack](https://nodejs.org/api/corepack.html) via the Yarn Modern install process.

See https://yarnpkg.com/getting-started/install and https://nodejs.org/api/corepack.html.

Tested on a fresh system (GitHub Codespaces).

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D64536673

fbshipit-source-id: 535c0ca725172e4a06de04b19c6cd2d31788f5a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants