error "Undefinded method "load_defaults" " when trying to deploy app on Heroku

It's trying to use /usr/lib gems folder. You can see the gems folders using it:

bundle show --paths

When I had installed all Gems on ./vendor/bundle on my project folder, it worked fine.

bundle install --path vendor/bundle


Well, first I'll apologize for going as far as to having to make a question and finding the solution by myself 20 mins later.

While I'm not sure exactly what was malfunctioning, I did narrow it down to differing versions of Rails and other gems, as I was using old specific versions that said book , railstutorial.org/book , indicated me to use.

What I did was use all the default gems given by the command rails new for my Gemfile, without specifiying versions or anything other than the production group for the pg gem.

Gemfile code that fixed it:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.0'

# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :production do
  gem 'pg'
end


group :development, :test do
  # Use sqlite3 as the database for Active Record
  gem 'sqlite3'
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13.0'
  gem 'selenium-webdriver'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Go to config/application.rb then comment this code config.load_defaults 5.1 out like this: #config.load_defaults 5.1 (insert a "#") or you can just remove this code, but in case you might need this later so it's better to just comment it out.

I had same issue, commented it out and it worked fine.


OK, just try bundle and report the results. If it reports you're missing bundler, then run gem install bundler