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

bazel sync fails during yarn_install #1086

Closed
ian-h-chamberlain opened this issue Sep 3, 2019 · 2 comments Β· Fixed by #1100
Closed

bazel sync fails during yarn_install #1086

ian-h-chamberlain opened this issue Sep 3, 2019 · 2 comments Β· Fixed by #1100

Comments

@ian-h-chamberlain
Copy link

ian-h-chamberlain commented Sep 3, 2019

🐞 Bug report

Affected Rule

Failure occurs in ts_setup_workspace() from rules_typescript

Is this a regression?

I don't think so – I can't find any other Github issues describing this problem, but I'm not sure whether the sync operation was ever supported/tested.

Description

bazel sync fails to complete yarn_install for build_bazel_rules_typescript_tsc_wrapped_deps repository. It appears that the failing yarn_install rules were removed from rules_typescript as part of bazelbuild/rules_typescript#429, but still remain in this repo's version of ts_repositories.bzl – perhaps the checked-in version simply needs to be updated to upstream rules_typescript? I'm not quite clear on the relationship between the packages/typescript directory and the rules_typescript repository.

πŸ”¬ Minimal Reproduction

I have created a minimal reproduction with a simple nodejs_binary typescript target here:

https://github.com/ian-h-chamberlain/bad-yarn-install

Simply clone and run bazel sync to see the error.
Note that fetch/build/run etc. work without a problem... only bazel sync is affected.

πŸ”₯ Exception or Error


INFO: Call stack for the definition of repository 'build_bazel_rules_typescript_tsc_wrapped_deps' which is a yarn_install (rule definition at /private/var/tmp/_bazel_ichamberlain/6f039f055d4e51b6e0afb14d1a8ec43c/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:406:16):
 - /private/var/tmp/_bazel_ichamberlain/6f039f055d4e51b6e0afb14d1a8ec43c/external/build_bazel_rules_nodejs/defs.bzl:82:5
 - /private/var/tmp/_bazel_ichamberlain/6f039f055d4e51b6e0afb14d1a8ec43c/external/npm_bazel_typescript/internal/ts_repositories.bzl:35:5
 - /Users/ichamberlain/Documents/thirdparty/bad-yarn-install/WORKSPACE:61:1
ERROR: An error occurred during the fetch of repository 'build_bazel_rules_typescript_tsc_wrapped_deps':
   Not a regular file: /private/var/tmp/_bazel_ichamberlain/6f039f055d4e51b6e0afb14d1a8ec43c/external/npm_bazel_typescript/internal/tsc_wrapped/yarn.lock
ERROR: Not a regular file: /private/var/tmp/_bazel_ichamberlain/6f039f055d4e51b6e0afb14d1a8ec43c/external/npm_bazel_typescript/internal/tsc_wrapped/yarn.lock
Loading: loading...

🌍 Your Environment

Operating System:

  
macOS Mojave 10.14.6
  

Output of bazel version:

  
$ bazel version 
Build label: 0.28.1
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jul 19 15:22:50 2019 (1563549770)
Build timestamp: 1563549770
Build timestamp as int: 1563549770
  

Rules version (SHA):

  
git_repository(
    name = "build_bazel_rules_nodejs",
    commit = "e04c8c31f3cb859754ea5c5e97f331a3932b725d",
    remote = "https://github.com/bazelbuild/rules_nodejs.git",
    shallow_since = "1567186025 -0700",
)
  

Let me know if any additional information is required – this is blocking my organization's use of rules_nodejs as we utilize bazel sync to create a kind of lockfile for transitive dependencies coming from our WORKSPACE file.

@ian-h-chamberlain
Copy link
Author

ian-h-chamberlain commented Sep 3, 2019

In case anyone else needs a workaround, I seem to be able to get around this using patch-package as a postinstall hook with the following patch:

diff --git a/node_modules/@bazel/typescript/internal/ts_repositories.bzl b/node_modules/@bazel/typescript/internal/ts_repositories.bzl
index 0f0feb6..06c7998 100755
--- a/node_modules/@bazel/typescript/internal/ts_repositories.bzl
+++ b/node_modules/@bazel/typescript/internal/ts_repositories.bzl
@@ -29,19 +29,6 @@ def ts_setup_workspace():
     # 0.16.8: ng_package fix for packaging binary files
     check_rules_nodejs_version("0.16.8")

-    # Included here for backward compatability for downstream repositories
-    # that use @build_bazel_rules_typescript_tsc_wrapped_deps such as rxjs.
-    # @build_bazel_rules_typescript_tsc_wrapped_deps is not used locally.
-    yarn_install(
-        name = "build_bazel_rules_typescript_tsc_wrapped_deps",
-        package_json = "@npm_bazel_typescript//internal:tsc_wrapped/package.json",
-        yarn_lock = "@npm_bazel_typescript//internal:tsc_wrapped/yarn.lock",
-        # Do not symlink node_modules as when used in downstream repos we should not create
-        # node_modules folders in the @npm_bazel_typescript external repository. This is
-        # not supported by managed_directories.
-        symlink_node_modules = False,
-    )
-
     yarn_install(
         name = "build_bazel_rules_typescript_devserver_deps",
         package_json = "@npm_bazel_typescript//internal/devserver:package.json",

Edit: only one yarn_install needs to be removed, not all of them.

alexeagle added a commit that referenced this issue Sep 5, 2019
This was introduced a year ago in https://github.com/bazelbuild/rules_typescript/pull/276/files to help avoid a breaking change to rxjs. They no longer need it, and very unlikely anyone else ever used it.

BREAKING CHANGE:

A compatibility layer was removed. See discussion in #1086

Fixes #1086
@alexeagle
Copy link
Collaborator

Thanks so much for doing the hard work of tracking down the problem, that's easy to remove since it's a year-old compatibility shim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants