You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加含邮箱格式用户名的JFrog RubyGems私有源时遭遇URI::InvalidURIError错误的解决方案求助

Fixing URI::InvalidURIError When Adding JFrog RubyGems Source

The root cause of your error is that your username is an email address containing the @ character, which confuses the URI parser. The URL structure https://user:pass@host expects @ to separate credentials from the hostname—but when your username itself has an @, the parser can't correctly identify where the credential section ends.

Here are two reliable fixes to resolve this:

1. URL-Encode Special Characters in Credentials

Replace the @ in your email username with its URL-encoded equivalent %40. This lets the parser correctly interpret the credentials string:

Command Line Method

Run this corrected gem source command:

gem source -a https://stephan%40company.com:PaSsWoRd@company.jfrog.io/artifactory/api/gems/my-gems/

.gemrc File Method

Update your ~/.gemrc with the encoded username:

---
:backtrace: false
:bulk_threshold: 1000
:sources:
- https://stephan%40company.com:PaSsWoRd@company.jfrog.io/artifactory/api/gems/my-gems/
- https://rubygems.org/
:update_sources: true
:verbose: true
:concurrent_downloads: 8

(Note: I removed the duplicate http://rubygems.org entry since you already have the more secure HTTPS version.)

If your password contains special characters like !, $, or &, you’ll need to URL-encode those too (e.g., ! becomes %21, $ becomes %24).

For better security and to avoid URL encoding headaches entirely, configure your credentials separately in ~/.gemrc instead of embedding them in the source URL:

---
:backtrace: false
:bulk_threshold: 1000
:sources:
- https://company.jfrog.io/artifactory/api/gems/my-gems/
- https://rubygems.org/
:update_sources: true
:verbose: true
:concurrent_downloads: 8
:credentials:
  company.jfrog.io:
    username: stephan@company.com
    password: PaSsWoRd

This keeps your credentials out of plaintext source listings and eliminates URI parsing issues altogether.

Either approach should resolve the URI::InvalidURIError and let you use your authenticated JFrog RubyGems repository.

内容的提问来源于stack exchange,提问作者sarkstephan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 10:59:06