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

//kotlin:dependencies.bzl does not load all required dependencies #1230

Closed
shs96c opened this issue Oct 22, 2024 · 2 comments · Fixed by #1231
Closed

//kotlin:dependencies.bzl does not load all required dependencies #1230

shs96c opened this issue Oct 22, 2024 · 2 comments · Fixed by #1231

Comments

@shs96c
Copy link
Contributor

shs96c commented Oct 22, 2024

Apply the following patch to rules_kotlin in order to make the production deps be loaded before the dev ones. This should be a safe operation since the production deps contain everything that rules_kotlin needs at runtime:

diff --git a/WORKSPACE.dev.bazel b/WORKSPACE.dev.bazel
index c282275..d184a6e 100644
--- a/WORKSPACE.dev.bazel
+++ b/WORKSPACE.dev.bazel
@@ -13,14 +13,14 @@
 # limitations under the License.
 workspace(name = "rules_kotlin")
 
-load("//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
-
-kt_download_local_dev_dependencies()
-
 load("//kotlin:repositories.bzl", "kotlin_repositories")
 
 kotlin_repositories()
 
+load("//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")
+
+kt_download_local_dev_dependencies()
+
 register_toolchains("@rules_kotlin//kotlin/internal:default_toolchain")
 
 android_sdk_repository(name = "androidsdk")

Now run bazel sync --noenable_bzlmod and the following error is reported:

ERROR: ErrorInfo{exception=null, cycles=[[] -> [[/Volumes/Dev/src/github.com/bazelbuild/rules_kotlin]/[WORKSPACE], 2, KeyForWorkspace{label=//kotlin:repositories.bzl, isBuildPrelude=false}, KeyForWorkspace{label=//src/main/starlark/core/repositories:initialize.bzl, isBuildPrelude=false}, KeyForWorkspace{label=//src/main/starlark/core/repositories:setup.bzl, isBuildPrelude=false}, KeyForWorkspace{label=@@rules_proto//proto:repositories.bzl, isBuildPrelude=false}, CONTAINING_PACKAGE_LOOKUP:@@rules_proto//proto, PACKAGE_LOOKUP:@@rules_proto//proto, REPOSITORY_DIRECTORY:@@rules_proto]], isCatastrophic=false, isDirectlyTransient=false, isTransitivelyTransient=false}

From this, it's clear that there is a chain of load statements from repositories.bzl to setup.bzl (and from there to @rules_proto).

@shs96c
Copy link
Contributor Author

shs96c commented Oct 22, 2024

The way that I've "solved" this before is manually "unwind" the dependencies of my ruleset's transitive deps in the dependencies.bzl file so that setup.bzl can call the various setup functions that those rulesets provide. It's most unsatisfactory.

@restingbull
Copy link
Collaborator

rules_proto. How I love thee.

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