title: There was an error while trying to load the gem 'pg'
body: <p>I'm trying to update my old project to new rails version and I have this error when I'm trying to run it as debug in local</p>
  
  <p>As you can see above I'm using Windows. The project now have the ruby version ruby-2.4.4-p296</p>
  
  <p>I tried to reinstall the gem and run bundle install / update but it doesn't work...</p>
  
  <p>Any help is appreciated. Thanks in advance</p>
  
  <p>Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails'
  # Use postgresql as the database for Active Record
  gem 'pg', '0.20.0'
  gem 'bootstrap-sass', '~&gt; 3.3.7'
  gem 'font-awesome-rails', '4.7.0.1'
  
  #gem 'puma'
  
  # Use SCSS for stylesheets
  gem 'sass-rails', '~&gt; 5.0.4'
  
  gem 'simple_form'
  
  #https://github.com/mileszs/wicked_pdf
  gem 'wicked_pdf'
  
  gem 'newrelic_rpm'
  gem 'wkhtmltopdf-heroku'
  
  # Use Uglifier as compressor for JavaScript assets
  gem 'uglifier', '&gt;= 1.3.0'
  
  # Use CoffeeScript for .js.coffee assets and views
  gem 'coffee-rails', '~&gt; 4.0.0'
  
  gem 'nokogiri', '~&gt; 1.8.2'
  
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', platforms: :ruby
  
  # Turbolinks makes following links in your web application faster. Read more:   https://github.com/rails/turbolinks
  gem 'turbolinks'
  
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  gem 'jbuilder', '~&gt; 1.2'
  
  
  group :doc do
      # bundle exec rake doc:rails generates the API under doc/api.
      gem 'sdoc', require: false
  end
  
  group :development, :test do
      # Call 'byebug' anywhere in the code to stop execution and get a debugger console
      #gem install rdoc -v '6.0.4'gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  end
  
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
  
  Fast Debugger (ruby-debug-ide 0.6.1.beta2, debase 0.2.2, file filtering is supported) listens on 0.0.0.0:3970
  Uncaught exception: There was an error while trying to load the gem 'pg'.
  Gem Load Error is: undefined method `add_dll_directory' for RubyInstaller:Module
  Backtrace for gem load error is:
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/pg-0.20.0-x64-mingw32/lib/pg.rb:14:in `block in &lt;top (required)&gt;'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/pg-0.20.0-x64-mingw32/lib/pg.rb:24:in `rescue in &lt;top (required)&gt;'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/pg-0.20.0-x64-mingw32/lib/pg.rb:3:in `&lt;top (required)&gt;'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:81:in `require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:76:in `each'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:76:in `block in require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:65:in `each'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:65:in `require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler.rb:114:in `require'
  C:/Users/Adrian/RubymineProjects/peluqueria-inspinia/config/application.rb:7:in `&lt;top (required)&gt;'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:78:in `require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:78:in `block in server'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `tap'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `server'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `&lt;top (required)&gt;'
  C:/Users/Adrian/RubymineProjects/peluqueria-inspinia/bin/rails:4:in `require'
  C:/Users/Adrian/RubymineProjects/peluqueria-inspinia/bin/rails:4:in `&lt;top (required)&gt;'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-debug-ide-0.6.1.beta2/lib/ruby-debug-ide.rb:88:in `debug_load'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-debug-ide-0.6.1.beta2/lib/ruby-debug-ide.rb:88:in `debug_program'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby-debug-ide-0.6.1.beta2/bin/rdebug-ide:130:in `&lt;top (required)&gt;' -e:1:in `load'-e:1:in `&lt;main&gt;'
  </code></pre>
  
  <p>Bundler Error Backtrace:</p>
  
  <pre><code>C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:80:in `block (2 levels) in require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:76:in `each'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:76:in `block in require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:65:in `each'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler/runtime.rb:65:in `require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.17.0.pre.1/lib/bundler.rb:114:in `require'
  C:/Users/Adrian/RubymineProjects/peluqueria-inspinia/config/application.rb:7:in `&lt;top (required)&gt;'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:78:in `require'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:78:in `block in server'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `tap'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:75:in `server'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `&lt;top (required)&gt;'
  C:/Users/Adrian/RubymineProjects/peluqueria-inspinia/bin/rails:4:in `require'
  C:/Users/Adrian/RubymineProjects/peluqueria-inspinia/bin/rails:4:in `&lt;top (required)&gt;'
  </code></pre>
  
  <p>Process finished with exit code 0</p>
  
  <p>I think the problem is the version of the gem 'pg' but I don't know what version I should put</p>