nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.25k stars 2.31k forks source link

Cannot unignore sub directories of gitignored directories #19796

Open FrozenPandaz opened 11 months ago

FrozenPandaz commented 11 months ago

Current Behavior

For the following ignore files:

.gitignore

dir

.nxignore

!dir/subdir

dir/subdir does not actually get "unignored" for nx to hash.

Expected Behavior

For the following ignore files:

.gitignore

dir

.nxignore

!dir/subdir

dir/subdir does get "unignored" for nx to hash.

GitHub Repo

https://github.com/nrwl/nx-examples

Steps to Reproduce

  1. Add a .nxignore with the following:
!/.angular/cache/*/angular-webpack
  1. Add "{workspaceRoot}/.angular/cache/16.2.0/**/*" to the default inputs
  2. Run nx build cart --graph and look at the inputs

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.3.1
   OS     : linux-x64
   yarn   : 1.22.19

   nx (global)        : 17.0.0-rc.2
   nx                 : 17.1.0
   @nx/js             : 17.1.0
   @nx/jest           : 17.1.0
   @nx/eslint         : 17.1.0
   @nx/workspace      : 17.1.0
   @nx/angular        : 17.1.0
   @nx/cypress        : 17.1.0
   @nx/devkit         : 17.1.0
   @nx/eslint-plugin  : 17.1.0
   @nx/react          : 17.1.0
   @nx/web            : 17.1.0
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.0
   @ngrx/effects         : 16.0.0
   @ngrx/entity          : 16.0.0
   @ngrx/router-store    : 16.0.0
   @ngrx/store           : 16.0.0
   @ngrx/store-devtools  : 16.0.0

Failure Logs

N/a

Package Manager Version

yarn 1.22.19

Operating System

Additional Information

This is due to an issue in the ignores crate: https://github.com/BurntSushi/ripgrep/issues/1050

What does work is: For the following ignore files:

.gitignore

dir

.nxignore

!dir

Original issue: https://github.com/nrwl/nx/issues/6821

ecoms-ye commented 9 months ago

UPDATE:

The .env file is hashed when added to both .nxignore and sharedGlobals. (nx@17.1.3)

.nxignore

!.env*

nx.json

{
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "sharedGlobals": ["{workspaceRoot}/.env*"]
  }
}

Hello, thanks for this amazing project.

I'm trying to cache my task but I found changing my .env file (included in .gitignore) would cause a false positive even if the file is added in .nxignore and inputs.

The .env file is not even in file-map.json unless unignore it in .gitignore, so I guess if it's the same problem with this issue.