r/ruby • u/geospeck • 6h ago
Security updates for JRuby: 9.4.16.1, 10.0.8.1, 10.1.3.1
jruby.orgSecurity alert! We have just released JRuby versions 9.4.16.1, 10.0.8.1, and 10.1.3.1 to address a medium to high-severity security issue. All users are strongly encouraged to upgrade and consider signing up for support services from https://headius.com
We will release technical details of this issue on December 8, 2026, at 18:00UTC.
See the release announcements at https://www.jruby.org/news for more details.
Security Upgrade Ruby ASAP - Security advisories: multiple vulnerabilities in Regexp and String case conversations
r/ruby • u/Calm_Adagio_9991 • 10h ago
AcceptLanguage 3.0: one method, bounded parsing, and a written spec
I posted here about accept_language 2.2 earlier this year. Version 3.0 is out, and it is a breaking release, so here is what changed and why.
One entry point. parse and match are gone. There is a single method now:
# 2.x
AcceptLanguage.parse(header).match(:en, :fr)
# 3.0
AcceptLanguage.negotiate(header, %i[en fr])
It takes the header value (or nil) and an Array of Symbols or Strings, and returns the best match exactly as you gave it, or nil.
Bounded work on client input. The header comes from the client, so the library now limits what it does with it: a field longer than 4096 bytes is treated as absent, and only the first 50 elements are considered. In 2.x, a 1 MB header took seconds to process.
No header makes it raise. A header with invalid encoding (a UTF-8 String holding 0xFF, say) used to raise ArgumentError. The field is now handled as bytes. Case folding is ASCII-only too: U+212A KELVIN SIGN is no longer read as k.
A few results change. When several ranges match a tag, the most specific one now decides its q-value:
AcceptLanguage.negotiate("en-US, en;q=0", %i[en-US])
# => :"en-US" (was nil)
AcceptLanguage.negotiate("en;q=0.9, en-US;q=0.5", %i[en-US en-GB])
# => :"en-GB" (was :"en-US")
This only matters when a header lists a range and one of its prefixes with different q-values. Duplicate ranges and malformed elements (en;q=, e n) also have a defined behavior now; the changelog lists each case.
A specification and shared test vectors. The behavior is written down in SPECIFICATION.md, with test vectors in a TSV file. The Elixir port implements the same spec and passes the same vectors.
Ruby 3.3+ is required. Still zero dependencies.
- GitHub: https://github.com/cyril/accept_language.rb
- Changelog: https://github.com/cyril/accept_language.rb/blob/main/CHANGELOG.md
Feedback welcome, especially on the matching rule change.
r/ruby • u/retro-rubies • 2d ago
2027 Gem Fellowship: Applications are Open!
mikeperham.comr/ruby • u/Edthal01 • 3d ago
Question GVL and concurrent programming
Ruby cannot perform real concurrent processing on multicore microprocessors without using ractors because of the GVL. It will only simulate multiple simultaneous processes with threads, queues, mutexes, etc. in a single processor core, no true parallel processing. How does this limitation affect true parallel programming in Ruby, that is, how much more complicated is it in producing true multicore parallel programming? I am still working on learning Ruby and this is part of my self-inflicted learning process in parallel with Huw Collingworth Book of Ruby.
r/ruby • u/unselective-amnesia • 2d ago
Using ARGF on a subset of ARGV?
This thread is solely a simple technical question about the ruby language.
As you read this question, please keep in mind that ...
... I am NOT asking about any alternative ways to accomplish what I'm discussing.
... I am NOT asking an "XY" question.
... I do not want to get into any discussions nor arguments about why I am doing what I'm discussing, nor concerning whether or not what I'm writing about is a recommended practice.
... and again, keep in mind that I am only looking for the answer to one simple technical question about the ruby language, and nothing else.
I'm sorry for this verbiage about what I don't want to discuss here. However, I have learned from the responses to other questions that I have asked in reddit that some people refuse to read the initial post of a thread in its entirety before responding, and that some other people do read the initial post, but then still make a point to disrespect the stipulations that are made in that initial post. I'm hoping that by all of what I've written here concerning what I don't want, that my stipulations will indeed be respected this time.
Thank you very much for keeping all of these points in mind as you read my question now:
I understand most of the information about ruby's ARGF construct. However, I want to do something involving ARGF that I couldn't find any documentation for.
I have a ruby program that is invoked as follows:
ruby-program operation [ optional arguments ... ]
I know that I can get 'operation' from ARGV[0]. And I then want to process the remaining 'optional arguments' via ARGF: i.e., to either treat these remaining arguments as filenames whose data is returned by ARGF, or if these optional arguments are missing, for the data to be obtained from stdin.
I know that ARGF normally processes the entire ARGV, but in this case, I'd like ARGF to ignore ARGV[0] and to only process whatever command-line arguments commence with ARGV[1] (if it exists, of course ... and if it doesn't exist, to then have ARGF get its data from stdin).
I know of alternative ways to accomplish this without using ARGF at all; however, please remember what I wrote at the beginning of this message about NOT wanting to discuss such alternatives. All I want in this case is to know of a way that I might be able to accomplish what I'm discussing via the use of ARGF.
And please note that if this is not possible via ARGF, since I already know of alternatives that I can utilize, I therefore don't want to discuss any of those alternatives here. In the case of this not being possible with ARGF, I just would ONLY like to know about this indeed being impossible, and then I won't want to discuss anything else.
Thank you very much in advance.
r/ruby • u/Sensitive-Training22 • 2d ago
Speed Demon II: a 72-hour optimisation race in slow languages, Ruby included
Speed Demon II runs online from 29 January to 1 February 2027. Teams of 1 to 4 make code in a slow language as fast as they can. Faster code moves your team's car round a race track through San Francisco.
Details: https://speeddemon.dev/2027/
Register: https://speeddemon.dev/2027/register/
r/ruby • u/ombulabs • 3d ago
Blog post Spotting a Typosquat in Your Gemfile.lock
r/ruby • u/javier_cervantes • 4d ago
Ruby Users Forum - Monthly Update - November 2026
r/ruby • u/pdabrowski • 4d ago
Closer to the business, further from the Rails way
r/ruby • u/Dry-Exam-3338 • 4d ago
I built schema_shard — dynamic Rails 8 database sharding & fail-closed multi-tenancy (when static connects_to isn't enough)
Hey r/ruby!
I recently published an open-source gem called **schema_shard** and would love some eyes on it from folks running multi-tenant or sharded Rails 8 apps, whether it’s code review, edge-case feedback, or testing it out in a staging setup.
### Why not just use Rails' built-in `connects_to` / `connected_to`?
Rails 8's native multi-DB support is great when you have a fixed, known set of shards declared at boot time on `ApplicationRecord`. Where it starts getting painful is when you need **dynamic, runtime-driven routing** or **schema/database-level tenant isolation** without bloating your connection count.
`schema_shard` sits on top of Active Record's connection pooling (`HashConfig` / `PoolConfig` + `IsolatedExecutionState`) to handle three things out of the box:
* **Dynamic Config-Driven Shards (No Static `connects_to` Boilerplate):** Define shards in `config/shards.yml` (or pass a runtime `Proc`) and route blocks with `SchemaShard.with('acme_corp', shard_key: 'replica_1')` or `SchemaShard.on_shard('write_shard_2', read_only: false)` without hardcoding shard mappings on every model class.
* **LRU-Bounded Connection Pools:** Instead of holding open pools forever for every shard/tenant combination, it uses an atomic refcounted LRU registry (`max_pools`) to evict idle pools safely under load without racing active queries.
* **Fail-Closed Multi-Tenant Isolation:** Supports PostgreSQL (`search_path` or `ros-apartment`), MySQL/MariaDB (`trilogy` & `mysql2`), and per-tenant SQLite3 files. In `:strict` mode, missing/blank tenants, system schemas, or nested tenant switches inside an open transaction fail closed rather than silently falling back to `public` or your primary DB.
### Quick Example
```ruby
# Fail-closed tenant + read-replica routing (read-only at both Rails and DB session levels)
SchemaShard.with('acme_corp', shard_key: 'replica_1') do
Order.where(status: 'paid').count
end
# Pure shard routing (no tenant switching)
SchemaShard.on_shard('write_shard_2', read_only: false) do
AuditLog.create!(event: 'synced')
end
Looking for Feedback
I'd genuinely appreciate any feedback on the architecture, pool lifecycle edge cases, or how you're handling dynamic sharding in Rails 8 today:
* GitHub: https://github.com/syrens/schema_shard
* RubyGems: https://rubygems.org/gems/schema_shard
Thanks in advance for checking it out!
r/ruby • u/maokomioko • 6d ago
Steep / RBS toolkit - (steep-kit gem)
Hi all,
I just open-sourced (slope-coded) steep-kit, a companion toolkit for Ruby apps and gems typed with inline RBS (# u/rbs / #:) and checked with Steep.
It was battle-tested in our company for about 4-5 months and evolved (slope-rewritten) to a point of being community ready. https://github.com/maokomioko/steep-kit
Why it exists
RBS 4.2's native inline parser + Steep 2.1 are great, but adopting them incrementally on a larger codebase hits two recurring gaps:
- Runtime definitions the inline parser can't see:
Data.define/Struct.new, class-bodyalias/alias_method, unannotated literal constants,ClassMethodsmixins, dynamic superclasses, and macros likeattr_json. - Scaling friction: body-checking overhead on silent donor files, CLI/LSP memory retention, drifted
rbs_railsoutput, and signature/runtime drift.
What it does
- Projected RBS (
sig/projected+watch): generates classic RBS reopenings forData.define/Struct.new,alias/alias_method, and (opt-in)attr_json. - In-memory RBS & Steep enhancements: infers literal/record constants, handles value/dynamic superclasses and opt-in mixin contracts (
ClassMethods, command aliases, nested classes), and patches Steep for lower overhead (signature-only silent donors, path-indexed lookups, completed-typing compaction). - Single CI / pre-push gate (
bundle exec steep-kit): syncsrbs_collection, lints inline grammar pitfalls (class << self,Data.defineblocks), validates record-constant key lookups workspace-wide via Rubydex, and checkssig/projectedfreshness. - Optional tooling:
steep-kit fast(targeted--validate=skipchecks), deterministic scratch-DBsteep-kit rbs-rails, andSteepKit::Runtime(rbs/testwith inline RBS + nested mismatch paths).
All Rails and convention features are off by default, so it works for plain Ruby apps and gems too (Ruby 3.3+, RBS 4.2, Steep 2.1, Rubydex 0.4).
Hope it helps someone else :3
Snails is a Rails-like framework for API-only Ruby apps.
snails-rb.orgSnails builds on Matz's Spinel to compile apps into a single native binary, minus Active Record, server-rendered views and gems. It keeps the Rails conventions and builds the framework in plain Ruby. One process, multi-threaded, across all cores: no worker processes, no GVL. On the benchmark, Snails serves about 3× the requests per second of Rails in cluster mode, with more than 10× lower peak memory under load.
Site: https://snails-rb.org/
Repository: https://github.com/snails-rb/snails
r/ruby • u/_joeldrapper • 9d ago
Phlex 3 Beta is out with a specialised Ruby-to-Ruby JIT for components
We just released the first beta of Phlex 3, which includes a special Ruby-to-Ruby just-in-time compiler, allowing us to optimise performance far beyond what’s possible at runtime.
The compiler starts from what’s actually loaded. It asks each component’s live methods where they were defined, parses those files with Prism and turns them into a syntax tree.
Then it walks the tree and decides what each call really means by asking the running program: is div still Phlex’s div, or has someone overridden it, refined it or mixed something over it? Is that constant still the string it was? Each call we can prove is ours is replaced with a node that just appends text. Everything else is left as it was.
Next comes fusing: neighbouring appends merge, so a run of static elements becomes a single string, escaped and serialised once.
Finally, the tree is formatted back into Ruby, with a source map so that errors point to your original file and line, and this is evaluated in place of the original methods.
I posted more details including some micro benchmark results. You can also see the full release notes on GitHub.
I don’t know if this is going to work or if we’re going to discover some new edge case we hadn’t thought of, but it looks promising so far and it’s been running in production with 465 components for over 24 hours without any issues.
Blog post Start with one server, even if you plan to take over the world
A lesson from maintaining legacy Ruby on Rails apps.
r/ruby • u/nateberkopec • 10d ago
stylebench: compare how different models write ruby, stylistically
nateberkopec.github.ioVibe coded in an hour. Please send all feedback to https://github.com/nateberkopec/stylebench. If you wish there was a model here that I didn't include, go run it yourself!
JRuby 9.4.16.0 Released with security updates
jruby.orgWe are happy to announce the release of JRuby 9.4.16.0, a sponsored release mostly containing third-party security updates. Users still on JRuby 9.4 are encouraged to update and sign up for support services at https://headius.com to assist with future releases and upgrading to JRuby 10.x.
- Homepage: https://www.jruby.org/
- Download: https://www.jruby.org/download
JRuby 9.4.x targets Ruby 3.1 compatibility.
Thank you to our contributors this release, you help keep JRuby moving forward! @jessecai33, @mnpoonia
Notable Changes
Security
Updated several dependencies to pick up security fixes.
- jruby-opensl 0.16.3 with Bouncy Castle 1.86. #9730
- rdoc 6.6.3.1, fixing sonatype-2022-6090. #9730
- uri 0.12.5, fixing CVE-2025-61594. #9730
- net-imap 0.6.7, with over 15 years of bug and security updates. #9730
- asm bytecode library 9.11.1, fixing several potential DoS security issues. #10119
- resolv equivalent to 0.7.2 (vendored) for hostname-length and generic-resource fixes. #10119
Compatibility
- Improved handling of ruby2_keywords argument passing. #9517
- Marshal dump and load of an identity hash no longer loses identity bit. #9584
Java Integration
- JVM bytecode output will now better match the current JVM, up to the limits of the ASM bytecode library. #9483