-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[FR] .bazelignore should support wildcard prefix #7093
Comments
Is somebody working on this issue? If not, I'd like to start working on a patch. |
+1 for the Angular repo.
|
+1 for all the rules_* repos, which typically have a variety of sub-repos to handle testing the rules. |
@tclem ran into an issue where he had built `semantic-source` from the `semantic-source` directory; `cabal` placed a `dist-newstyle` directory there, which was fouling up Bazel due to the fact that `cabal` generates binary files called `BUILD`, and Bazel tries to interpret these files as package configurations. Not good! We can't use a glob here because .bazelignore files don't support globbing (bazelbuild/bazel#7093), so it suffices to ignore all the projects' `dist-newstyle` directories so that no one runs into this again.
@tclem ran into an issue where he had built `semantic-source` from the `semantic-source` directory; `cabal` placed a `dist-newstyle` directory there, which was fouling up Bazel due to the fact that `cabal` generates binary files called `BUILD`, and Bazel tries to interpret these files as package configurations. Not good! We can't use a glob here because .bazelignore files don't support globbing (bazelbuild/bazel#7093), so it suffices to ignore all the projects' `dist-newstyle` directories so that no one runs into this again.
also related #13807 |
Is this a dup of #8106? |
Bazel removed `managed_directories` feature on Bazel@HEAD, see: [1]. Design document is here: [2]. Also extend the .bazelignore and add explicitly the path to the node_modules directories. Note, that Bazel currently doesn't support the same semantic as .gitignore. For more details see this issue: [3] and this issue specific to rules_nodejs: [4]. [1] bazelbuild/bazel#15463 [2] https://docs.google.com/document/d/1u9V5RUc7i6Urh8gGfnSurxpWA7JMRtwCi1Pr5BHeE44/edit [3] bazelbuild/bazel#7093 [4] bazelbuild/bazel#8106 Release-Notes: skip Change-Id: I5dc582e05e4116064fc06d438d4b8a8b57b6bb8d
Experience report: Like others, we have a monorepo where developers run Even with these precautions, we run into issues after the repo structure has changed upstream and a developer does I acknowledge that the root cause here is really that we put non-source files into the source tree, but we are not aware of a practical way to avoid that (short of building our own IDE plugins). Wildcards in the |
This creates a new `pnpm-workspace.yaml` which makes it install `node_modules/` in all the `packages/*` directories. This wasn't necessary before because `rules_prerender` and `@rules_prerender/declarative_shadow_dom` don't have any external dependencies, but it is necessary to install package-specific dependencies. Also updates `tsconfig.json` to work for any `@rules_prerender/*` packages instead of just `@rules_prerender/declarative_shadow_dom`. `.bazelignore` needs to be updated as well, but doesn't support globs unfortunately (see bazelbuild/bazel#7093). `node_modules/` verification was also incorrectly being done on the user `.bazelignore` file, rather than `@rules_prerender`'s `.bazelignore` when loaded as an external workspace. Used a `Label()` constructor to fix that.
This creates a new `pnpm-workspace.yaml` which makes it install `node_modules/` in all the `packages/*` directories. This wasn't necessary before because `rules_prerender` and `@rules_prerender/declarative_shadow_dom` don't have any external dependencies, but it is necessary to install package-specific dependencies. Also updates `tsconfig.json` to work for any `@rules_prerender/*` packages instead of just `@rules_prerender/declarative_shadow_dom`. `.bazelignore` needs to be updated as well, but doesn't support globs unfortunately (see bazelbuild/bazel#7093). `node_modules/` verification was also incorrectly being done on the user `.bazelignore` file, rather than `@rules_prerender`'s `.bazelignore` when loaded as an external workspace. Used a `Label()` constructor to fix that.
This creates a new `pnpm-workspace.yaml` which makes it install `node_modules/` in all the `packages/*` directories. This wasn't necessary before because `rules_prerender` and `@rules_prerender/declarative_shadow_dom` don't have any external dependencies, but it is necessary to install package-specific dependencies. Also updates `tsconfig.json` to work for any `@rules_prerender/*` packages instead of just `@rules_prerender/declarative_shadow_dom`. `.bazelignore` needs to be updated as well, but doesn't support globs unfortunately (see bazelbuild/bazel#7093). `node_modules/` verification was also incorrectly being done on the user `.bazelignore` file, rather than `@rules_prerender`'s `.bazelignore` when loaded as an external workspace. Used a `Label()` constructor to fix that.
Progress towards #7093. RELNOTES: None. PiperOrigin-RevId: 686088272 Change-Id: I17ea2481ed58b76352ff1939b78ba93b8bdc9eac
This required a number of somewhat awkward .toRelative() calls, but the alternative would have been to make IgnoredSubdirectories either have all absolute paths or all relative paths (both prefixes and inputs) and this one seemed simpler. Progress towards #7093. RELNOTES: None. PiperOrigin-RevId: 686411349 Change-Id: I62b0b7f12801e7b44b6e064893c1dc0cb282badb
I have a change out that almost works. The "almost" part is because apparently requring the evaluation of The dependency cycle is as follows:
Thus, dependency cycle. More simply: The main repository mapping depends on the @meteorcloudy do you have any ideas how to fix this? |
You can cut the last edge without any loss in functionality. |
@fmeum You are technically correct, but |
@lberki But doesn't that only require the repo mapping of the repo containing the |
I don't know. I assumed that the reason why the main repo mapping is passed in is so that the labels reported on the debug output are consistent, no matter which repository they are in. @meteorcloudy is that correct? It looks like we do pass in Let me create a pull request so that we can better discuss the change... |
#24022 it is. |
(paging @Wyverald ) |
Looks promising! I didn't have time to make a proper pull request, but this change implementing the "split https://bazel-review.googlesource.com/c/bazel/+/261670 seems to be looking good, although the tests didn't finish by the end of my workday: https://buildkite.com/bazel/google-bazel-presubmit/builds/85367 |
This is accomplished by a new directive in REPO.bazel, "ignore_directories()". It takes a single argument, a list of directories to ignore and it allows the same wildcards as glob(). This is done separately from .bazelignore to provide a migration path off of that weird single-purpose configuration file. Implementing this requires splitting RepoFileFunction into two: a part that parses the repository file and one that creates a PackageArgs instance. This was necessary to avoid a Skyframe dependency cycle: when a WORKSPACE file is present and it loads a .bzl file from a repository with a REPO.bazel file, the repo mapping for the main repository depends on the WORKSPACE file, which depends on the .bzl file, which depends on the IgnoredPackagePrefixesValue of its repository, which then depends on the repo mapping of the main repository and the one the .bzl file is in, which then depend on the WORKSPACE file. Fixes #7093. RELNOTES[NEW]: REPO.bazel now allows another directive, "ignore_directories()". It takes a list of directories to ignore just like .bazelignore does, but with glob semantics.
#24032 implements this feature, makes all test cases pass and is principled enough to be submittable. Let the review begin! |
This is accomplished by a new directive in REPO.bazel, "ignore_directories()". It takes a single argument, a list of directories to ignore and it allows the same wildcards as glob(). This is done separately from .bazelignore to provide a migration path off of that weird single-purpose configuration file. Implementing this requires splitting RepoFileFunction into two: a part that parses the repository file and one that creates a PackageArgs instance. This was necessary to avoid a Skyframe dependency cycle: when a WORKSPACE file is present and it loads a .bzl file from a repository with a REPO.bazel file, the repo mapping for the main repository depends on the WORKSPACE file, which depends on the .bzl file, which depends on the IgnoredPackagePrefixesValue of its repository, which then depends on the repo mapping of the main repository and the one the .bzl file is in, which then depend on the WORKSPACE file. Fixes #7093. RELNOTES[NEW]: REPO.bazel now allows another directive, "ignore_directories()". It takes a list of directories to ignore just like .bazelignore does, but with glob semantics.
This is now fixed at HEAD: you can use the @meteorcloudy do you think I should backport this feature to Bazel 8.0? |
I think we should do it, this is a nice feature that probably needs some migration time for community, so let's get it in an official release as soon as possible. |
Ack. @Wyverald opined that you'd think otherwise, but I assume it was not that he had concerns, it's just that he thought you had. How urgent is the backporting? |
This is accomplished by a new directive in REPO.bazel, "ignore_directories()". It takes a single argument, a list of directories to ignore and it allows the same wildcards as glob(). This is done separately from .bazelignore to provide a migration path off of that weird single-purpose configuration file. Implementing this requires splitting RepoFileFunction into two: a part that parses the repository file and one that creates a PackageArgs instance. This was necessary to avoid a Skyframe dependency cycle: when a WORKSPACE file is present and it loads a .bzl file from a repository with a REPO.bazel file, the repo mapping for the main repository depends on the WORKSPACE file, which depends on the .bzl file, which depends on the IgnoredPackagePrefixesValue of its repository, which then depends on the repo mapping of the main repository and the one the .bzl file is in, which then depend on the WORKSPACE file. Fixes #7093. RELNOTES[NEW]: REPO.bazel now allows another directive, "ignore_directories()". It takes a list of directories to ignore just like .bazelignore does, but with glob semantics. Closes #24032. PiperOrigin-RevId: 693227896 Change-Id: Ia3e02a2bfe9caf999fc641f75261b528b19c1d03
#24203 sent out to backport this to Bazel 8.0.0. |
We still have about 2 weeks before the final release, but the sooner the better ;) |
Already done, it was much easier than I expected. |
This is accomplished by a new directive in REPO.bazel, "ignore_directories()". It takes a single argument, a list of directories to ignore and it allows the same wildcards as glob(). This is done separately from .bazelignore to provide a migration path off of that weird single-purpose configuration file. Implementing this requires splitting RepoFileFunction into two: a part that parses the repository file and one that creates a PackageArgs instance. This was necessary to avoid a Skyframe dependency cycle: when a WORKSPACE file is present and it loads a .bzl file from a repository with a REPO.bazel file, the repo mapping for the main repository depends on the WORKSPACE file, which depends on the .bzl file, which depends on the IgnoredPackagePrefixesValue of its repository, which then depends on the repo mapping of the main repository and the one the .bzl file is in, which then depend on the WORKSPACE file. Fixes #7093. RELNOTES[NEW]: REPO.bazel now allows another directive, "ignore_directories()". It takes a list of directories to ignore just like .bazelignore does, but with glob semantics. Closes #24032. PiperOrigin-RevId: 693227896 Change-Id: Ia3e02a2bfe9caf999fc641f75261b528b19c1d03
Is there any documentation for this change? I was able to piece together the syntax from the unit tests in the PR, but would be great to surface this in docs somewhere for other users! |
Thanks for the nudge -- I'll be looking at adding docs tomorrow! |
Follow-up for #7093 PiperOrigin-RevId: 693795472 Change-Id: Icac2f5658d1579377a38979905214ead9da73dac
thanks for implementing this, very much looking forward to using it once my team upgrades to bazel 8! |
Description of the feature request:
Currently
.bazelignore
supports only full relative path prefix without any wildcardsI have many
node_modules
subfolders in my repo that I want to ignore.With
.gitignore
I'd just need to put:node_modules
and it will be ignored by git.With
.bazelignore
I need to specify each folder by it's full relative path from workspace root.I suggest to adjust behavior to the way
.gitignore
and save our users the trouble of collecting all folders.What operating system are you running Bazel on?
We tested it on linux with bazel 0.20.0 and 0.21.0
The text was updated successfully, but these errors were encountered: