0

A while ago I created a Ruby on Rails project with a postgres database. It was originally created on a macbook where I had set up a working production and test environment. Unfortunately, this computer has died and now I have to continue working on the same project using the only machine I have: a Windows 10 laptop.

I have been following these guides to set up a viable rails environment on my windows 10 pc: https://medium.com/@colinrubbert/installing-ruby-on-rails-in-windows-10-w-bash-postgresql-e48e55954fbf

https://gorails.com/setup/windows/10

I have installed bash/ubuntu successfully. I have installed git successfully. I have installed ruby successfully. I have installed all the pre-requisite gems so that I can run bundle install successfully. When I get to postgres, as suggested by both tutorials, I install it via windows instead of installing it by terminal. With Postgres 9.6 installed and running as a windows service, I'm unable to enter psql in the terminal. I get this error:

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Additionally, here are the errors that appear when I attempt to do something with rake db commands:

FATAL: role "xxx" does not exist Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"YelpClone_development", "host"=>"localhost"} rake aborted! ActiveRecord::NoDatabaseError: FATAL: role "xxx" does not exist

'xxx' above is my username. I'm not sure if its the username from my old mac or on my new windows machine. I've attempted to edit the database.yml inside my rails project but that gets the same results.

Looking at this topic about the role error, I attempted to use the command "sudo -u postgres -i" which results in another error:

sudo: setresuid() [1000, 112, 1000] -> [-1, 0, -1]: Operation not permitted sudo: unable to set runas group vector: Operation not permitted sudo: unable to mkdir /var/run/sudo: Permission denied [sudo] password for xxx: sudo: PERM_ROOT: setresuid(0, -1, 0): Operation not permitted xxx is not in the sudoers file. This incident will be reported.

Once again 'xxx' is my username. Now I'm beginning to suspect that all this stuff did NOT install correctly. But I'm unsure how I can check. I've tried re-installing postgres about 5-6 times now. Can anyone shed some light on this mess?

1 Answers1

0

I have found a solution to this problem and I thought I would post how I solved it in case anyone else had the same issues:

I followed the instructions found on this page for issues specific to the WSL (Windows subsystem for Linux), specifically posted by user leafofLegend.

The main problem I had was getting stuck on step 7. I had to downgrade my postgres install to 9.3 in order to have PGAdmin 3 instead of 4 as it no longer has editing features for server config. The 2nd issue was being unable to access the ~/.bashrc file. I attempted to open it in atom (via terminal) but it would show me a blank file each time. Alternatively, if I navigated to the file on windows and opened it there, it would become corrupted and not source to the terminal properly. You CANNOT edit linux files using windows tools. Therefore I had to use nano editor to edit the ~./bashrc file as stated in step 9.

The above steps solved the bulk of the problem, which was getting a windows installed PG to be friendly with a WSL terminal. Following the rest of the steps, I'm now able to run rake DB commands and create new dbs.