Skip to content

Bazel ng-new schematic doesn't handle less stylesheet format correctly #31209

Closed

Description

@henning96

🐞 bug report

Affected Package

The issue is caused by package @angular/bazel.

Is this a regression?

No, this never worked.

Description and Minimal Reproduction

The Bazel ng-new schematic doesn't seem to respect the less stylesheet format option.
I've followed the instructions on https://blog.angular.io/try-bazels-opt-in-preview-in-angular-cli-b9430bd00e82 to create a new Bazel project and selected less as my stylesheet format.
When trying to build the generated project, the build fails with the message:
index out of range (index is 0, but sequence has 0 elements) in sass_binary.

🔬 Minimal Reproduction

Create a new Bazel project by using the command:
ng new my-app --collection=@angular/bazel and choose the less stylesheet format option.
Then try to build the project by running ng build.

🔥 Exception or Error


ERROR: workspace_root/src/BUILD.bazel:12:9: Traceback (most recent call last):
        File "workspace_root/src/BUILD.bazel", line 10
                sass_binary(name = "global_stylesheet", src = ...], ...")
        File "workspace_root/src/BUILD.bazel", line 12, in sass_binary
                glob(["styles.css", "styles.scss"])[0]
index out of range (index is 0, but sequence has 0 elements)
ERROR: error loading package 'src': Package 'src' contains errors

🌍 Your Environment

Angular Version:


