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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileSystem has not been configured. Please call setFileSystem() before calling this method. #32352

Closed
SGissubel opened this issue Aug 27, 2019 · 5 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler needs reproduction This issue needs a reproduction in order for the team to investigate further regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Milestone

Comments

@SGissubel
Copy link

馃悶 Bug report

Command

- npm run build

AND/OR 

- gulp build

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular 7.

Description

Just updated my company's private npm-package/project to use Angular 8, from Angular 7. After upgrading, ran gulp build (also ran npm run build), and got the error:
FileSystem has not been configured. Please call 'setFileSystem()' before calling this method.

Entire Message:


馃敩 Minimal Reproduction

Cannot provide code due to privacy of code - but all that I did was upgrade from Angular 7 to Angular 8

馃敟 Exception or Error


gulp build
[13:31:20] Using gulpfile ~/Desktop/YTG/Projects/Ytg.Angular/gulpfile.js
[13:31:20] Starting 'build'...
[13:31:20] Starting 'cleanDist'...
[13:31:20] Finished 'cleanDist' after 14 ms
[13:31:20] Starting 'cleanTmp'...
[13:31:20] Finished 'cleanTmp' after 2.41 ms
[13:31:20] Starting 'cleanBuild'...
[13:31:20] Finished 'cleanBuild' after 407 渭s
[13:31:20] Starting 'cleanDist'...
[13:31:20] Finished 'cleanDist' after 471 渭s
[13:31:20] Starting 'copySource'...
[13:31:20] Finished 'copySource' after 43 ms
[13:31:20] Starting 'inlineResources'...
[13:31:20] Finished 'inlineResources' after 6.39 ms
[13:31:20] Starting 'ngc'...
Error: FileSystem has not been configured. Please call `setFileSystem()` before calling this method.
    at makeError (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/ngtsc/file_system/src/invalid_file_system.js:63:16)
    at InvalidFileSystem.resolve (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/ngtsc/file_system/src/invalid_file_system.js:42:19)
    at calcProjectFileAndBasePath (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/perform_compile.js:113:29)
    at Object.readConfiguration (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/perform_compile.js:132:22)
    at readCommandLineAndConfiguration (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/main.js:146:40)
    at readNgcCommandLineAndConfiguration (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/main.js:119:22)
    at main (/Users/***/Desktop/***/Projects/***/node_modules/@angular/compiler-cli/src/main.js:32:28)
    at ngc (/Users/***/Desktop/***/Projects/***/gulpfile.js:52:3)
    at bound (domain.js:402:14)
    at runBound (domain.js:415:12)
[13:31:20] Finished 'ngc' after 2.81 ms
[13:31:20] Starting 'rollupFesm'...
[13:31:20] Finished 'rollupFesm' after 3.35 ms
[13:31:20] Starting 'rollupUmd'...
[13:31:20] Finished 'rollupUmd' after 2.92 ms
[13:31:20] Starting 'copyBuild'...
[13:31:20] Finished 'copyBuild' after 1.82 ms
[13:31:20] Starting 'copyManifest'...
[13:31:20] Finished 'copyManifest' after 2.48 ms
[13:31:20] Starting 'copyReadme'...
[13:31:20] Finished 'copyReadme' after 2.47 ms
[13:31:20] Starting 'cleanBuild'...
[13:31:20] Finished 'cleanBuild' after 381 渭s
[13:31:20] Starting 'cleanTmp'...
[13:31:20] Finished 'cleanTmp' after 8.05 ms
[13:31:20] Finished 'build' after 96 ms

馃實 Your Environment


Angular CLI: 8.3.0
Node: 10.16.0
OS: darwin x64
Angular: 8.2.3
... common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.0
@angular-devkit/core         8.3.0
@angular-devkit/schematics   8.3.0
@angular/cli                 8.3.0
@angular/http                7.2.15
@schematics/angular          8.3.0
@schematics/update           0.803.0
rxjs                         6.5.2
typescript                   3.5.3
@clydin
Copy link
Member

clydin commented Aug 27, 2019

From the log output, the Angular CLI doesn't appear to be used.

Transferring this to the Framework repository that manages the @angular/compiler-cli project. However, more information about the project and its custom build system will most likely be needed to assist further.

@clydin clydin transferred this issue from angular/angular-cli Aug 27, 2019
@gkalpak
Copy link
Member

gkalpak commented Aug 27, 2019

As @clydin said, it is hard to provide any help without knowing more about the failing gulp task.
What does the ngc gulp task do?

@gkalpak gkalpak added area: compiler Issues related to `ngc`, Angular's template compiler regression Indicates than the issue relates to something that worked in a previous version needs reproduction This issue needs a reproduction in order for the team to investigate further type: bug/fix labels Aug 27, 2019
@ngbot ngbot bot modified the milestone: needsTriage Aug 27, 2019
@SGissubel
Copy link
Author

@gkalpak:

ngc:

var gulp = require('gulp'),
  path = require('path'),
  gulpNgc = require('@angular/compiler-cli/src/main').main,
  rollup = require('gulp-better-rollup'),
  rename = require('gulp-rename'),
  del = require('del'),
  gulpInlineResources = require('./tools/gulp/inline-resources');
function ngc() {
  gulpNgc([ '-p', `${tmpFolder}/tsconfig.es5.json` ]);
  return Promise.resolve();
};

image

@gkalpak
Copy link
Member

gkalpak commented Aug 28, 2019

I see. So, you are essentially hacking around the fact that main() is not part of the public API by using a deep import (importing from @angular/compiler/src/main, instead @angular/compiler).
Note this is not officially supported (but will probably work fine).

Basically, you are trying to emulate this bit, but are currently missing this line. I think the following should fix it (but it is still a hack 馃槂):

+var ngFsUtils = require('@angular/compiler-cli/src/ngtsc/file_system');
 function ngc() {
+  ngFsUtils.setFileSystem(new ngFsUtils.NodeJSFileSystem());
   gulpNgc([ '-p', `${tmpFolder}/tsconfig.es5.json` ]);
   return Promise.resolve();
 }

Alternatively, you could leave everything as is and just import/require @angular/compiler-cli (which sets up the file-system):

+// Import `compiler-cli` for the side-effect of setting up the internal `FileSystem`.
+require('@angular/compiler-cli');

NOTE: There might be subtle implications with this second approach, so I suggest you go with the first one (which is a hack, but not any different than the hack you are already employing).

Closing, because everything works as expected and the breakage is due to using private APIs.

@gkalpak gkalpak closed this as completed Aug 28, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler needs reproduction This issue needs a reproduction in order for the team to investigate further regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Projects
None yet
Development

No branches or pull requests

3 participants