CodeSampleX

Ejemplo

csv 3.3.5: Fix LoadError for csv or base64 after a Ruby upgrade, where they used to be built

Muestra verificada para gem csv 3.3.5: Fix LoadError for csv or base64 after a Ruby upgrade, where they used to be built. El contrato se ejecutó en ruby 3 …

sha256:8f9a1d4bba7bafae896c8862e6cc34aa3d64cb931492106f55207f395dde64bb

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
2
Entorno declarado ruby 3 linux x64 ruby 3 ruby bundler

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
ruby 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · gem@1
2026-08-14
ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · gem@1
2026-08-17

Caso

FIX
Objetivo
Fix LoadError for csv or base64 after a Ruby upgrade, where they used to be built in
Paquetes
Símbolos
  • CSV.parse
  • Base64.strict_encode64
Entorno
ruby 3
Creado
2026-08-14T05:46:56Z

Contrato

  1. declare the extracted default gems in the Gemfile
  2. assert requiring csv and base64 works because they are declared
  3. assert strict_encode64 omits the newlines encode64 inserts
  4. assert both now appear as resolved gems rather than builtins

Archivos

  • Gemfile
  • Gemfile.lock
  • csx.json
  • test/contract.rb

Descargar el artefacto de código fuente (tar.gz)

Código fuente

Gemfile
source "https://rubygems.org"

# Modern Ruby moved several stdlib libraries out of the default gem set.
# Requiring them without declaring them raises LoadError, which is the most
# common "my code broke on the new Ruby" report.
gem "csv", "3.3.5"
gem "base64", "0.3.0"
gem "minitest", "5.25.4"
Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    base64 (0.3.0)
    csv (3.3.5)
    minitest (5.25.4)

PLATFORMS
  ruby
  x86_64-linux-musl

DEPENDENCIES
  base64 (= 0.3.0)
  csv (= 3.3.5)
  minitest (= 5.25.4)

CHECKSUMS
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
  bundler (4.0.18) sha256=02d9a17429de1847b4e0c9f27a9ee4b20c0a74c0a641b4e77195d6019e3618ac
  csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
  minitest (5.25.4) sha256=9cf2cae25ac4dfc90c988ebc3b917f53c054978b673273da1bd20bcb0778f947

BUNDLED WITH
  4.0.18
csx.json
{"case":{"caseId":"case:sha256:ddc7e373cb2bf4c3b768cbef9d486b18dcec1b994b4ce7c82bca9a4f28abb1d9","constraints":{"runtime":"ruby"},"contract":["declare the extracted default gems in the Gemfile","assert requiring csv and base64 works because they are declared","assert strict_encode64 omits the newlines encode64 inserts","assert both now appear as resolved gems rather than builtins"],"goal":"Fix LoadError for csv or base64 after a Ruby upgrade, where they used to be built in","kind":"FIX","packages":["pkg:gem/csv@3.3.5","pkg:gem/base64@0.3.0"],"schemaVersion":1,"symbols":["CSV.parse","Base64.strict_encode64"]},"contractCommand":["bundle","exec","ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","runtimeVersion":"3","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/csv@3.3.5","pkg:gem/base64@0.3.0"],"schemaVersion":1,"symbols":["CSV.parse","Base64.strict_encode64"],"verifierAdapter":"gem@1"}
test/contract.rb
require "minitest/autorun"

# The point: these used to come free with the interpreter. They are ordinary
# gems now, so this file loads only because the Gemfile declares them.
# Removing either line reproduces the LoadError an undeclared application
# hits after the upgrade.
require "csv"
require "base64"

class DefaultGemExtractionTest < Minitest::Test
  def test_csv_is_available_because_it_is_declared
    rows = CSV.parse("a,b\n1,2", headers: true)
    assert_equal ["a", "b"], rows.headers
    assert_equal "1", rows.first["a"]
  end

  def test_base64_round_trips_and_strict_refuses_newlines
    assert_equal "codesamplex", Base64.decode64(Base64.encode64("codesamplex"))
    # encode64 inserts newlines every 60 chars; strict_encode64 does not.
    # Tokens built with the non-strict form are the usual breakage.
    assert_equal "Y29kZXNhbXBsZXg=", Base64.strict_encode64("codesamplex")
    long = "a" * 100
    assert_includes Base64.encode64(long), "\n"
    refute_includes Base64.strict_encode64(long), "\n"
  end

  def test_they_are_resolved_gems_now
    assert Gem.loaded_specs.key?("csv"), "csv should be a resolved gem"
    assert Gem.loaded_specs.key?("base64"), "base64 should be a resolved gem"
  end
end

Seeder de origen

anonymous