Angular CLI: 8.0.3
Node: 12.4.0
OS: darwin x64
Angular: 8.0.2
... animations, bazel, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.3
@angular-devkit/build-angular     0.800.3
@angular-devkit/build-optimizer   0.800.3
@angular-devkit/build-webpack     0.800.3
@angular-devkit/core              8.0.3
@angular-devkit/schematics        8.0.3
@angular/cli                      8.0.3
@bazel/bazel                      0.26.1
@bazel/ibazel                     0.10.3
@bazel/karma                      0.31.1
@bazel/typescript                 0.31.1
@ngtools/webpack                  8.0.3
@schematics/angular               8.0.3
@schematics/update                0.800.3
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Activity

  1. perjerz commented on Jun 22, 2019

    @perjerz

    same issue

    Angular CLI: 8.0.3
    Node: 10.15.3
    OS: darwin x64
    Angular: 8.0.2
    ... animations, bazel, common, compiler, compiler-cli, core
    ... forms, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.800.3
    @angular-devkit/build-angular     0.800.3
    @angular-devkit/build-optimizer   0.800.3
    @angular-devkit/build-webpack     0.800.3
    @angular-devkit/core              8.0.3
    @angular-devkit/schematics        8.0.3
    @angular/cli                      8.0.3
    @bazel/bazel                      0.26.1
    @bazel/bazel-darwin_x64           0.26.1
    @bazel/ibazel                     v0.10.3
    @bazel/karma                      0.31.1
    @bazel/typescript                 0.31.1
    @ngtools/webpack                  8.0.3
    @schematics/angular               8.0.3
    @schematics/update                0.800.3
    rxjs                              6.4.0
    typescript                        3.4.5
    webpack                           4.30.0
    
  2. perjerz commented on Jun 22, 2019

    @perjerz

    I has changed the project to css. The first build is fine.

    INFO: Analyzed target //src:prodapp (528 packages loaded, 19286 targets configured).
    INFO: Found 1 target...
    Target //src:prodapp up-to-date:
      dist/bin/src/prodapp
    INFO: Elapsed time: 97.560s, Critical Path: 28.03s
    INFO: 7 processes: 6 local, 1 worker.
    INFO: Build completed successfully, 8102 total actions
    

    However, I ran ng serve
    I got the error message.

    ng serve 
    Error getting Bazel info exec: "bazel": executable file not found in $PATH
    error setting higher file descriptor limit for this process: invalid argumentQuerying for files to watch...
    Bazel query failed: exec: "bazel": executable file not found in $PATH
    Bazel query failed: exec: "bazel": executable file not found in $PATH
    Runing //src:devserver
    Error running Bazel exec: "bazel": executable file not found in $PATH
    /Users/perjerz/bazel/node_modules/@bazel/ibazel/bin/darwin_amd64/ibazel failed with code 4.
    

    This error leads to bazelbuild/bazel-watcher#252

    After that I ran

    npm install -g @bazel/bazel
    

    Then, I got this error.

    ng serve                   
    error setting higher file descriptor limit for this process: invalid argumentQuerying for files to watch...
    Loading: 0 packages loaded
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/build_bazel_rules_sass_deps/sass/BUILD.bazel:249:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps and referenced by '@build_bazel_rules_sass_deps//sass:sass'
    Loading: 17 packages loaded
    Loading: 17 packages loaded
    Loading: 22 packages loaded
    Loading: 154 packages loaded
        currently loading: @npm//node_modules/arr-union
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/io_bazel_rules_sass/sass/BUILD:11:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps and referenced by '@io_bazel_rules_sass//sass:sass_bin'
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/build_bazel_rules_sass_deps/sass/BUILD.bazel:249:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps and referenced by '@build_bazel_rules_sass_deps//sass:sass'
    ERROR: Evaluation of subquery "deps(set(//src:devserver))" failed (did you want to use --keep_going?): errors were encountered while computing transitive closure
    Loading: 266 packages loaded
    Loading: 266 packages loaded
    Bazel query failed: exit status 7
    Loading: 0 packages loaded
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/io_bazel_rules_sass/sass/BUILD:11:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps and referenced by '@io_bazel_rules_sass//sass:sass_bin'
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/build_bazel_rules_sass_deps/sass/BUILD.bazel:249:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps and referenced by '@build_bazel_rules_sass_deps//sass:sass'
    ERROR: Evaluation of subquery "deps(set(//src:devserver))" failed (did you want to use --keep_going?): errors were encountered while computing transitive closure
    Loading: 0 packages loaded
    Loading: 0 packages loaded
    Bazel query failed: exit status 7
    Runing //src:devserver
    Loading: 0 packages loaded
    Loading: 0 packages loaded
    
    Loading: 0 packages loaded
    Launching with notifications
    listening on :35729
    Loading: 
    Loading: 0 packages loaded
    Analyzing: target //src:devserver (1 packages loaded, 0 targets configured)
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/io_bazel_rules_sass/sass/BUILD:11:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps and referenced by '@io_bazel_rules_sass//sass:sass_bin'
    ERROR: Analysis of target '//src:devserver' failed; build aborted: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found in directory 'node_modules/sass' of external repository @build_bazel_rules_sass_deps
    INFO: Elapsed time: 0.763s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (19 packages loaded, 41 targets configured)
    ERROR: Build failed. Not running target
    FAILED: Build did NOT complete successfully (19 packages loaded, 41 targets configured)
    Error starting process: fork/exec /var/folders/vl/wp3bydl53fvcy8gh1dvnfqxh0000gn/T/bazel_script_path469790526: permission denied
    Run start failed fork/exec /var/folders/vl/wp3bydl53fvcy8gh1dvnfqxh0000gn/T/bazel_script_path469790526: permission denied
    Triggering live reload
    requesting reload: reload
    

    I deleted my project and generated new app. I always get this error when I try to ng build

    Starting local Bazel server and connecting to it...
    ERROR: /private/var/tmp/_bazel_perjerz/e94172a9a26676c96635c93e5554594c/external/io_bazel_rules_sass/sass/BUILD:11:1: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found on package path and referenced by '@io_bazel_rules_sass//sass:sass_bin'
    ERROR: Analysis of target '//src:prodapp' failed; build aborted: no such package '@build_bazel_rules_sass_deps//node_modules/sass': BUILD file not found on package path
    INFO: Elapsed time: 4.445s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (189 packages loaded, 1663 targets\
     configured)
        Fetching @local_config_cc; fetching
    

    Therefore, my guess is about build bazel rules are invalid after first build. I deleted all files in folder /private/var/tmp/_bazel_perjerz/, and run ng build again. It works fine again.

    Extracting Bazel installation...
    Starting local Bazel server and connecting to it...
    INFO: SHA256 (https://github.com/manekinekko/rules_sass/archive/9862dfc96a4a1f66fe171ef5e043b29853e8445b.zip) = 6035f25dbcd1e5575a681f5d7b9d9821dde09fcf73ccea053d1bc1c9523b1a2a
    DEBUG: Rule 'io_bazel_rules_sass' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "6035f25dbcd1e5575a681f5d7b9d9821dde09fcf73ccea053d1bc1c9523b1a2a"
    INFO: Analyzed target //src:prodapp (528 packages loaded, 19286 targets configured).
    INFO: Found 1 target...
    Target //src:prodapp up-to-date:
      dist/bin/src/prodapp
    INFO: Elapsed time: 195.176s, Critical Path: 33.13s
    INFO: 7 processes: 6 local, 1 worker.
    INFO: Build completed successfully, 8102 total actions
    

    The second build takes ~9 seconds.

    INFO: Analyzed target //src:prodapp (528 packages loaded, 19286 targets configured).
    INFO: Found 1 target...
    Target //src:prodapp up-to-date:
      dist/bin/src/prodapp
    INFO: Elapsed time: 8.895s, Critical Path: 0.09s
    INFO: 0 processes.
    INFO: Build completed successfully, 1 total action
    

    My problem is now about run ng serve which invoking ibazel to be run, and it totally break the bazel rules to be not found.

  3. forssri commented on Jun 23, 2019

    @forssri

    I am facing similar issues, creating a new project using 8.0.3 angular and latest @angular/bazel and latest @bazel/bazel fails for both ng serve and ng build. This doesn't seem to be a failure related to LESS, tried with choosing either CSS/SASS while creating a new project as well

    Analyzing: target //src:devserver (1 packages loaded, 0 targets configured) ERROR: /private/var/tmp/_bazel_sriram/67919b6f64079d0c1fa653a6ec12dcff/external/bazel_tools/tools/bash/runfiles/BUILD:1:1: in @build_bazel_rules_nodejs//internal/common:sources_aspect.bzl%sources_aspect aspect on sh_library rule @bazel_tools//tools/bash/runfiles:runfiles: Traceback (most recent call last): File "/private/var/tmp/_bazel_sriram/67919b6f64079d0c1fa653a6ec12dcff/external/bazel_tools/tools/bash/runfiles/BUILD", line 1 @build_bazel_rules_nodejs//internal/common:sources_aspect.bzl%sources_aspect(...) File "/private/var/tmp/_bazel_sriram/67919b6f64079d0c1fa653a6ec12dcff/external/build_bazel_rules_nodejs/internal/common/sources_aspect.bzl", line 40, in _sources_aspect_impl depset([f for f in target.files if f.pa...")], ...]) File "/private/var/tmp/_bazel_sriram/67919b6f64079d0c1fa653a6ec12dcff/external/build_bazel_rules_nodejs/internal/common/sources_aspect.bzl", line 41, in depset [f for f in target.files if f.path.endswith(".js")] type 'depset' is not iterable. Use the to_list()method to get a list. Use --incompatible_depset_is_not_iterable=false to temporarily disable this check.

  4. added
    area: bazelIssues related to the published `@angular/bazel` build rules
    on Jun 24, 2019
  5. added this to the needsTriage milestone on Jun 24, 2019
  6. alan-agius4 commented on Jun 24, 2019

    @alan-agius4
    Contributor

    Hi, at the moment bazel only supports CSS and SASS.

    With regards to the users experiencing other errors, I suggest that a new issue is opening. Since the errors that you are experiencing are not related to the original issue.

    Thanks.

  7. gurezo commented on Jun 24, 2019

    @gurezo
  8. henning96 commented on Jun 24, 2019

    @henning96
    Author

    Hi @alan-agius4,
    I see. Is support for Less planned for the Angular 9 release? Or do we have to create our own Bazel rule for this?

  9. alan-agius4 commented on Jun 24, 2019

    @alan-agius4
    Contributor

    @henning96, probably we will have a first party rule for Less, but there is no timeframe yet.

  10. alan-agius4 commented on Jun 24, 2019

    @alan-agius4
    Contributor

    @gurezo, please file a new issue, your error is unrelated to Less.

  11. gurezo commented on Jun 24, 2019

    @gurezo

    @alan-agius4 Okay!
    i'll making to new issue

  12. added a commit that references this issue on Jun 24, 2019
    980bcaf
  13. manish-jain-1 commented on Jul 9, 2019

    @manish-jain-1

    Error getting Bazel info exit status 2
    error setting higher file descriptor limit for this process: invalid argumentQuerying for files to watch...
    INFO: Options provided by the client:
    Inherited 'common' options: --isatty=0 --terminal_columns=80
    INFO: Reading rc options for 'query' from /Users/user/ng8-bazel/bazeltest/.bazelrc:
    Inherited 'common' options: --experimental_allow_incremental_repository_updates
    ERROR: Unrecognized option: --experimental_allow_incremental_repository_updates
    Bazel query failed: exit status 2
    INFO: Options provided by the client:
    Inherited 'common' options: --isatty=0 --terminal_columns=80
    INFO: Reading rc options for 'query' from /Users/user/ng8-bazel/bazeltest/.bazelrc:
    Inherited 'common' options: --experimental_allow_incremental_repository_updates
    ERROR: Unrecognized option: --experimental_allow_incremental_repository_updates
    Bazel query failed: exit status 2
    Runing //src:devserver
    INFO: Options provided by the client:
    Inherited 'common' options: --isatty=0 --terminal_columns=80
    INFO: Reading rc options for 'query' from /Users/user/ng8-bazel/bazeltest/.bazelrc:
    Inherited 'common' options: --experimental_allow_incremental_repository_updates
    ERROR: Unrecognized option: --experimental_allow_incremental_repository_updates
    Error running Bazel exit status 2
    /Users/user/ng8-bazel/bazeltest/node_modules/@bazel/ibazel/bin/darwin_amd64/ibazel failed with code 4.

  14. angular-automatic-lock-bot commented on Sep 15, 2019

    @angular-automatic-lock-bot

    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.

  15. locked and limited conversation to collaborators on Sep 15, 2019
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

    area: bazelIssues related to the published `@angular/bazel` build rules

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions