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

tsc v3.4RC: Incremental build fails when --rootDir passed on CLI #30457

Closed
Coridyn opened this issue Mar 18, 2019 · 4 comments
Closed

tsc v3.4RC: Incremental build fails when --rootDir passed on CLI #30457

Coridyn opened this issue Mar 18, 2019 · 4 comments
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@Coridyn
Copy link

Coridyn commented Mar 18, 2019

TypeScript Version: 3.4.0-dev.20190316

Search Terms: incremental, False expression, both be relative

Code

//tsconfig.json
{
    "compilerOptions": {
        "incremental": true,
        "outDir": "dist"
    }
}

$ tsc -p tsconfig.json --rootDir src

Expected behavior:
Project is built successfully.

Actual behavior:
Build fails with Error: Debug Failure. False expression: Paths must either both be absolute or both be relative.

When a project has this setup:

  • "incremental": true
  • outDir has value (doesn't matter if the value is from tsconfig.json or CLI)
  • --rootDir ... set from CLI

NOTE: Build is successful when rootDir value is set in tsconfig.json (instead of passed on CLI).

So this will work:

//tsconfig.json
{
    "compilerOptions": {
        "incremental": true,
        "outDir": "dist",
        "rootDir": "src"
    }
}

$ tsc -p tsconfig.json

Reproduction Link:
Project available here: https://github.com/Coridyn/ts34-incremental-issue

Related Issues: N/A

@sheetalkamat sheetalkamat added the Bug A bug in TypeScript label Mar 18, 2019
@sheetalkamat
Copy link
Member

The cause of this is that commandLine rootDir is not resolved to configFile or commandLine directory where as tsconfig options that are filePath are always resolved in directory path of config file

@nealeu
Copy link

nealeu commented Apr 10, 2019

Hi,
I've just gone from 3.3.3333 to 3.4.2 and got the same problem (but only via gulp-typescript) via getOutputPathForBuildInfo(). We've got composite: true, so I guess this is what's bringing in the incremental build code path.

In our case, some quirkiness due to the .ts being embedded in an old school Java app

    "compilerOptions": {
        "outDir": "../../../../../../../../target/classes/com/ecco/offline/staticFiles/build",
        "rootDir": "."

In my case the fromDirectory and to args are: /home/neale/dev/path/to/stuff/scripts (which is rootDir resolved as absolute) and tsconfig.

Edit: Hold that thought. Directly invoking tsc is not throwing up that error. I'm getting the error only via gulp-typescript, which is because --incremental is not yet supported, and in need of the API support #29978

Disabling incremental doesn't work for gulp-typescript (or at least I couldn't get it to behave), but looking into the code I found that we can avoid the issue by explicitly specifying tsBuildInfoFile:

        "tsBuildInfoFile": "./buildcache/tsBuildInfo",

@MikeMitterer
Copy link

MikeMitterer commented Apr 10, 2019

I had the same problem when move to 3.4.3

Old cmd in package.json (fails with 3.4.3)

"build:ts": "tsc --rootDir src/main --project tsconfig.lib.json --declaration --outDir lib",

New version - works with 3.4.3

"build:ts": "tsc --rootDir $(pwd)/src/main --project tsconfig.lib.json --declaration --outDir $(pwd)/lib",

BTW:
In my case tsconfig.json includes tsconfig.lib.json
tsconfig.lib.json is used to generate the lib. Most of the settings are in tsconfig.lib.json.
This was also the case with the "incremental" setting but I had to move this setting from
tsconfig.lib.json to tsconfig.json because when it was in tsconfig.lib.json it did not generated all files...

@ulrichb
Copy link

ulrichb commented Jul 2, 2019

.. I'm getting the same error ("Debug Failure. False expression: Paths must either both be absolute or both be relative.") in my 3.6 nightly builds in a project where I use --incremental.

It started ~ with 3.6.0-dev.20190628. In previous versions I got no errors; also TS 3.5 works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants