error in 8.0.3 ensure_latest: undefined method to_date for 2026-02-26 00:00:00 UTC:Time (NoMethodError)
Background
Brakeman version: 8.0.3 Rails version: 7.2.2 Ruby version: 3.4.6
Issue
In CI we have the following script run brakeman:
#!/usr/bin/env bash
set -eu -o pipefail
echo "--- Running brakeman"
LC_ALL="C.UTF-8" bundle exec brakeman --no-pager --ensure-latest -i config/brakeman.ignore
And we are seeing an error after using the most recent version of brakeman (8.0.3)
Run LC_ALL="C.UTF-8" brakeman --no-pager --ensure-latest -i config/brakeman.ignore
/var/lib/gems/3.2.0/gems/brakeman-8.0.3/lib/brakeman.rb:425:in `ensure_latest': undefined method `to_date' for 2026-02-26 00:00:00 UTC:Time (NoMethodError)
release_date = latest.date.to_date
^^^^^^^^
Did you mean? to_a
from /var/lib/gems/3.2.0/gems/brakeman-8.0.3/lib/brakeman/commandline.rb:49:in `check_latest'
from /var/lib/gems/3.2.0/gems/brakeman-8.0.3/lib/brakeman/commandline.rb:34:in `run'
from /var/lib/gems/3.2.0/gems/brakeman-8.0.3/lib/brakeman/commandline.rb:20:in `start'
from /var/lib/gems/3.2.0/gems/brakeman-8.0.3/bin/brakeman:10:in `<top (required)>'
from /usr/local/bin/brakeman:25:in `load'
from /usr/local/bin/brakeman:25:in `<main>'
Run Brakeman with --debug to see the full stack trace.
Stack trace:
?
Only fails on our CI server, not my local machine.
As far as we can tell, this started for us around 5pm Pacific time on 26 Feb 2026
Fix is to pin to older version
We have a bin/brakeman file we run with a github action. Adding require "date" "fixes" the problem:
#!/usr/bin/env ruby
# frozen_string_literal: true
require "rubygems"
require "bundler/setup"
require "date" # <-- workaround
ARGV.unshift("--ensure-latest")
load Gem.bin_path("brakeman", "brakeman")
Only fails on our CI server, not my local machine.
That's pretty weird (and makes it hard for me to test)... same Ruby version?
Please try with 8.0.4.
Must be an issue with order of library loading or something.