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

Recursive WORKSPACE file loading #1943

Closed
kchodorow opened this issue Oct 13, 2016 · 19 comments
Closed

Recursive WORKSPACE file loading #1943

kchodorow opened this issue Oct 13, 2016 · 19 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@kchodorow
Copy link
Contributor

Design doc: https://bazel-review.googlesource.com/c/6131

@kchodorow kchodorow added type: feature request P2 We'll consider working on this in future. (Assignee optional) category: extensibility > external repositories labels Oct 13, 2016
@kchodorow kchodorow self-assigned this Oct 13, 2016
bazel-io pushed a commit that referenced this issue Oct 14, 2016
#1943

--
Change-Id: Ic7b4378acb4d3661a1b61ff887c9cc8592df9f7e
Reviewed-on: https://bazel-review.googlesource.com/c/6131/
MOS_MIGRATED_REVID=136154990
@jart
Copy link
Contributor

jart commented Oct 19, 2016

Drive by review. I love watching the amazing work you do @kchodorow. This seems like a potential solution for #1550.

You're tackling a very difficult problem. Many people have tried to solve this problem and only introduced new ones. One of Bazel's virtues is that it's held off on trying to solve this so far until it can come up with a solution it knows is going to be awesome. I'd like to help you find that solution.

[Diamonds]

The PNG files seems to be broken in https://github.com/bazelbuild/bazel/blob/master/site/designs/_posts/2016-09-19-recursive-ws-parsing.md so it's not clear to me yet how this is going to work.

We always download/link every external dependency before a build can happen.

I want to only pay for the dependencies I use. If I depend on @foo//bar/some/tiny:library, then I don't want to have to download the externals required to build @foo//.... That could include testing dependencies like web browsers, documentation generators, and all this other stuff that could be gigabytes in size, when all I actually wanted was maybe a tiny jar file.

A lot of people have opinions on this topic, as you know. I'm sure you hear user complaints all the time about why Bazel can't solve all their problems without them having to do additional work. Allow me to counteract some of those opinions by saying this. I don't care if Bazel is convenient. I don't care if it's easy. I just care that it's performant, minimal, deterministic, reproducible, and correct (PMDRC). Even if that means I'm configuring my build on the hardest difficulty setting. I like difficult things, as long as I'm reaping significant benefits from that difficulty. This level of high precision professionalism is what sets Bazel apart from many other build systems, which play fast and loose with dependencies. I also believe that once we figure out how to make our builds PMDRC, then we can add abstractions later that make PMDRC easy.

@kchodorow kchodorow added this to the 0.6 milestone Dec 9, 2016
@kchodorow
Copy link
Contributor Author

Sorry, missed this comment! Thanks for the props, commit in progress to fix the images.

Many people have tried to solve this problem and only introduced new ones.

I've read the internal doc on it :)

I'm not really trying to solve the problem, fwiw. The tl;dr of that design doc is:

  1. Use unambiguous transitive external dependencies.
  2. Error out fast if there's an ambiguity.
  3. Allow overriding dependency conflicts in the top-level WS file.

