添加含邮箱格式用户名的JFrog RubyGems私有源时遭遇URI::InvalidURIError错误的解决方案求助
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).
2. Use Separate Credential Configuration (Recommended)
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

