Bazel: No way to tell .bazelignore to ignore all folders of the given name

Created on 21 Apr 2019  路  2Comments  路  Source: bazelbuild/bazel

Description of the problem / feature request:

A .bazelignore pattern such as


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:

P3 team-Starlark feature request

Most helpful comment

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.

All 2 comments

@alexeagle This issue will be a problem for rules_nodejs users after https://github.com/bazelbuild/rules_nodejs/pull/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.

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.

Was this page helpful?
0 / 5 - 0 ratings