Skip to content

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

Closed as not planned

Description

@gregmagolan

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:

Activity

  1. gregmagolan commented on Apr 21, 2019

    @gregmagolan
    ContributorAuthor

    @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.

  2. added
    team-Bazel
    P2
    on Apr 22, 2019
  3. added
    untriaged
    and removed
    team-Bazel
    P2
    on Jul 5, 2019
  4. added
    P3
    and removed
    untriaged
    on Jul 8, 2019
  5. kylecordes commented on Oct 24, 2019

    @kylecordes

    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.

  6. brandjon commented on Feb 17, 2021

    @brandjon
    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.

  7. added
    P4
    and removed
    P3
    on Feb 17, 2021
  8. nkoroste commented on Feb 18, 2021

    @nkoroste
    Contributor

    better to be consistent with .gitignore syntax

    +1 to this

  9. aiuto commented on Jan 11, 2022

    @aiuto

    This is a duplicate of #7093

  10. guw commented on Feb 1, 2022

    @guw
    Contributor

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

  11. brandjon commented on Nov 4, 2022

    @brandjon
    Member

    Closing as dup of #7093.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4type: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions