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

使用RubyGems API发布Gem时遇tar损坏错误求助

RubyGems API上传Gem时提示"tar is corrupt, name contains null byte",但gem push可成功,求C#代码解决方案

我最近尝试通过RubyGems官方API向rubygems.org发布自己的Ruby Gem,遇到了一个奇怪的问题:

  • 用C#代码调用API上传已构建好的gem文件时,收到报错
  • 用Postman测试同样的上传操作,也得到相同错误
  • 但使用命令行执行gem push filename.gem发布同一个gem文件却完全正常

具体报错信息如下:

RubyGems.org cannot process this gem. Please try rebuilding it and installing it locally to make sure it's valid. Error: tar is corrupt, name contains null byte

我的C#代码如下:

var client = new WebClient();
client.Headers.Add(HttpRequestHeader.Authorization, "--authorization key--");
byte[] rawResponse = client.UploadFile("https://rubygems.org/api/v1/gems", Path.Combine(PATH, "tester-1.1.0.gem"));

有没有使用过RubyGems API发布Gem的开发者能帮我排查问题?如果我的代码存在问题,希望能提供可用的API调用代码示例。非常感谢!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:51:16