cgrindel/rules_spm

Repo name must match product

Closed this issue · 2 comments

Consider the following:

spm_repositories(
    name = "spm",
    // ... other attrs ...
    dependencies = [
        spm_pkg(
            "https://github.com/apple/swift-protobuf.git",
            exact_version = "1.19.0",
            products = ["SwiftProtobuf"],
        ),
    ],
)

Of course that's pointing to SwiftProtobuf's Package.swift, and it uses the SwiftProtobuf product from that configuration. However, when running a build with SPM, I get:

Repository rule spm_repositories defined at:
  /private/var/tmp/_bazel_sam/df355283ea71b0f4452e4b8a830191c8/external/cgrindel_rules_spm/spm/private/spm_repositories.bzl:693:35: in <toplevel>
ERROR: An error occurred during the fetch of repository 'spm':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_sam/df355283ea71b0f4452e4b8a830191c8/external/cgrindel_rules_spm/spm/private/spm_repositories.bzl", line 691, column 30, in _spm_repositories_impl
		_configure_spm_repository(repository_ctx, pkgs, env)
	File "/private/var/tmp/_bazel_sam/df355283ea71b0f4452e4b8a830191c8/external/cgrindel_rules_spm/spm/private/spm_repositories.bzl", line 629, column 49, in _configure_spm_repository
		product = pds.get_product(pkg_descs_dict[pkg_name], product_name)
Error: key "swift-protobuf" not found in dictionary
ERROR: /Users/sam/Workspace/sample/WORKSPACE:929:17: fetching spm_repositories rule //external:spm: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_sam/df355283ea71b0f4452e4b8a830191c8/external/cgrindel_rules_spm/spm/private/spm_repositories.bzl", line 691, column 30, in _spm_repositories_impl
		_configure_spm_repository(repository_ctx, pkgs, env)
	File "/private/var/tmp/_bazel_sam/df355283ea71b0f4452e4b8a830191c8/external/cgrindel_rules_spm/spm/private/spm_repositories.bzl", line 629, column 49, in _configure_spm_repository
		product = pds.get_product(pkg_descs_dict[pkg_name], product_name)
Error: key "swift-protobuf" not found in dictionary

Notable from that:
Error: key "swift-protobuf" not found in dictionary

Forking, and then renaming the repo, to SwiftProtobuf, fixed this particular error for me

If the package name does not match the repository name, you need to specify it using the name parameter. Here is an example.

Does that work for you?

@cgrindel not sure how i missed that, thank you, yes that works great!