0

I am working with a friend on a small Rails app to continue learning Rails, and I cloned his GitHub repository on my old laptop.

When I migrated everything to my new laptop the next day, I was forced to add a 1 at the end of my laptop user account, and for some reason this is showing up when I try to work on the app in the new laptop (specifically after running rails db:migrate):

ActiveRecord::ConnectionNotEstablished: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "my_laptop_name1" does not exist

I understand the new laptop is at the heart of the issue, I just can't figure out how/why.

I have tried many StackOverflow solutions (here, here, here) but am not having much luck anywhere.

AmandaBP
  • 5
  • 2

1 Answers1

1

In the process of installing Postgres on your old laptop, a Postgres role was created that matches your shell login username. (Postgres uses the word "role" to mean what we think of as "user" - the person logging in)

In your new laptop Postgres doesn't have this role.

Things to check:

  • if you installed Postgres on your new machine before you changed the username, maybe the old username exists as a role inside Postgres
  • You can specify a user to psql using psql -U my_laptop_name (if you leave the -U off, postgres assumes that the role name is the same as your shell login name)
  • if that works, you can change your db/config.yml to use the old role name
  • if you want your database role/user name to be something else you can use the postgres cli, something like: sudo -u postgres createuser <username>
iftheshoefritz
  • 5,829
  • 2
  • 34
  • 41