-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Consider a WORKSPACE alias
rule
#3219
Comments
How about bind()? |
|
I still disagree with your premise. A repository should be ~a project. Also, if you're aliasing these, all of these repositories need to have the exact same targets, which is awkward. IIUC, the concern is that @com_google_protobuf_java has one implementation and @com_google_protobuf_javalite has another and some projects will want to use them interchangably? That seems like it can be handled at several other levels. |
They need to be used together in the same code base (e.g., Java code that's reused between server and Android). |
That sounds like it should be handled at the configuration layer. |
Without aliases, what is the the best practice for renaming a workspace? I would expect aliases to be the main tool for this, and I don't see how renaming would work without them. Suppose I have a project that uses |
I have the same question really. This stops me from making a transition when renaming WORKSPACE rule names in dependency (or consumer) projects. Would be great leave some aliases to cover a certain transition period. Bumped into this when trying to build a JGit development tree in Gerrit. One of the two decided it was a good idea to rename all the rules to a new format. (mailing list discussion) |
This is implemented with repository remapping |
@dslomov How is that solved with repository remapping? The link provided only shows an example with |
Also there is still missing documentation of this new field here: https://docs.bazel.build/versions/master/be/workspace.html#local_repository |
Repository remapping does remap labels in the BUILD files, but won't do anything to labels in .bzl files. This makes the feature useless when project have their own macros in .bzl files. As a reference, I've tried to make TensorFlow use |
It should also remap labels in .bzl files as well - do you have a repro where it does not work?
|
Every repository rule has a If a repository you depend on wants to refer to workspace(name = "myproject")
http_archive(
name = "xyz", ....,
repo_mapping = { "@some_repo" : "@myproject" }
) |
I have remapped |
@dslomov What I mean is, I want to be able to alias the external repository itself in my current workspace. So In the example you gave, I suppose I would want something like: workspace(
name = "myproject",
repo_mapping = { "@xyz": "@abc" },
)
http_archive(
name = "xyz", ....,
repo_mapping = { "@some_repo" : "@myproject" }
) or as the issue creator suggested: workspace(name = "myproject")
http_archive(
name = "xyz", ....,
repo_mapping = { "@some_repo" : "@myproject" }
)
alias(
name = "abc",
actual = "xyz",
) As far as I can see from the documentation that is currently not possible, or am I wrong here? My concrete use-case is we use yarn_install with an internal workspace name, but the name Hope that clarifies the problem. |
Hmm, why don't you just call the |
Ah I see, sorry... What forces you to use |
Also I have started to write a plugin for gazelle to auto generate Renaming things permanently is a bigger task due to internal reasons, even if it is possible in an automated manner. So being able to alias the name in our current workspace would be preferable. It also would make it simpler to change workspace names of some of our own private external dependencies with a transition period. |
@dslomov any more thoughts on this? |
@dslomov Another use-case that just came up when implementing toolchaings for rules_nodejs is that per default we provide a nodejs repository for each supported platform with the name |
I suggest this bug be reopened, as the use-case identified by @Globegitter, which I share the need for, remains unsolved. |
If the usage is in your own project, why can't you just rename the references with a simple search and replace? It is more maintainable and less confusing than aliases. |
mature projects (ie the family of protobuf projects) have over time changed the names of expected repos, as well as their strategies for fetching dependencies. Working with older versions of protobuf is a nightmare. I believe the request for aliasing repo's is valid. |
https://github.com/bazelbuild/rules_python
https://github.com/bazelbuild/rules_python/blob/master/python/pip.bzl
MD TNND Life is so hard |
This looks like an important and relevant feature - why is this issue still closed? |
Followup: I agree with @dslomov's point that aliasing repos are not necessary within the main workspace, as you should in theory have full control over that code and be able to find and replace to a name of your choice. Repo mapping fits the rest of the use cases - allowing a translation between the main workspace and the external workspaces names. However, I'm having the exact same issue as @nicolov. In my case I refer to the flatbuffers repo as |
Although Bazel gives you the option of naming your http_archive repositories whatever you want, it apparently would really prefer if everyone chose the same name everywhere. This becomes apparent where fuzztest really wants the top level `WORKSPACE` to call absl `com_google_absl`, and will not allow me to use the shorter name `absl`. This is especially annoying because both `WORKSPACE`s describe `absl` using the same URL and sha256 hash, so you'd hope it would identify them as the same dependency? Discussions online do not give me great hope in flexibility from Bazel on this point: bazelbuild/bazel#3219 In any case, for now I am duplicating the dependency in two different `http_archive`s. I will remove the shorter, more readable `absl` and `re2` in the future once I have cut over to the new dependency.
…741) Although Bazel gives you the option of naming your http_archive repositories whatever you want, it apparently would really prefer if everyone chose the same name everywhere. This becomes apparent where fuzztest really wants the top level `WORKSPACE` to call absl `com_google_absl`, and will not allow me to use the shorter name `absl`. This is especially annoying because both `WORKSPACE`s describe `absl` using the same URL and sha256 hash, so you'd hope it would identify them as the same dependency? Discussions online do not give me great hope in flexibility from Bazel on this point: bazelbuild/bazel#3219 In any case, for now I am duplicating the dependency in two different `http_archive`s. I will remove the shorter, more readable `absl` and `re2` in the future once I have cut over to the new dependency.
Something like:
WORKSPACE:
Depending on
com_google_protobuf_cc
would be equivalent tocom_google_protobuf
.The use-case is highlighted in
https://groups.google.com/forum/#!topic/bazel-discuss/859ybHQZnuI
The text was updated successfully, but these errors were encountered: