ruby / stringio

Pseudo `IO` class from/to `String`.
BSD 2-Clause "Simplified" License
33 stars 26 forks source link

Specify pre-release string to development version #81

Open hsbt opened 8 months ago

hsbt commented 8 months ago

I understand to use development version policy like "stringio-3.1.1". But this policy is harmful for library developer who used master version of Ruby.

I ususally use master version that is ruby-dev definition of ruby-build and develop software. When I did bundle update on tdiary/tdiary-core, it seems working fine. But stringio-3.1.1 is not released on rubygems.org. So, we get preparation failure on GitHub Actions like:

https://github.com/tdiary/tdiary-core/actions/runs/7470853111/job/20330178338

Can you add .dev suffix to development version? .dev is example, I'm okay to any string that is prelease flag. After that, I easily find dev version of dependencies.

kou commented 8 months ago

I'm OK with adding a suffix but it seems that it's a Bundler bug.

https://github.com/tdiary/tdiary-core/actions/runs/7470853111/job/20330178338#step:6:15

Your bundle is locked to stringio (3.1.1) from rubygems repository
https://rubygems.org/ or installed locally, but that version can no longer be
found in that source.

"that source" means "rubygems repository https://rubygems.org/ or installed locally" not "rubygems repository https://rubygems.org/", right? If so, "stringio (3.1.1)" installed as a default gem should be used by Bundler. Because it exists in a local source.

hsbt commented 7 months ago

If so, "stringio (3.1.1)" installed as a default gem should be used by Bundler. Because it exists in a local source.

I'm not sure what you mean. https://github.com/tdiary/tdiary-core/actions/runs/7470853111/job/20330178338#step:6:15 is not master/head version. Ruby 3.0 or other stable version don't have stringio-3.1.1 as default gems. Why is it Bundler's bug?

Bundler will not pick prerelease version in default. If stringio or other default gems is marked with prelease flag like .dev or .pre, We keep to safe version on lockfile for old versions of ruby.

headius commented 6 months ago

Just noting that I was trying to update JRuby's copy of gems from CRuby master and ran into this for both stringio and strscan (3.1.1 referenced there but not released). I see other gems that are .dev and can skip them until they are released, but there's no way to know 3.1.1 isn't released without checking manually.

joshuapinter commented 3 months ago

I'm also running into this now. Seeing the following message when deploying:

Your bundle is locked to stringio (3.1.1) from rubygems repository https://rubygems.org/ or installed locally, but that version can no longer be found in that source. That means the author of stringio (3.1.1) has removed it. You'll need to update your bundle to a version other than stringio (3.1.1) that hasn't been removed in order to install.

It looks like running bundle update updates stringio to 3.1.1 but Rubygems doesn't have that version.

For reference, our only gem that depends on this is psych and it's not version specific:

psych (5.1.2)
      stringio

I'm not sure where it's finding 3.1.1 and trying to use that.

I will adjust manually for now but anything we can do to solve this longer-term?

Thanks,

Joshua

yahonda commented 2 weeks ago

Rails CI agaist Ruby master branch is getting the same You have already activated stringio 3.1.2.dev, but your Gemfile requires stringio 3.1.1. Since stringio is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports stringio as a default gem. (Gem::LoadError) error since https://github.com/ruby/ruby/commit/32f134bb8541b21b941c49c68b5bf91cf62c97dc

Refer to https://buildkite.com/rails/rails-nightly/builds/971#0191aa3d-c398-4c46-a32b-69de837da9e7/1259

For similar LoadErrors, we have applied workaround by updating Gemfile.lock explicitly for stringio 3.1.1, strscan 3.0.4, strscan 3.0.2 and psych 5.1.1.1 like https://github.com/rails/rails/pull/52123 . However, this workaround does not work for stringio 3.1.2.dev . As far as I understand the original issue can be resolved once https://github.com/rubygems/rubygems/pull/5535 or https://github.com/rubygems/rubygems/pull/5535 is merged to RubyGems.

Steps to reproduce

rdoc is one of the RubyGems that is installed by Rails https://github.com/rails/rails/blob/8bac99ad7a403ef52a5c97e7afa73c7bbcc67110/Gemfile#L65

rdoc depends on psych that depends on stringio.

Install ruby 3.4.0dev that has https://github.com/ruby/ruby/commit/32f134bb8541b21b941c49c68b5bf91cf62c97dc

git clone https://github.com/yahonda/rep_rails_nightly_971
cd rep_rails_nightly_971
bundle install
cd subdir
bundle exec rake

Expected behavior

It should pass as it runs against Ruby 3.3.4.

