Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Setting credentials for gem sources via environment variable does not work if domain name contains dash #4241

Closed
fschwahn opened this issue Jan 26, 2016 · 7 comments

Comments

@fschwahn
Copy link

Hi,
I have a gem host at gems.with-dash.com, and I cannot set the credentials using an environment variable (as explained here) because dashes are not allowed in environment variable names (it would have to be BUNDLE_GEMS__WITH-DASH__COM, which is invalid at least in bash).

Am I missing something here? I'd be willing to put together a pull request that converts the dash to an underscore in this case. Would this be worthwhile?

@segiddins
Copy link
Member

I can set an env var with a dash fine using Ruby, maybe you just need to escape the dash?

@segiddins
Copy link
Member

env 'foo-bar=bar' env => foo-bar=bar

@segiddins
Copy link
Member

You can also always use bundle config to set the configuration

@fschwahn
Copy link
Author

Thanks for your quick reply, and for the solutions!

I'd like to set the environment variable using export, and I don't see any way to achieve that when the variable name includes a dash. It just seemed like an oversight to me.

You can close this if it is out of scope, as there are alternative ways I can work around this problem. Thanks again!

@segiddins
Copy link
Member

Yeah, sorry, does kinda feel out of scope to me :/

@fschwahn
Copy link
Author

Sure, no worries. If it hasn't come up until now, it's most probably an edge case.

@fschwahn
Copy link
Author

Hi, sorry to bother again, I will quickly outline my use case, maybe you re-evaluate your stance:

I'm using Gitlab CI for our internal gems. Gitlab CI has a feature which allows you to specify so-called secret environment variables, which are injected in the CI run. We have several internal gems that reference each other, and using any method other than the environment variable approach would force me to include the credentials of our internal gem host in the repository, which I'd like to avoid.

I have raised this issue with Gitlab, but they are unwilling / not able to allow environment variables with dashes, as these are invalid in bash (and they use bash to set these environment variables).

Thanks again for your attention!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants