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

git_repository ignoring repo's WORKSPACE #3195

Closed
cpenner-va opened this issue Jun 14, 2017 · 2 comments
Closed

git_repository ignoring repo's WORKSPACE #3195

cpenner-va opened this issue Jun 14, 2017 · 2 comments

Comments

@cpenner-va
Copy link

Description of the problem / feature request / question:

Bazel doesn't seem to be respecting WORKSPACE for packages inside repos when using the git_repository rule.

I'm adding a target to our system to run generate_workspace to simplify the process of generating a workspace for my teammates; to do so I'm including the new generate_workspace from https://github.com/bazelbuild/migration-tooling like so:

# WORKSPACE
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
    name = "io_bazel_migration_tooling",
    remote = "https://github.com/bazelbuild/migration-tooling",
    commit = "be4bd8a8a953543a0e4fd2f5f0aa62d7bcca0830",
)

However, when I try to build the target using

bazel build @io_bazel_migration_tooling//generate_workspace

I get the following error:

ERROR: /private/var/tmp/_bazel_cpenner/9b118102cdffeca44d4b37a64afaa853/external/io_bazel_migration_tooling/generate_workspace/src/main/java/com/google/devtools/build/workspace/BUILD:1:1: no such package '@guava//jar': error loading package 'external': The repository named 'guava' could not be resolved and referenced by '@io_bazel_migration_tooling//generate_workspace/src/main/java/com/google/devtools/build/workspace:workspace'.
ERROR: Analysis of target '@io_bazel_migration_tooling//generate_workspace:generate_workspace' failed; build aborted.
INFO: Elapsed time: 3.019s

It seems that the WORKSPACE of the migration-tools repo is being ignored for some reason which is causing this to fail.

If possible, provide a minimal example to reproduce the problem:

Create new package with the following workspace:

#WORKSPACE
load("@bazel_tools//tools/build_defs/repo:git.bzl","new_git_repository", "git_repository")
git_repository(
    name = "io_bazel_migration_tooling",
    remote = "https://github.com/bazelbuild/migration-tooling",
    commit = "be4bd8a8a953543a0e4fd2f5f0aa62d7bcca0830",
)

Then run bazel build @io_bazel_migration_tooling//generate_workspace.

Environment info

  • Operating System:
    Mac OS Sierra
    10.12.4 (16E195)

  • Bazel version (output of bazel info release):
    release 0.4.5

@kchodorow
Copy link
Contributor

Unfortunately, this is "WAI" until #1943 is resolved. Bazel only parses the WORKSPACE file of you "main" repository, not the child WORKSPACE files.

You can add an @guava target to your project's WORKSPACE file, if you want to build generate_workspace.

@cpenner-va
Copy link
Author

Thanks, That's the solution I went with for now.

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

No branches or pull requests

2 participants