Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Last active September 2, 2018 17:50
Show Gist options
  • Save JoshCheek/a0d3af7d6dce0450fbfcda3f1aa2cb19 to your computer and use it in GitHub Desktop.
Save JoshCheek/a0d3af7d6dce0450fbfcda3f1aa2cb19 to your computer and use it in GitHub Desktop.
ActiveRecord errors when Bundler isn't loaded and adapter isn't installed

Reporting

  • Reported to Bundler here.
  • Reported to ActiveRecord here.

Usage

$ bash ./run.sh

Output

$ ./run.sh
===== RAILS MASTER WITHOUT BUNDLER =====
  Successfully installed bundler-1.16.4
  1 gem installed
  Using concurrent-ruby 1.0.5
  Using i18n 1.1.0
  Using minitest 5.11.3
  Using thread_safe 0.3.6
  Using tzinfo 1.2.5
  Using activesupport 6.0.0.alpha from https://github.com/rails/rails.git (at master@9b56cbd)
  Using activemodel 6.0.0.alpha from https://github.com/rails/rails.git (at master@9b56cbd)
  Using activerecord 6.0.0.alpha from https://github.com/rails/rails.git (at master@9b56cbd)
  Using bundler 1.16.4
  Bundle complete! 2 Gemfile dependencies, 9 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
  ----- WITHOUT BUNDLER (broken) -----
  {:message=>"wrong number of arguments (given 1, expected 2)",
   :cause_message=>
    "Could not find 'sqlite3' (~> 1.3.6) among 28 total gem(s)\n" +
    "Checked in 'GEM_PATH=/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-master/tmp', execute `gem env` for more information",
   :backtrace=>
    ["/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/errors.rb:28:in `initialize'",
     "/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-master/tmp/bundler/gems/rails-9b56cbd98dc4/activerecord/lib/active_record/connection_adapters/connection_specification.rb:182:in `exception'"],
   :cause_backtrace=>
    ["/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb:310:in `to_specs'",
     "/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb:322:in `to_spec'"],
   :versions=>
    {:activerecord=>"6.0.0.alpha",
     :ruby=>"2.5.1",
     :rubygems=>"2.7.6",
     :bundler=>"not loaded"}}
  ----- WITH BUNDLER (not broken) -----
  {:message=>
    "Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile-master.",
   :cause_message=>
    "sqlite3 is not part of the bundle. Add it to your Gemfile-master.",
   :backtrace=>
    ["/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-master/tmp/gems/bundler-1.16.4/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem'",
     "/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-master/tmp/bundler/gems/rails-9b56cbd98dc4/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:12:in `<top (required)>'"],
   :cause_backtrace=>
    ["/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-master/tmp/gems/bundler-1.16.4/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem'",
     "/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-master/tmp/bundler/gems/rails-9b56cbd98dc4/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:12:in `<top (required)>'"],
   :versions=>
    {:activerecord=>"6.0.0.alpha",
     :ruby=>"2.5.1",
     :rubygems=>"2.7.6",
     :bundler=>"1.16.4"}}
===== Y-YAGI FIXES_32830 =====
  Successfully installed bundler-1.16.4
  1 gem installed
  Using concurrent-ruby 1.0.5
  Using i18n 1.1.0
  Using minitest 5.11.3
  Using thread_safe 0.3.6
  Using tzinfo 1.2.5
  Using activesupport 6.0.0.alpha from https://github.com/y-yagi/rails.git (at fixes_32830@dc6b851)
  Using activemodel 6.0.0.alpha from https://github.com/y-yagi/rails.git (at fixes_32830@dc6b851)
  Using activerecord 6.0.0.alpha from https://github.com/y-yagi/rails.git (at fixes_32830@dc6b851)
  Using bundler 1.16.4
  Bundle complete! 2 Gemfile dependencies, 9 gems now installed.
  Use `bundle info [gemname]` to see where a bundled gem is installed.
  ----- WITHOUT BUNDLER (fixed) -----
  {:message=>
    "Could not load the 'sqlite3' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile or installed.",
   :cause_message=>
    "Could not find 'sqlite3' (~> 1.3.6) among 28 total gem(s)\n" +
    "Checked in 'GEM_PATH=/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-y-yagi/tmp', execute `gem env` for more information",
   :backtrace=>
    ["/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb:310:in `to_specs'",
     "/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb:322:in `to_spec'"],
   :cause_backtrace=>
    ["/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb:310:in `to_specs'",
     "/Users/josh/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/dependency.rb:322:in `to_spec'"],
   :versions=>
    {:activerecord=>"6.0.0.alpha",
     :ruby=>"2.5.1",
     :rubygems=>"2.7.6",
     :bundler=>"not loaded"}}
  ----- WITH BUNDLER (not broken) -----
  {:message=>
    "Could not load the 'sqlite3' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile or installed.",
   :cause_message=>
    "sqlite3 is not part of the bundle. Add it to your Gemfile-y-yagi.",
   :backtrace=>
    ["/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-y-yagi/tmp/gems/bundler-1.16.4/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem'",
     "/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-y-yagi/tmp/bundler/gems/rails-dc6b851b232a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:12:in `<top (required)>'"],
   :cause_backtrace=>
    ["/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-y-yagi/tmp/gems/bundler-1.16.4/lib/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem'",
     "/Users/josh/deleteme/a0d3af7d6dce0450fbfcda3f1aa2cb19/tmp-y-yagi/tmp/bundler/gems/rails-dc6b851b232a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb:12:in `<top (required)>'"],
   :versions=>
    {:activerecord=>"6.0.0.alpha",
     :ruby=>"2.5.1",
     :rubygems=>"2.7.6",
     :bundler=>"1.16.4"}}
