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

Support custom headers in rb_bundle_fetch to support private ruby repositories and mirrors with bundler #174

Open
noahkawasakigoogle opened this issue Nov 25, 2024 · 3 comments

Comments

@noahkawasakigoogle
Copy link

noahkawasakigoogle commented Nov 25, 2024

So far, it looks like rb_bundle_fetch does not support installing gems from private repositories with authentication. I believe this is from the implementation using repository_ctx.download. I believe this could be accomplished by exposing the headers argument here in the rb_bundle_fetch arguments: https://bazel.build/rules/lib/builtins/repository_ctx#download

Example - bundle fetch hits 401 unauthorized here due to no way to pass credentials to request:

rb_bundle_fetch(
    name = "bundle",
    gemfile = "//:Gemfile",
    gemfile_lock = "//:Gemfile.lock",
    env = {
        "BUNDLE_MY_REPO__COM": "username:password",
    }
)

rb_bundle can do this successfully, because these bundler environment variables can pass through:

rb_bundle(
    name = "bundle",
    gemfile = "//:Gemfile",
    env = {
        "BUNDLE_MY_REPO__COM": "username:password",
    }
)

However rb_bundle is to be deprecated and docs recommend using rb_bundle_fetch instead. There are also numerous advantages pointed out in rb_bundle_fetch described here: #48

Or perhaps there is a way to use rb_bundle_fetch with private repos?

@noahkawasakigoogle
Copy link
Author

Possibly a dupe of this: #62

@p0deje
Copy link
Member

p0deje commented Nov 25, 2024

It's not obvious, but you should be able to provide credentials using Bazel --credential-helper flag. The credentials exposed by it should be propagated to repository_ctx.download per bazelbuild/bazel#13709 (comment).

@p0deje
Copy link
Member

p0deje commented Nov 25, 2024

#62 is about installing gems from Git repositories, whether they are private or not. However, installing from private Bundler mirrors should also work.

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