Replies: 8 comments 2 replies
-
|
I'm glad someone else noticed this. This is a real pain. |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
|
Just encountered this problem too. Is this going to be fixed anytime soon? Without proper support for multiple platforms for (mostly binary) gems this registry is pretty useless for me. |
Beta Was this translation helpful? Give feedback.
-
|
Oof, I just ran head-first into this issue today. Would be great to see this fixed. |
Beta Was this translation helpful? Give feedback.
-
|
Hey, this needs a big bump. This seems like a fatal flaw, and the workarounds are not pretty. |
Beta Was this translation helpful? Give feedback.
-
|
I'm not sure if this is related, but I successfully pushed the platform-specific gem. However, Bundler fails to locate it locally even after reporting that it was successfully fetched and installed. |
Beta Was this translation helpful? Give feedback.
-
|
Sharing my experience:
then, I thought maybe the issue was not having all platforms in my Gemfile.lock published
People are mentioning workarounds - what are they and is there any official documentation about native gems? |
Beta Was this translation helpful? Give feedback.
-
|
I was impacted by this as well... of course after spending much effort creating platform-specific build/publish workflows + gemspec changes. the idea was to package gems that contain binaries matching the consumer's platform -- instead of 1 large gem w/ all platform binaries. rubygems has supported this for a long time, e.g. see all the platform variants for the blake3-rb gem. how do we know if this gets on github's radar to support? here's an example workflow: name: Publish Gems
on:
release:
types:
- published
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
publish:
name: Publish ${{ matrix.target_platform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target_platform: arm64-darwin
- target_platform: arm64-linux
- target_platform: x86_64-linux
env:
RUBYGEMS_HOST: https://rubygems.pkg.github.com/briceburg
TARGET_PLATFORM: ${{ matrix.target_platform }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
- name: Prepare gem credentials
run: |
mkdir -p ~/.gem
printf -- "---\n:github: Bearer %s\n" "${GITHUB_TOKEN}" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build gem
run: |
rm -f test-gem-*.gem
gem build test-gem.gemspec
- name: Push gem to GitHub Packages
run: |
gem_file=$(ls -*.gem)
gem push "$gem_file" --key github --host "$RUBYGEMS_HOST"and example gemspec: require "rubygems"
SUPPORTED_PLATFORMS = {
"arm64-darwin" => "test-binary-darwin-arm64",
"arm64-linux" => "test-binary-linux-arm64",
"x86_64-linux" => "test-binary-linux-amd64"
}.freeze
target_platform = ENV["TARGET_PLATFORM"]&.strip
unless target_platform && SUPPORTED_PLATFORMS.key?(target_platform)
supported = SUPPORTED_PLATFORMS.keys.join(", ")
raise "TARGET_PLATFORM must be set to one of: #{supported}"
end
target_binary_path = File.join("exe", SUPPORTED_PLATFORMS.fetch(target_platform))
unless File.exist?(target_binary_path)
raise "Expected binary #{target_binary_path} for TARGET_PLATFORM=#{target_platform}"
end
Gem::Specification.new do |spec|
spec.name = "test-gem"
spec.version = "0.0.1"
spec.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/briceburg"
gemspec = File.basename(__FILE__)
spec.files = [
File.basename(__FILE__),
target_binary_path,
...
]
spec.files += Dir["lib/**/*"].select { |path| File.file?(path) }
spec.files.uniq!
spec.bindir = "exe"
spec.executables = ["test-entrypoint"]
spec.platform = Gem::Platform.new(target_platform_name)
...
endthe first matrix job that publishes wins, subsequent platforms get: Pushing gem to https://rubygems.pkg.github.com/briceburg...
Error: Version 0.1.0 of "test-gem" has already been pushed.😢 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Product Feedback
Body
Just tinkering with rubygem packages on github recently because why not. However, I noticed something.
In the standard rubygems server you are allowed to have multiple platforms for the same gem version. For example, if you
gem search -r sys-uptimeyou will seesys-uptime (0.7.6 ruby universal-mingw32), one for Windows (universal-mingw32) and one for everything else (ruby), because they have slightly different dependencies but they are both the same version (0.7.6).It appears that github does NOT allow that, and will complain that a "version already exists" if I try to upload a Windows-specific version of the gem. I would like to be able to put up both.
Beta Was this translation helpful? Give feedback.
All reactions