From f6c9aea1b7da94cafd425e57d4314354c66f2930 Mon Sep 17 00:00:00 2001 From: Peter Solnica Date: Thu, 21 Aug 2025 10:02:00 +0000 Subject: [PATCH 1/5] [rails] fix bundling for older rubies --- sentry-rails/Gemfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sentry-rails/Gemfile b/sentry-rails/Gemfile index f27453ac6..6008cdf49 100644 --- a/sentry-rails/Gemfile +++ b/sentry-rails/Gemfile @@ -16,8 +16,18 @@ end ruby_version = Gem::Version.new(RUBY_VERSION) -rails_version = ENV["RAILS_VERSION"] -rails_version = "8.0.0" if rails_version.nil? +rails_version = ENV.fetch("RAILS_VERSION") do + if ruby_version >= Gem::Version.new("3.2") + "8.0" + elsif ruby_version >= Gem::Version.new("3.1") + "7.2" + elsif ruby_version >= Gem::Version.new("2.7") + "7.1" + elsif ruby_version >= Gem::Version.new("2.4") + "5.2" + end +end + rails_version = Gem::Version.new(rails_version) gem "rails", "~> #{rails_version}" From 5b95a856c61ebe2706dea65ecc2b4b9901fda28f Mon Sep 17 00:00:00 2001 From: Peter Solnica Date: Thu, 21 Aug 2025 10:03:21 +0000 Subject: [PATCH 2/5] [e2e] completely relax rails version requirement This is just for convenience so that it can bundle under various rubies --- spec/apps/rails-mini/Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/apps/rails-mini/Gemfile b/spec/apps/rails-mini/Gemfile index 6ba99b8af..be4cf2082 100644 --- a/spec/apps/rails-mini/Gemfile +++ b/spec/apps/rails-mini/Gemfile @@ -4,7 +4,7 @@ source 'https://rubygems.org' gem "rake" gem "puma" -gem 'railties', '~> 8.0' -gem 'actionpack', '~> 8.0' +gem 'railties' +gem 'actionpack' gem 'sentry-ruby', path: Pathname(__dir__).join("../../..").realpath gem 'sentry-rails', path: Pathname(__dir__).join("../../..").realpath From cb3951403db57555ae1a5d81d257b711313bb157 Mon Sep 17 00:00:00 2001 From: Peter Solnica Date: Thu, 21 Aug 2025 10:01:26 +0000 Subject: [PATCH 3/5] [.devcontainer] add libsqlite3-dev Needed by sqlite3 1.4.0 gem --- .devcontainer/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9871a2679..e98e0ffff 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libffi-dev \ libgdbm-dev \ sqlite3 \ + libsqlite3-dev \ nodejs \ npm \ chromium \ From 9d021a79ad6823173ad726973faad522c6f39d2a Mon Sep 17 00:00:00 2001 From: Peter Solnica Date: Thu, 21 Aug 2025 10:04:08 +0000 Subject: [PATCH 4/5] [.devcontainer] fix git command for older git --- .devcontainer/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/run b/.devcontainer/run index ed22b3403..ae646c8c1 100755 --- a/.devcontainer/run +++ b/.devcontainer/run @@ -7,8 +7,8 @@ cd /workspace/sentry sudo mkdir -p vendor/gems sudo chown -R sentry:sentry vendor/gems -git config --global --add safe.directory /workspace/sentry -git config --global --add safe.directory /workspace/sentry/vendor/gems/* +git config --global safe.directory /workspace/sentry +git config --global safe.directory /workspace/sentry/vendor/gems/* sudo chown -R sentry:sentry . From 701ef318c5f182c40219bce46baaf63d94ace645 Mon Sep 17 00:00:00 2001 From: Peter Solnica Date: Thu, 21 Aug 2025 10:04:33 +0000 Subject: [PATCH 5/5] [.devcontainer] make it work under ancient rubies Notice that it now removes locks, a cleaner solution would be to go multi-lock - and I tried - and then gave up due to time constraints. Something to revisit in the future. --- .devcontainer/setup | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.devcontainer/setup b/.devcontainer/setup index 177502732..9789d999f 100755 --- a/.devcontainer/setup +++ b/.devcontainer/setup @@ -35,6 +35,7 @@ class SetupScript if should_run_bundle? cleanup_ruby_lsp_directories + update_rubygems_and_bundler install_bundle_dependencies install_foreman_gem if @options[:with_foreman] end @@ -121,7 +122,8 @@ class SetupScript if Dir.exist?(folder_path) && File.exist?(gemfile_path) Dir.chdir(folder_path) do puts " Installing dependencies for #{folder_path}..." - unless system('bundle install') + + unless system("[ -f Gemfile.lock ] && rm Gemfile.lock; bundle install") puts "❌ Bundle install failed for #{folder}" exit 1 end @@ -134,6 +136,28 @@ class SetupScript end end + def update_rubygems_and_bundler + puts "📦 Updating RubyGems and Bundler..." + + if RUBY_VERSION >= "3.0" + unless system("sudo gem update --system --silent") + puts "❌ RubyGems update failed" + exit 1 + end + else + unless system("sudo gem update --silent --system 3.4.22") + puts "❌ RubyGems update failed" + exit 1 + end + + # sentry-sidekiq does not bundle with Bundler 2.5.x that ships with RubyGems 3.4.22 + unless system("sudo gem install bundler -v 2.4.22") + puts "❌ Bundler installation failed" + exit 1 + end + end + end + def install_foreman_gem unless system('gem install foreman') puts "❌ Foreman gem installation failed"