Ask A Question

Notifications

You’re not receiving notifications from this thread.

Bundler And PG Error On Deployment

Damian Nelwep asked in Rails

Hi, I followed every step of the deployment but when I get to 'cap production deploy', some errors appear :

01 /home/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:319:in `check_for_activated_spec!'
      01 :
      01 You have already activated bundler 1.17.2, but your Gemfile requires bundler 1.17.3. Since bundler is a default gem, you can either remove your depe…
      01  (
      01 Gem::LoadError
      01 )

It seems like I have a conflict between bundler versions. I tried many things but not one seems to work fine.

Also I get some errors about PostGres connection. If someone could tell me where this can come from, It'd really help!

01 rake aborted!
      01 PG::ConnectionBad: could not connect to server: Connection timed out
      01    Is the server running on host "1.2.3.4" and accepting
      01    TCP/IP connections on port 5432?
      01 /home/deploy/meaw/shared/bundle/ruby/2.6.0/gems/pg-0.18.4/lib/pg.rb:45:in `initialize'
      01 /home/deploy/meaw/shared/bundle/ruby/2.6.0/gems/pg-0.18.4/lib/pg.rb:45:in `new'
      01 /home/deploy/meaw/shared/bundle/ruby/2.6.0/gems/pg-0.18.4/lib/pg.rb:45:in `connect'

Thank you very much in advance and have a sweet day :)

Reply

It says the host IP address is "1.2.3.4" so that looks like a misconfiguration in your deploy.rb or the development/production.rb file

Reply

No I've just replaced it myself but it display it correctly !

Don't you think I have to setup bundle properly ?

Reply

I've solved this before by just logging into the server and updating the gems, then trying to deploy.

Reply

I've done it but nothing have changed and I get the same error messages .. :(

gem update

isn't it ?

Reply

No, you need to gem update --system to update bundler. The bundler message is not an error, it's just a warning. I get this often but everything works. I think your Gem::LoadError is something else like mismatched ruby versions.

Your post shows Ruby 2.6.1, is that the same version that's installed on your local machine? Have you also set it in the gem file by adding ruby 2.6.1 and have you also created a .ruby-version file and added ruby-2-6-1 to make everything match?

The Postgres error looks like the service isn't running on the server. You can check the status by running sudo service postgresql status on the server. It should print out a bunch of lines, one will say something like 'Active: active (exited) since Tue 2019-06-25 18:12:36 UTC; 1 months 21 days ago'

Reply

Hello Seth, I just saw your answer.

First of all thank you for taking some time to help me.

I did gem update --system on me local machine and my deploy server as well
I put in the Gemfile ruby "2.6.1" and also ruby-2-6-1 but when I type ruby -v I get
rbenv: version "ruby-2-6-1" is not installed

About Postgres, it says what it should, and is active.

Thank you

Reply

Typo on my part, it should be ruby-2.6,1 should go into a .ruby-version file.

You are only using rbenv or rvm and not both at the same time, correct?

Reply

Yes rbenv and no rvm installed ! Trying what you told me... and I get this error message when deploying :

01 You are trying to install in deployment mode after changing
      01 your Gemfile. Run `bundle install` elsewhere and add the
      01 updated Gemfile.lock to version control.
      01
      01 Bundler is unlocking ruby
      01
      01 You have added to the Gemfile:
      01 * source: git://github.com/rails/rails.git (at master)
      01 * rails
      01
      01 You have deleted from the Gemfile:
      01 * rails (~> 5.1.6)

Anyway thanks for the tip I don't get the same message as before

Reply

You might get the same error message as before until you run bundle install

Since it looks like you're also upgrading your rails version, I highly suggest you stick with the version you had and figure out why bundler is having an issue. I've had a few situations where the bundler version gets stuck on the previous version. When I run bundler -v I actually get Bundler version 2.02. Just make sure what you see on your local machine matches what appears on your server.

Reply

On my deploy server I get Bundler version 2.0.2 whereas the version on my local machine is Bundler version 1.17.3 . How can I downgrade the server version ? I already tried some things before but without much success...

About rails, I'm not trying to upgrade it so I really don't get why it is displaying this error message... Anyway do you think it would be a good idea to upgrade rails ? Also upgrade bundler on my local machine would seem to be a good solution ?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.