There's also some cool strictness stuff we'll be doing, like only allowing external dependencies that have been declared in that WS (so @x can't use @y unless it's declared in x's WS file).

We always download/link every external dependency before a build can happen.

We're not doing that!

They'll be downloaded as-needed, as it is today.

bazel-io pushed a commit that referenced this issue Jan 30, 2017
Somehow they were all uploaded as 0 bytes, but that's okay because the URLs
in the design doc were wrong, anyway.

Relavant design doc: https://bazel.build/designs/2016/09/19/recursive-ws-parsing.html, issue #1943.

--
PiperOrigin-RevId: 145799866
MOS_MIGRATED_REVID=145799866
bazel-io pushed a commit that referenced this issue Apr 26, 2017
…ir WORKSPACE file

This is prep for #1943 - hierarchical workspace loading.

RELNOTES[INC]: Remote repositories must define any remote repositories they
themselves use (e.g., if @x//:foo depends on @y//:bar, @y must be defined
in @x's WORKSPACE file).

PiperOrigin-RevId: 154295762
bazel-io pushed a commit that referenced this issue Apr 26, 2017
*** Reason for rollback ***

The go rules have tons of transitive dependencies that are not declared in their "local" WORKSPACE files, so this broke lots of projects on ci.bazel.build

I'll fix up the go rules, update all of _their_ reverse-dep projects, and resubmit.

*** Original change description ***

Repositories can only be accessed in projects that define them in their WORKSPACE file

This is prep for #1943 - hierarchical workspace loading.

RELNOTES[INC]: Remote repositories must define any remote repositories they
themselves use (e.g., if @x//:foo depends on @y//:bar, @y must be defined
in @x's WORKSPACE file).

PiperOrigin-RevId: 154321845
kchodorow added a commit to kchodorow/rules_go that referenced this issue Apr 27, 2017
Bazel is moving to a model where child repository WORKSPACE files will be
parsed (see bazelbuild/bazel#1943). This means
that top-level WORKSPACE files won't have to declare every dependency
(yay!) but, as a part of this, child repositories will have to start
declaring the repositories they use.

This should be a no-op, though, since the top-level WORKSPACE file
overrides all of these repository definitions.  So it doesn't really
matter what they are (hence the dummy paths).
@ittaiz
Copy link
Member

ittaiz commented Jun 11, 2017

@kchodorow is this still being targeted for 0.6?

@kchodorow
Copy link
Contributor Author

It depends when 0.6 is getting cut, I'd like it to be!

@jgavris
Copy link
Contributor

jgavris commented Jul 11, 2017

Also eagerly awaiting this, as we have bazel as a submodule of our monorepo and would like to put the WORKSPACE at the root.

@ittaiz
Copy link
Member

ittaiz commented Jul 16, 2017

Will this enable me to have a nested WORKSPACE which has (for example) a java_binary and then in the "main" WORKSPACE a repository rule which depends on the deploy jar of the java_binary?
IIUC currently that isn't possible Note that remote repositories are executed during the analysis phase and thus cannot depends on a target result (the label should point to a non-generated file).

If the answer is yes then any rough estimates on when this will land in HEAD?

@aehlig
Copy link
Contributor

aehlig commented Aug 19, 2019

@aehlig Friendly ping. This seems like a critical feature for any project of moderate size. Are there plans to get this into the 1.0 release?

@gnossen No. When @dslomov decided on the priorities for Bazel 1.0, recursive workspaces were not in scope. So, unfortunately, nobody will be working on recursive workspaces before Bazel 1.0 is out.

@gnossen
Copy link

gnossen commented Aug 21, 2019

Understood. I'd just like to raise awareness that this gap is causing a fair bit of pain. Related: census-instrumentation/opencensus-cpp#378

@immars
Copy link

immars commented Nov 26, 2019

Hi,

is there any update for this feature? I came across this issue and #1550 . Seems it's really hard to make WORKSPACE modularized without this one.

Since 1.2.0 is out now, could you please consider putting this feature somewhere in the roadmap? thanks.

@aehlig aehlig assigned dslomov and unassigned aehlig Nov 26, 2019
@UebelAndre
Copy link
Contributor

Friendly ping, this is a highly anticipated feature for my group. Can we get an update on it's status?

@smolkaj
Copy link

smolkaj commented May 6, 2020

Friendly ping, this is a big problem for open sourcing Google projects.
Is there a known workaround at least?

@EricCousineau-TRI
Copy link
Contributor

EricCousineau-TRI commented May 6, 2020

@smolkaj In our project, we try to ensure that our repository rules and toolchains can ultimately be grouped into one macro, and is crafted such that you only need one WORKSPACE-level load() statements in a downstream project (e.g. no inter-dependencies for repository rule load() statements).

The example macro:
https://github.com/RobotLocomotion/drake/blob/2c485822aecda3b2400ce5db4262c28a37caeeeb/tools/workspace/default.bzl#L286-L306

Example usage in downstream Bazel project:
https://github.com/RobotLocomotion/drake-external-examples/blob/d5067ad0395cc20c917866ad6ee3d63b0df90fb0/drake_bazel_external/WORKSPACE#L84-L85

Disclaimer: Not the author of the implementation ;)

Meta: I tried searching the doc for something that talks about the load() statement inter-dependency stuff. Didn't find anything easy. As of 3.1.0, looked at:

Multiple loads here, but does not appear to have inter-dependencies?
#1550 (comment)

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
damienmg pushed a commit to bazelbuild/rules_rust that referenced this issue Sep 9, 2020
This pull request contains various cleanup/quality-of-life improvements for the repository by clearly grouping and defining dependencies for the docs and examples workspaces. Ultimately, the files that are created in here can be moved entirely into their neighboring WORKSPACE files once bazelbuild/bazel#1943 has been closed.
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@meteorcloudy
Copy link
Member

We are developing a new external dependency system for Bazel (codename Bzlmod), which will tackle the fundamental problem this issue tries to solve. Please read more at https://bazel.build/docs/bzlmod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests