Commit Graph

146 Commits

Author SHA1 Message Date
Jean Boussier
6ba2fdb2fe Bump the required Ruby version to 3.1.0
Until now, Rails only droped compatibility with older
rubies on new majors, but I propose to change this policy
because it causes us to either keep compatibility with long
EOLed rubies or to bump the Rails major more often, and to
drop multiple Ruby versions at once when we bump the major.

In my opinion it's a bad alignments of incentives. And we'd
be much better to just drop support in new minors whenever they
go EOL (so 3 years).

Also Ruby being an upstream dependency, it's not even
a semver violation AFAICT.

Since Rails 7.2 isn't planned before a few months, we
can already drop Ruby 3.0 as it will be EOL in March.
2023-12-31 08:54:03 +01:00
Yasuo Honda
cd5a698c4b
Revert "Lock bigdecimal version to 3.1.4 or lower" 2023-12-17 15:05:47 +09:00
Yasuo Honda
04ab0b58fd Lock bigdecimal version to 3.1.4
This commit addresses the Rails CI using Ruby master branch failure
because Rails CI enables `RAILS_STRICT_WARNINGS` to raise RuntimeError for warnings.

https://buildkite.com/rails/rails/builds/102621#018c49df-e3de-4c2f-aeb7-6d8f08997da9/1102-1107
```ruby
/rails/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb:4: warning: bigdecimal/util is found in bigdecimal, which will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec. (RuntimeError)
```

According to https://bugs.ruby-lang.org/issues/20058 ,
This failure has been triggered since cc9826503d
and it will be addressed once the bigdecimal 3.1.5 is available at rubygems.org .

In the meantime, we can workaround this issue by logking `bigdecimal` version to 3.1.4 or lower.
This commit should be reverted when the `bigdecimal` 3.1.5 is available at rubygems.org .
2023-12-12 11:45:37 +09:00
Jean Boussier
7ae4a5f3b5 Automatically eager load TZInfo
On the first call it can be a bit slow because it needs to load
a bunch of data. It's also better to do it as part of boot
so that some of that data is shared via Copy-on-Write
2023-11-09 18:44:27 +01:00
Jean Boussier
bcdeea5da7 Drop dependency on mutex_m
It used to be stdlib but is being extracted in modern rubies.

Overall its usefulness is dubious. In all cases it is included in
Rails, it's only for the `synchronize` method, but end up exposing
a dozen other useless methods.

In the end just using a Mutex is clearer and simpler.

In some cases we can even get away with a single mutex in a constant.
2023-10-18 14:27:26 +02:00
Koichi ITO
a77535c74c Add bigdecimal to runtime dependency
## Motivation / Background

Follow up 1c93288f8b.

This PR adds bigdecimal to runtime dependency of Active Support to suppress the following Ruby 3.3.0dev's warning.

> /Users/koic/.rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0/bundler/gems/rails-a8871e6829e5/activesupport/lib/
> active_support/core_ext/object/json.rb:5: warning: bigdecimal will be not part of the default gems since Ruby 3.4.0.
> Add bigdecimal to your Gemfile. Also contact author of  to add bigdecimal into its gemspec.

The grep yields the following results:

```console
$ git grep 'require.*bigdecimal'
activejob/lib/active_job/arguments.rb:3:require "bigdecimal"
activejob/lib/active_job/serializers/big_decimal_serializer.rb:3:require "bigdecimal"
activejob/test/cases/argument_serialization_test.rb:3:require "bigdecimal"
activemodel/lib/active_model/type/decimal.rb:3:require "bigdecimal/util"
activemodel/lib/active_model/validations/numericality.rb:5:require "bigdecimal/util"
activemodel/test/cases/validations/numericality_validation_test.rb:8:require "bigdecimal"
activerecord/test/cases/adapters/sqlite3/quoting_test.rb:4:require "bigdecimal"
activerecord/test/cases/arel/visitors/to_sql_test.rb:4:require "bigdecimal"
activerecord/test/cases/migration_test.rb:5:require "bigdecimal/util"
activesupport/lib/active_support/core_ext/big_decimal/conversions.rb:3:require "bigdecimal"
activesupport/lib/active_support/core_ext/big_decimal/conversions.rb:4:require "bigdecimal/util"
activesupport/lib/active_support/core_ext/object/json.rb:5:require "bigdecimal"
activesupport/lib/active_support/message_pack/extensions.rb:3:require "bigdecimal"
activesupport/lib/active_support/xml_mini.rb:5:require "bigdecimal"
activesupport/lib/active_support/xml_mini.rb:6:require "bigdecimal/util"
activesupport/test/core_ext/hash_ext_test.rb:4:require "bigdecimal"
activesupport/test/core_ext/object/duplicable_test.rb:4:require "bigdecimal"
activesupport/test/hash_with_indifferent_access_test.rb:4:require "bigdecimal"
activesupport/test/json/encoding_test_cases.rb:3:require "bigdecimal"
```

By adding only to Active Support as a dependency, it should resolve the issue due to the dependency.

## Detail

The warning is confirmed in the following step:

```ruby
$ cat generic_main.rb
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", github: "rails/rails", branch: "main"
end

require 'active_support'
require 'minitest/autorun'
# These gems will be bundled gems in Ruby 3.4
require 'bigdecimal'
```

Run generic_main.rb with Ruby 3.3.0dev below.

```console
$ ruby -v
ruby 3.3.0dev (2023-08-25T17:47:04Z master 7d32011399) [x86_64-darwin22]

$ ruby generic_main.rb
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
/Users/koic/.rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0/bundler/gems/rails-a8871e6829e5/activesupport/lib/
active_support/core_ext/object/json.rb:5: warning: bigdecimal will be not part of the default gems since Ruby 3.4.0.
Add bigdecimal to your Gemfile. Also contact author of  to add bigdecimal into its gemspec.
Run options: --seed 39015

# Running:

Finished in 0.001313s, 0.0000 runs/s, 0.0000 assertions/s.
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
```

## Additional information

It is essentially the same as https://github.com/rails/rails/pull/48907.
2023-08-26 03:40:25 +09:00
Yasuo Honda
3e52adf28e Add drb, mutex_m and base64 that are bundled gem candidates for Ruby 3.4
This commit adds `drb`, `mutex_m` and `base64` to `activesupport/activesupport.gemspec`
because 3.3.0dev shows warnings if bundled gem candidates are required
like `mutex_m will be not part of the default gems since Ruby 3.4.0. Add it to your Gemfile.`

- Example
```
$ ruby -v ; ruby generic_main.rb
ruby 3.3.0dev (2023-08-07T23:09:02Z master 0e5da05a32) [x86_64-linux]
Fetching https://github.com/rails/rails.git
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/.......
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/bundler/gems/rails-2942958827f1/activesupport/lib/active_support/notifications/fanout.rb:3: warning: mutex_m will be not part of the default gems since Ruby 3.4.0. Add it to your Gemfile.
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.3.0+0/bundler/gems/rails-2942958827f1/activesupport/lib/active_support/message_encryptor.rb:4: warning: base64 will be not part of the default gems since Ruby 3.4.0. Add it to your Gemfile.
generic_main.rb:16: warning: drb will be not part of the default gems since Ruby 3.4.0. Add it to your inline Gemfile.
$
```

- generic_main.rb
```

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", github: "rails/rails", branch: "main"
end

require "active_support"
require "minitest/autorun"
require "drb"
require "base64"
require "mutex_m"
```

These gems are chosen as follows.

- Bundled gems candidates for Ruby 3.4

```ruby
$ ruby -v ; ruby -e 'pp Gem::BUNDLED_GEMS::SINCE.select { |k,v| v == "3.4.0" }'
ruby 3.3.0dev (2023-08-07T23:09:02Z master 0e5da05a32) [x86_64-linux]
{"abbrev"=>"3.4.0",
 "observer"=>"3.4.0",
 "getoptlong"=>"3.4.0",
 "resolv-replace"=>"3.4.0",
 "rinda"=>"3.4.0",
 "nkf"=>"3.4.0",
 "syslog"=>"3.4.0",
 "drb"=>"3.4.0",
 "mutex_m"=>"3.4.0",
 "csv"=>"3.4.0",
 "base64"=>"3.4.0"}
$
```

- `drb`, `mutex_m` and `base64` are required by Rails

- "drb"

```ruby
$ git grep 'require "drb"'
activesupport/lib/active_support/testing/parallelization.rb:require "drb"
activesupport/lib/active_support/testing/parallelization/server.rb:require "drb"
```

- "mutex_m"

```ruby
$ git grep 'require "mutex_m"'
actionpack/lib/action_controller/metal/params_wrapper.rb:    require "mutex_m"
activerecord/lib/active_record/attribute_methods.rb:require "mutex_m"
activerecord/lib/active_record/relation/delegation.rb:require "mutex_m"
activesupport/lib/active_support/notifications/fanout.rb:require "mutex_m"
```

- "base64" usage

```ruby
$ git grep 'require "base64"'
actioncable/Rakefile:require "base64"
actionmailer/lib/action_mailer/inline_preview_interceptor.rb:require "base64"
actionpack/lib/action_controller/metal/http_authentication.rb:require "base64"
actionview/Rakefile:require "base64"
activerecord/lib/active_record/encryption/message_serializer.rb:require "base64"
activerecord/lib/active_record/fixture_set/render_context.rb:require "base64"
activerecord/test/cases/encryption/message_serializer_test.rb:require "base64"
activesupport/lib/active_support/message_encryptor.rb:require "base64"
activesupport/lib/active_support/message_verifier.rb:require "base64"
activesupport/lib/active_support/xml_mini.rb:require "base64"
railties/test/application/mailer_previews_test.rb:require "base64"
```

- Dependency between Rails related modules

- "drb" is only required by Active Support

- "mutex_m" is required by Action Pack, Active Record and Active Support
  Action Pack and Active Record depend on Active Support. Therefore, adding dependency to Active Support is fine.

  2942958827/actionpack/actionpack.gemspec (L36)
  2942958827/activerecord/activerecord.gemspec (L38)

- "base64" is required by Action Cable, Action Mailer, Action Pack, Action View,
  Active Record, Active Support and Raillties.
  Action Cable, Action Mailer, Action Pack, Action View and Active Record and Railties depend
  on Active Support. Therefore, adding dependency to Active Support is fine.

  2942958827/actioncable/actioncable.gemspec (L35)
  2942958827/actionmailer/actionmailer.gemspec (L36)
  2942958827/actionpack/actionpack.gemspec (L36)
  2942958827/actionview/actionview.gemspec (L36)
  2942958827/actionpack/actionpack.gemspec (L36)
  2942958827/railties/railties.gemspec (L40)

Refer to:
https://bugs.ruby-lang.org/issues/19776
https://github.com/ruby/ruby/pull/8126
https://github.com/rubygems/rubygems/pull/6840
2023-08-08 21:08:48 +09:00
fatkodima
799b5c1df4 Enable connection pooling by default for MemCacheStore and RedisCacheStore 2022-06-07 11:40:17 +03:00
Rafael Mendonça França
1fde031e89 Fix gemspec 2021-11-15 21:06:21 +00:00
Rafael Mendonça França
9195b7fd0a
Require MFA to release rails 2021-11-15 20:37:42 +00:00
Xavier Noria
1d6355f6e1 Move Zeitwerk to railties
Active Support should not know about Rails. Once classic has been removed,
AS should get anything it needs from the application as usual.
2021-09-05 03:37:46 +02:00
Xavier Noria
174ee7bb60 Depends on Zeitwerk 2.5.0.beta3 2021-09-01 15:31:04 +02:00
Xavier Noria
fc9a179033 Depends on Zeitwerk 2.5.0.beta2 2021-08-21 01:23:21 +02:00
Xavier Noria
6068639775 Upgrades Zeitwerk to 2.5.0.beta 2021-08-04 09:43:06 +02:00
Rafael Mendonça França
6487836af8
Rails 7 requires Ruby 2.7 and prefer Ruby 3+
The code cleanup is comming in later commits but this
already remove support to Ruby < 2.7.
2021-02-04 16:34:53 +00:00
Rafael Mendonça França
f624ed09ab
Don't make rexml an dependency of activesupport
rexml is only used in the xml_mini backend and it should be the users
choice if they want to use that feature or not. If they do we will warn
them that installing rexml is needed like we do with all backends.
2020-09-24 22:41:04 +00:00
Ryuta Kamizono
c23533ee0b rexml is no longer default gem in Ruby 3.0
https://bugs.ruby-lang.org/issues/16485
https://github.com/ruby/ruby/pull/2832

Unless adding `s.add_dependency "rexml"` in the gemspec,
`ActiveSupport::XmlMini` with default engine (REXML) won't work.

```ruby
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "activesupport", github: "rails/rails"
end

require "active_support"
require "active_support/xml_mini"
require "minitest/autorun"

class BugTest < Minitest::Test
  def test_stuff
    xml_string = "<root></root>"
    assert_equal({ "root" => {} }, ActiveSupport::XmlMini.parse(xml_string))
  end
end
```

```
% ruby xml_mini.rb
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies...
Using bundler 2.2.0.dev
Using concurrent-ruby 1.1.7
Using minitest 5.14.2
Using zeitwerk 2.4.0
Using i18n 1.8.5
Using tzinfo 2.0.2
Using activesupport 6.1.0.alpha from source at `..`
Run options: --seed 20428

# Running:

E

Finished in 0.002034s, 491.6421 runs/s, 0.0000 assertions/s.

  1) Error:
BugTest#test_stuff:
LoadError: cannot load such file -- rexml/document
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/xml_mini/rexml.rb:28:in `require'
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/xml_mini/rexml.rb:28:in `block in parse'
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:15:in `block in silence_warnings'
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:28:in `with_warnings'
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:15:in `silence_warnings'
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/xml_mini/rexml.rb:28:in `parse'
    /Users/kamipo/src/github.com/rails/rails/activesupport/lib/active_support/xml_mini.rb:94:in `parse'
    xml_mini.rb:23:in `test_stuff'

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

Follow up of 0399be70766d7c6bf46d727ef2e337ff40f242b4.
2020-09-24 16:07:16 +09:00
David Heinemeier Hansson
36a33d721c Needlessly tight dependency spec
Let it float, unless there's a specific threat to the opposite.
2020-05-31 16:45:37 -07:00
Xavier Noria
cf71309684 Depend on Zeitwerk 2.3
Let's bump Zeitwerk in preparation for Rails 6.1.

With Zeitwerk 2.3, applications can enable reloading and eager loading
at the same time. As of this writing, Rails does not implement that
logic, but if we do we know the dependency is in place to support it.

Zeitwerk minor releases are backwards compatible, should be a seamlessly
upgrade.
2020-05-02 11:53:30 +02:00
Abhay Nikam
bdfffd1355 Update the Rails mailing list URLs to new discuss discourse URL [ci skip] 2020-04-02 22:00:28 +05:30
Phil Ross
e9425abe33
Update to TZInfo v2.0.0
Co-authored-by: Jared Beck <jared@jaredbeck.com>
Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2020-03-28 20:42:43 +01:00
Jean Boussier
54878cd44b Distinguish missing controller exceptions from unrelated NameError
Fix: https://github.com/rails/rails/issues/37650

The classic autoloader used to totally unregister any constant that
failed midway. Which mean `"SomeConst".constantize` was idempotent.

However Zeitwerk rely on normal `Kernel#require` behavior, which mean
that if an exception is raised during a class/module definition,
it will be left incompletely defined. For instance:

```ruby
class FooController
  ::DoesNotExist

  def index
  end
end
```

Will leave `FooController` defined, but without its `index` method.

Because of this, when silencing a NameError, it's important
to make sure the missing constant is really the one we were trying
to load.
2019-12-04 16:11:54 +01:00
Diego Plentz
9731bcbee7 Add I18n to eager_load_namespaces 2019-11-21 14:59:22 -05:00
Orien Madgwick
493edf044f Add bug tracker/documentation/mailing list URIs to the gemspecs 2019-10-11 20:47:19 -04:00
Xavier Noria
245f255318 bump Zeitwerk to 2.2 2019-10-09 21:30:48 +02:00
Xavier Noria
72e257b4c9 bumps Zeitwerk
This version makes eager loading and autoloading consistent,
as documented in the upgrading guide.
2019-06-30 23:57:19 +02:00
Xavier Noria
1b2efe5a11 upgrades Zeitwerk to 2.1.4
This commit more or less undoes 9b5401f, restores autoloaded? not to
touch the descendants tracker, and autoloaded_constants because it is
documented in the guide.
2019-04-23 01:18:21 +02:00
Xavier Noria
7b6b10542d improves the reloading disabled error message
The original message from Zeitwerk is "can't reload, please call
loader.enable_reloading before setup (Zeitwerk::Error)", which is not
very informative for Rails programmers.