$ ruby -v
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]
$ bundle info stringio
  * stringio (3.1.1)
    Summary: Pseudo IO on String
    Homepage: https://github.com/ruby/stringio
    Path: /home/yahonda/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/stringio-3.1.1
    Reverse Dependencies:
        psych (5.1.2) depends on stringio (>= 0)
$ bundle exec rake
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Run options: --seed 56666

# Running:

.

Finished in 0.000657s, 1521.0863 runs/s, 1521.0863 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
$

Actual behavior

It raises the following Gem::LoadError

$ ruby -v
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-linux]
$ bundle info stringio
  * stringio (3.1.2.dev)
    Summary: Pseudo IO on String
    Homepage: https://github.com/ruby/stringio
    Path: /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/stringio-3.1.2.dev
    Default Gem: yes
    Reverse Dependencies:
        psych (5.1.2) depends on stringio (>= 0)
$ bundle exec rake
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/runtime.rb:299:in 'Bundler::Runtime#check_for_activated_spec!': You have already activated stringio 3.1.2.dev, but your Gemfile requires stringio 3.1.1. Since stringio is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports stringio as a default gem. (Gem::LoadError)
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/runtime.rb:25:in 'block in Bundler::Runtime#setup'
    from <internal:array>:53:in 'Array#each'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/spec_set.rb:191:in 'Bundler::SpecSet#each'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/runtime.rb:24:in 'Enumerable#map'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/runtime.rb:24:in 'Bundler::Runtime#setup'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/inline.rb:66:in 'block (2 levels) in Object#gemfile'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/settings.rb:158:in 'Bundler::Settings#temporary'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/inline.rb:51:in 'block in Object#gemfile'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler.rb:429:in 'block in Bundler.with_unbundled_env'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler.rb:684:in 'Bundler.with_env'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler.rb:429:in 'Bundler.with_unbundled_env'
    from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/bundler-2.5.17/lib/bundler/inline.rb:42:in 'Object#gemfile'
    from test.rb:5:in '<main>'
+++ 💥 FAILED (exit 1)
$
amatsuda commented 2 weeks ago

I understand the original issue can be resolved once https://github.com/rubygems/rubygems/pull/5535 or https://github.com/rubygems/rubygems/pull/5535 is merged to RubyGems.

Perhaps you meant https://github.com/rubygems/rubygems/pull/5529 or https://github.com/rubygems/rubygems/pull/5535 ?

yahonda commented 2 weeks ago

My bad.

Perhaps you meant https://github.com/rubygems/rubygems/pull/5529 or https://github.com/rubygems/rubygems/pull/5535 ?

Right.

kou commented 2 weeks ago

If so, "stringio (3.1.1)" installed as a default gem should be used by Bundler. Because it exists in a local source.

I'm not sure what you mean. https://github.com/tdiary/tdiary-core/actions/runs/7470853111/job/20330178338#step:6:15 is not master/head version. Ruby 3.0 or other stable version don't have stringio-3.1.1 as default gems. Why is it Bundler's bug?

Bundler will not pick prerelease version in default. If stringio or other default gems is marked with prelease flag like .dev or .pre, We keep to safe version on lockfile for old versions of ruby.

Hmm. I'm not sure your workflow. Is the following correct?

  1. local: Prepare mater Ruby
  2. local: Run bundle update with master Ruby
  3. local: Commit Gemfile.lock and push it to tdiary/tdiary-core
  4. tdiary/tdiary-core: CI with Ruby 3.0 (not master Ruby) failed
kou commented 2 weeks ago

I'm not sure where it's finding 3.1.1 and trying to use that.

Are you using master Ruby?

kou commented 2 weeks ago

The Rails case shows that ".dev" approach causes another problem, right?

hsbt commented 2 weeks ago

Hmm. I'm not sure your workflow. Is the following correct?

local: Prepare mater Ruby
local: Run bundle update with master Ruby
local: Commit Gemfile.lock and push it to tdiary/tdiary-core
tdiary/tdiary-core: CI with Ruby 3.0 (not master Ruby) failed

Yes.

In my understanding, Rails case happened with 3.1.2, not only .dev prefix. It's another issue from my concern.

kou commented 2 weeks ago

OK. If you use master Ruby for bundle update, I think that BUNDLED WITH in Gemfile.lock will be updated to 2.6.0.dev or something too. Is it acceptable? I think that we should use released Ruby not mater Ruby for the use case.

yahonda commented 2 weeks ago

Opened https://github.com/rubygems/rubygems/issues/7996 because it looks like a bundler issue.