Skip to content

Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1. Make sure all dependencies are added to Gemfile. (LoadError) #529

@lucascaton

Description

@lucascaton

Hi there 👋

I'm updating a gem to support SQLite3 v2 but whenever I use version 2.x, I get the following error:

Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-arm64-darwin. Make sure all dependencies are added to Gemfile. (LoadError)

How to reproduce it:

# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  gem "rails", ">= 7.1"
  # gem "sqlite3", "< 2"
  gem "sqlite3", ">= 2"
end

require "active_record"
# require "sqlite3" # This doesn't seem to make a difference

puts "SQLite3::VERSION: #{SQLite3::VERSION}"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")

Results:

With gem "sqlite3", "< 2":

Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
SQLite3::VERSION: 1.7.3
✅

With gem "sqlite3", ">= 2":

Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
SQLite3::VERSION: 2.0.1
❌
~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/rubygems_integration.rb:237:in `block (2 levels) in replace_gem': Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-arm64-darwin. Make sure all dependencies are added to Gemfile. (LoadError)
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:14:in `<top (required)>'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/connection_handler.rb:333:in `resolve_pool_config'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/connection_handler.rb:134:in `establish_connection'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_handling.rb:53:in `establish_connection'
	from replication.rb:18:in `<main>'
~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/rubygems_integration.rb:237:in `block (2 levels) in replace_gem': can't activate sqlite3 (~> 1.4), already activated sqlite3-2.0.1-arm64-darwin. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:14:in `<top (required)>'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/connection_handler.rb:333:in `resolve_pool_config'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/connection_handler.rb:134:in `establish_connection'
	from ~/.asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3.2/lib/active_record/connection_handling.rb:53:in `establish_connection'
	from replication.rb:18:in `<main>'

Sorry if I missed something obvious and thanks in advance 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions