Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/run
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand Down
26 changes: 25 additions & 1 deletion .devcontainer/setup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
14 changes: 12 additions & 2 deletions sentry-rails/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Rails Version Selection Fails on Ruby 2.3

When RAILS_VERSION isn't set and the Ruby version is below 2.4, the rails_version selection logic returns nil. This causes Gem::Version.new to raise an exception when attempting to parse the nil value.

Fix in Cursor Fix in Web

rails_version = Gem::Version.new(rails_version)

gem "rails", "~> #{rails_version}"
Expand Down
4 changes: 2 additions & 2 deletions spec/apps/rails-mini/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading