r/ruby • • 1d ago

Security updates for JRuby: 9.4.16.1, 10.0.8.1, 10.1.3.1

Thumbnail jruby.org
16 Upvotes

Security 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.


r/ruby • • 15d ago

Security Upgrade Ruby ASAP - Security advisories: multiple vulnerabilities in Regexp and String case conversations

Thumbnail
ruby-lang.org
130 Upvotes

r/ruby • • 4h ago

Question So much knowledge in one joke

Post image
8 Upvotes

r/ruby • • 6h ago

Ruby Users Forum Wrapped 2026

Thumbnail
rubyforum.org
5 Upvotes

r/ruby • • 1d ago

2027 Gem Fellowship: Applications are Open!

Thumbnail mikeperham.com
11 Upvotes

r/ruby • • 2d ago

Question GVL and concurrent programming

10 Upvotes

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 • • 1d ago

Using ARGF on a subset of ARGV?

0 Upvotes

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 • • 1d ago

Speed Demon II: a 72-hour optimisation race in slow languages, Ruby included

4 Upvotes

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 • • 2d ago

Blog post Spotting a Typosquat in Your Gemfile.lock

Thumbnail
go.fastruby.io
9 Upvotes

r/ruby • • 2d ago

mruby 4.1.0 released

Thumbnail mruby.org
11 Upvotes

r/ruby • • 3d ago

Ruby Users Forum - Monthly Update - November 2026

Thumbnail
rubyforum.org
6 Upvotes

r/ruby • • 3d ago

Closer to the business, further from the Rails way

Thumbnail
blog.arkency.com
19 Upvotes

r/ruby • • 3d ago

I built schema_shard — dynamic Rails 8 database sharding & fail-closed multi-tenancy (when static connects_to isn't enough)

3 Upvotes

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 • • 5d ago

Strata: Ruby 0.49 – 1.8.7 in your browser

Thumbnail
strata.matiaskorhonen.fi
18 Upvotes

r/ruby • • 5d ago

Steep / RBS toolkit - (steep-kit gem)

10 Upvotes

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-body alias / alias_method, unannotated literal constants, ClassMethods mixins, dynamic superclasses, and macros like attr_json.
  • Scaling friction: body-checking overhead on silent donor files, CLI/LSP memory retention, drifted rbs_rails output, and signature/runtime drift.

What it does

  • Projected RBS (sig/projected + watch): generates classic RBS reopenings for Data.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): syncs rbs_collection, lints inline grammar pitfalls (class << self, Data.define blocks), validates record-constant key lookups workspace-wide via Rubydex, and checks sig/projected freshness.
  • Optional tooling: steep-kit fast (targeted --validate=skip checks), deterministic scratch-DB steep-kit rbs-rails, and SteepKit::Runtime (rbs/test with 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


r/ruby • • 7d ago

Snails is a Rails-like framework for API-only Ruby apps.

Thumbnail snails-rb.org
25 Upvotes

Snails 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 • • 8d ago

Call Things What They Are

Thumbnail
saturnci.com
69 Upvotes

r/ruby • • 8d ago

Phlex 3 Beta is out with a specialised Ruby-to-Ruby JIT for components

23 Upvotes

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.


r/ruby • • 8d ago

Blog post Start with one server, even if you plan to take over the world

Thumbnail
widefix.com
2 Upvotes

A lesson from maintaining legacy Ruby on Rails apps.


r/ruby • • 9d ago

stylebench: compare how different models write ruby, stylistically

Thumbnail nateberkopec.github.io
14 Upvotes

Vibe 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!


r/ruby • • 10d ago

Blog post UUIDv7 primary keys in Rails and PostgreSQL

Thumbnail
randomerrata.com
37 Upvotes

r/ruby • • 11d ago

JRuby 9.4.16.0 Released with security updates

Thumbnail jruby.org
18 Upvotes

We 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.

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

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

5 Issues and PRs resolved for 9.4.16.0


r/ruby • • 11d ago

Steadfast Update II - Rewriting ASTs

Thumbnail noteflakes.com
8 Upvotes

r/ruby • • 11d ago

Agent_primitives – capabilities your coding agent has to prove with specs

0 Upvotes

**Edited to better explain my ramblings. Hopefully...

Morning all,

You ask a coding agent to refactor the comments view. It breaks reply nesting, and this spec fails:

it "shows replies nested under their parent" do
  expect(page).to have_css(".comment .comment", text: "Nice post")
  expect(page).to have_css(".comment[data-depth='1']")
end

The agent "fixes" the failure by deleting the second assertion. The suite is green. The only evidence is one hunk in a 600 line diff, and nothing tells you that this spec mattered more than the forty around it.

Tests protect your code, but nothing protects the tests. That matters once agents write both.

I've released agent_primitives, a gem that covers that gap. It has two parts.

1. You write down what the app must keep doing. Each capability gets a short doc with plain numbered sentences:

I1 — A reader can reply to any comment.
I2 — Replies show nested under their parent.

2. You tag the specs that prove each sentence.

it "shows replies nested under their parent", intent: "comment_threads#I2" do

These are ordinary RSpec examples and they run as before. The tag is just metadata.

Now the same agent edit gets reported:

$ bundle exec agent_primitives guard --base main
spec/system/comment_threads_spec.rb
  7:1   N  the example proving comment_threads#I2 lost 1 assertion(s) — it still carries the tag while proving less of the clause   [proof/weakened]

If the agent deletes the example outright, the check that runs in CI fails:

$ bundle exec agent_primitives evals
docs/primitives/capabilities/comment_threads.md
  9:1   E  spec/system/comment_threads_spec.rb carries no `intent: "comment_threads#I2"` tag   [evaluation/untagged]

1 capability, 4 clauses — 1 offence

Rewording a sentence is reported too, so an agent can't change what the app is supposed to do without you seeing it.

A few other things it does:

  • The agent reads the doc before it plans a change, so it stops "fixing" deliberate decisions that look like bugs.
  • Each doc keeps a history of decisions and rejected alternatives, so the agent stops proposing the approach you turned down last month.
  • It works forwards. Write the sentences before the code, and each one becomes a spec the agent has to make pass.
  • You don't write the docs by hand. The gem ships agent skills that fold this into planning, building and review, and one that interviews you to backfill an existing feature.

It needs RSpec and an agent that can load skills.

gem "agent_primitives", group: :development

Source and README: GitHub - pitch-sourcery/agent_primitives · GitHub

I extracted it from the harness I use every day on my own startup's Rails app. It's a 0.1.0, so tell me where it's confusing or wrong.