require 'active_record'
require 'pp'
# sqlite3 gem is unavailable
begin
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
rescue Exception => e
pp message: e.message,
cause_message: e.cause.message,
backtrace: e.backtrace.take(2),
cause_backtrace: e.cause.backtrace.take(2),
versions: {
activerecord: ActiveRecord::VERSION::STRING,
ruby: RUBY_VERSION,
rubygems: Gem.rubygems_version.to_s,
bundler: defined?(Bundler) ? Bundler::VERSION : 'not loaded',
}
end
source 'https://rubygems.org'
git 'https://github.com/rails/rails.git', branch: 'master' do
gem 'activerecord'
gem 'activesupport'
end
GIT
remote: https://github.com/rails/rails.git
revision: 9b56cbd98dc422976cd59ec9644d670768efdfc2
branch: master
specs:
activemodel (6.0.0.alpha)
activesupport (= 6.0.0.alpha)
activerecord (6.0.0.alpha)
activemodel (= 6.0.0.alpha)
activesupport (= 6.0.0.alpha)
activesupport (6.0.0.alpha)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.0.5)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
activerecord!
activesupport!
BUNDLED WITH
1.16.4
source 'https://rubygems.org'
git 'https://github.com/y-yagi/rails.git', branch: 'fixes_32830' do
gem 'activerecord'
gem 'activesupport'
end
GIT
remote: https://github.com/y-yagi/rails.git
revision: dc6b851b232a779e1aebbbb5cd1b5fe28a78b283
branch: fixes_32830
specs:
activemodel (6.0.0.alpha)
activesupport (= 6.0.0.alpha)
activerecord (6.0.0.alpha)
activemodel (= 6.0.0.alpha)
activesupport (= 6.0.0.alpha)
activesupport (6.0.0.alpha)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.0.5)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
activerecord!
activesupport!
BUNDLED WITH
1.16.4
#!/usr/bin/env bash
cd "$(dirname "$0")"
setup() {
dir="$1"
mkdir -p "$dir"
export HOME="$dir"
export GEM_HOME="$dir/tmp"
export GEM_PATH="$dir/tmp"
export GEM_ROOT="$dir/tmp"
export PATH="$dir/tmp/bin:$PATH"
gem install bundler --no-ri --no-rdoc
bundle install
}
=====() {
echo -e '\033[35m===== '"$@"' =====\033[0m'
}
-----() {
echo -e '\033[34m----- '"$@"' -----\033[0m'
}
===== RAILS MASTER WITHOUT BUNDLER
( export BUNDLE_GEMFILE="$PWD/Gemfile-master"
setup "$PWD/tmp-master"
----- 'WITHOUT BUNDLER (broken)'
load_path=`bundle exec ruby -e 'print $LOAD_PATH.join(":")'`
ruby -I "$load_path" error.rb
----- 'WITH BUNDLER (not broken)'
bundle exec ruby error.rb
) | sed 's/^/ /'
===== Y-YAGI FIXES_32830
( export BUNDLE_GEMFILE="$PWD/Gemfile-y-yagi"
setup "$PWD/tmp-y-yagi"
----- 'WITHOUT BUNDLER (fixed)'
load_path=`bundle exec ruby -e 'print $LOAD_PATH.join(":")'`
ruby -I "$load_path" error.rb
----- 'WITH BUNDLER (not broken)'
bundle exec ruby error.rb
) | sed 's/^/ /'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment