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

No way to tell .bazelignore to ignore all folders of the given name #8106

Closed
gregmagolan opened this issue Apr 21, 2019 · 7 comments
Closed
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: feature request

Comments

@gregmagolan
Copy link
Contributor

gregmagolan commented Apr 21, 2019

Description of the problem / feature request:

A .bazelignore pattern such as

node_modules

only ignores the node_modules folder at the root level where the .bazelignore file is. This means that in nodejs projects, every single node_modules folder needs to be explicitly listed in .bazelignore.

Not ignoring a node_modules folder can lead to unexpected build errors as these folders contain downloaded npm dependencies that may contain BUILD files that should be ignored. node_modules folders are almost always all untracked and ignored in .gitignore so there are often left around in subdirectories when changing git branches and these are not easily noticed as they are ignored by git.

Feature requests: what underlying problem are you trying to solve with this feature?

Have .bazelignore patterns that don't start with / match in any directory. This would match the behavior of .gitignore. For example:

# ignore root /node_modules folder
/node_modules

# ignore all folders named node_modules in the root directory or in subdirectories
node_modules

What operating system are you running Bazel on?

OSX

What's the output of bazel info release?

release 0.24.0

Any other information, logs, or outputs that you want to share?

For reference:

@gregmagolan
Copy link
Contributor Author

@alexeagle This issue will be a problem for rules_nodejs users after bazel-contrib/rules_nodejs#704 lands since every yarn_install & npm_install rule will create a node_modules folder somewhere in the user's WORKSPACE that will be ignored by git by default but not by bazel.

@aiuto aiuto added team-Bazel General Bazel product/strategy issues P2 We'll consider working on this in future. (Assignee optional) labels Apr 22, 2019
@dslomov dslomov added team-Starlark untriaged and removed team-Bazel General Bazel product/strategy issues P2 We'll consider working on this in future. (Assignee optional) labels Jul 5, 2019
@laurentlb laurentlb added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request and removed untriaged labels Jul 8, 2019
@kylecordes
Copy link

Indeed, this is a problem.

Expected behavior, from working with other tools that have a ".ignore" file, would be that node_modules ignores that dir anywhere in the tree, while /node_modules ignores it only adjacent to the .ignore file.

@brandjon
Copy link
Member

This sounds like a reasonable request. I'm a bit worried that it might be too easy to accidentally exclude a directory, and wonder if the use of a wildcard syntax on anchored patterns might help make it more explicit. But then again, it's probably better to be consistent with .gitignore syntax.

@brandjon brandjon added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Build-Language and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Starlark labels Feb 17, 2021
@nkoroste
Copy link
Contributor

better to be consistent with .gitignore syntax

+1 to this

@aiuto
Copy link
Contributor

aiuto commented Jan 11, 2022

This is a duplicate of #7093

@guw
Copy link
Contributor

guw commented Feb 1, 2022

Another discovery: Is Bazel not ignoring the .git folder by default?

hanwen pushed a commit to GerritCodeReview/gerrit that referenced this issue Jun 7, 2022
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
@brandjon
Copy link
Member

brandjon commented Nov 4, 2022

Closing as dup of #7093.

@brandjon brandjon closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: feature request
Projects
None yet
Development

No branches or pull requests

8 participants