The local psql command could not be located
Asked Answered
A

12

30

I'm following the instructions found here. When I try to run $ heroku pg:psql or $ heroku pg:psql HEROKU POSTGRESQL_BROWN I recieve the following error message:

! The local psql command could not be located ! For help installing psql, see local-postgresql

I can't find anything useful on the link it gives me (it just links to the instructions I was already using, but further down the page) nor can I find this error anywhere else.

If I've missed anything you need to know to answer this, just let me know. I'm rather new to all this and teaching myself as I go.

Aeromancy answered 22/3, 2013 at 17:4 Comment(2)
Does heroku pg:info output your database information?Vixen
Yes it does. would that information help?Aeromancy
O
31

I had same error even after installing Postgres locally. But after seeing this I saw that "pqsl" was not in the PATH so I then did

PATH=%PATH%;C:\Program Files\PostgreSQL\9.2\bin

which worked for me

Onceover answered 2/5, 2013 at 9:35 Comment(2)
Note: This worked for me too, but I had to close and re-open the PowerShell window and then I typed $Env:Path to see the path and confirm it was there. Then I typed heroku pg:psql at the prompt (within my node-js-getting-started folder) and it worked!Hindquarter
Old question, but as its still not patched worth adding theres a bug in PSQL parsing paths still present: postgresql.org/message-id/…Stadium
A
6

I have since solved this myself. When I ran heroku pg:info it says the version number is 9.1.8, I was locally running 9.2

installing 9.1.8 and ensuring Path pointed to the appropriate folder solved the problem.

Aeromancy answered 22/3, 2013 at 17:4 Comment(2)
Nice, it save my day. Mine is 9.6 vs 10Leanneleanor
nice, this helped to solve my problem, I had 9.5 instead of 10.5Fourflush
E
4

After you change the path, make sure to restart the terminal!

Ellynellynn answered 26/12, 2013 at 4:26 Comment(0)
L
3

Top answer wouldn't work for me oddly, my system would not add the Path via cmd with administrator access (Not sure why).

So check this > Windows key > environment variables > system variables

And add the last line (your version may differ in the path)

enter image description here

Lucarne answered 9/8, 2019 at 17:56 Comment(0)
A
2

Set the PATH. To find out the PATH of your psql script (on mac) open the sql shell script from your finder in Applications/Postgres installation. This will give you a hint as to where it is installed. That opened a window which told me it is located here: /Library/PostgreSQL/8.4/scripts/runpsql.sh

Then, I set the PATH variable from the terminal window by typing:

$ PATH="/Library/PostgreSQL/8.4/bin:$PATH"

(depends on the location of your PostgreSQL installation, find your bin path first, another exp: /usr/local/Cellar/[email protected]/9.6.8/bin)

OR.....

You can also connect to the shell by opening the shell directly from your postgres installation folder. Then enter the credentials. If you don't know the credentials, here is how to find them out:

$ heroku pg:info === HEROKU_POSTGRESQL_RED_URL (DATABASE_URL)

$ heroku pg:credentials HEROKU_POSTGRESQL_RED_URL

Antheridium answered 29/5, 2013 at 12:21 Comment(0)
V
1

Make sure you've installed the toolbelt as psql is installed by default.

However you also need to ensure you've installed a local copy of PostgreSQL; if you don't the toolbelt will be unable to find the native psql client.

Assuming you have installed a local copy of PostgreSQL, make sure you can execute psql from the command line directly (i.e make sure you PATH is set correctly ). If the command does not execute, check your PATH, if it does execute see if you can connect via the PSQL connection string provided in the Heroku control panel. If you can connect reinstall the toolbelt, if you are unable to connect provision another dev database and try again.

If there are still issues, I would suggest contacting Heroku support for assistance after verifying no API issues are listed on the status page located here.

Vixen answered 22/3, 2013 at 17:8 Comment(0)
A
1

I got rid if this annoying message on Windows by adding a path element without the spaces, i.e.

C:\Progra~1\PostgreSQL\9.4\data

instead of

“C:\Program Files\PostgreSQL\9.4\data”

Apportionment answered 5/1, 2017 at 3:24 Comment(0)
S
1

I followed the instructions here: http://www.computerhope.com/issues/ch000549.htm, which worked for me if you prefer to go the point-and-click configuration of the PATH variable.

Sainfoin answered 11/4, 2017 at 23:39 Comment(0)
L
1

This type of error usually appears in the Windows environment, because if you do not update the PATH after installing Postgresql, heroku pg:psql command does not work.

So you need to update your PATH environment variable to add the bin directory of your Postgres installation. The directory will look like this: C:\Program Files\PostgreSQL\<VERSION>\bin. For more information, go to the Heroku in Local setup website:

heroku-postgresql: Local setup

Lassitude answered 1/11, 2017 at 20:23 Comment(0)
U
0

I had the same problem and discovered that Heroku doesn't seem to provision the latest version of PostgreSQL by default. Where the Heroku Getting Started instructions said

heroku addons:create heroku-postgresql:hobby-dev

That provisioned a v10 database for some reason (which you can check by clicking on Heroku Postgres in the Add-ons tab of your dashboard). I deleted that database and provisioned a new database using the --version flag:

heroku addons:create heroku-postgresql:hobby-dev --version 11

As of now, at least, you can find the latest version of Postgres supported by Heroku at this link: https://devcenter.heroku.com/articles/heroku-postgresql#version-support-and-legacy-infrastructure

I'm writing this in early 2019, but according to the PostgreSQL website the next version (12) is "tentatively scheduled" for third quarter of 2019 so if you're reading this in late 2019 potentially the same problem will come up for v12 instead

Upheld answered 7/3, 2019 at 10:37 Comment(0)
F
0

On Mac you can use the following:

export PATH="/Library/PostgreSQL/12/bin/:$PATH"
Firmament answered 16/9, 2020 at 8:49 Comment(0)
P
0

The only solution that I found on Windows:

  1. go to advanced system settings
  2. go to environment variables
  3. select Path variable and click Edit
  4. add a new line and enter your bin directory path (C:\Program Files\PostgreSQL<version>\bin) and click ok
  5. restart your terminal
  6. enter your psql command (heroku pg:psql)
Pail answered 15/8, 2022 at 7:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.