Rails should err with a message worded in terms of its interface.
2019-04-11 23:10:13 +02:00
Xavier Noria
9b5401fcc9 depend on Zeitwerk 2.1.0 2019-04-09 11:06:44 +02:00
Xavier Noria
57c7cbb162 depend on Zeitwerk 2 2019-04-07 13:05:26 +02:00
Xavier Noria
379d7e8bfa bumps Zeitwerk and Bootsnap 2019-03-26 20:30:18 +01:00
Xavier Noria
3acf5f71f0 Depend on Zeitwerk 1.4.2 2019-03-23 14:42:24 +01:00
Xavier Noria
3d0850bfb8 depend on Zeitwerk 1.4.0 2019-03-19 13:07:31 +01:00
Xavier Noria
85984e5031 bumps Zeitwerk 2019-03-14 14:42:12 -07:00
Xavier Noria
96242410a8 bump Zeitwerk to 1.3.3 2019-03-11 16:11:35 -07:00
Abhay Nikam
027e492b6f Fix links in gemspec and docs from http to https. 2019-03-09 19:42:35 +05:30
Xavier Noria
71e23d33ae Bump Zeitwerk 2019-03-06 12:08:08 -08:00
Xavier Noria
24092b7115 Upgrade Zeitwerk to 1.3.1 2019-02-23 05:16:03 -08:00
Xavier Noria
159b9c40db bump Zeitwerk 2019-02-21 14:27:32 -08:00
Xavier Noria
07346c4b35 upgrades Zeitwerk to 1.2.0 2019-02-17 10:10:05 -08:00
Xavier Noria
870377915a Replace autoloader accessors with Rails.autoloaders.{main,once}
Rails.autoloader and Rails.once_autoloader was just tentative API good
enough for a first patch. Rails.autoloader is singular and does not
convey in its name that there is another autoloader. That might be
confusing, for example if you set a logger and miss traces. On the other
hand, the name `once_autoloader` is very close to being horrible.

Rails.autoloaders.main and Rails.autoloaders.once read better for my
taste, and have a nice symmetry. Also, both "main" and "once" are four
letters long, short and same length.

They are tagged as "rails.main" and "rails.once", respectively.

References #35235.
2019-02-14 22:34:16 -08:00
Xavier Noria
c36b6c8d38 Let Zeitwerk be a dependency of Active Support
Zeitwerk is a strong dependency, planned to replace AS::Dependencies. A
line in the generated Gemfile does not convey this as much.
2019-02-13 12:27:53 -08:00
Kasper Timm Hansen
647d7e6167
Revert "Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json""
I reverted the wrong commit. Damn it.

This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
2019-01-08 22:19:22 +01:00
Kasper Timm Hansen
f66a977fc7
Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"
We had a discussion on the Core team and we don't want to expose this information
as a JSON endpoint and not by default.

It doesn't make sense to expose this JSON locally and this controller is only
accessible in dev, so the proposed access from a production app seems off.

This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing
changes made to b6e4305c3bca4c673996d0af9db0f4cfbf50215e.
2019-01-08 22:16:58 +01:00
Kasper Timm Hansen
1b7c3222e8
Require Ruby 2.5 for Rails 6.
Generally followed the pattern for https://github.com/rails/rails/pull/32034

* Removes needless CI configs for 2.4
* Targets 2.5 in rubocop
* Updates existing CHANGELOG entries for fewer merge conflicts
* Removes Hash#slice extension as that's inlined on Ruby 2.5.
* Removes the need for send on define_method in MethodCallAssertions.
2018-12-19 21:47:50 +01:00
Gannon McGibbon
e74fdbe00c Amend CVE note and security guide section wordings
Reword first sentence of dep management and CVE section of
security guide. Also, reword and move gemspec notes above deps.

[ci skip]
2018-11-06 18:06:57 -05:00
Gannon McGibbon
1c11688b56 Add CVE note to security guide and gemspecs
[ci skip]
2018-11-06 14:25:36 -05:00
Jeremy Daer
d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
Rafael Mendonça França
0ea8e7db1a Remove support to Ruby 2.2
Rails 6 will only support Ruby >= 2.3.
2018-02-16 18:52:10 -05:00
Rafael Mendonça França
2e87ea6d70 Don't force people to upgrade i18n gem 2018-02-14 11:55:36 -05:00