我如何设置heroku postgresql应用程序的路径?

时间:2021-08-21 23:06:28

I just installed the heroku PSQL app (v1.0) and i'm having trouble being able to connect my rails apps using the gem pg "0.1.4". I already added the path PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" to my .profile and my .bashrc files, but nothing seems to allow me to run psql simply by calling "psql". I had success using "psql -h localhost". When i go for "psql" i get:

我刚刚安装了heroku PSQL应用程序(v1.0),我无法使用gem pg“0.1.4”连接我的rails应用程序。我已经将路径PATH =“/ Applications / Postgres.app / Contents / MacOS / bin:$ PATH”添加到我的.profile和我的.bashrc文件中,但似乎没有任何东西允许我只是通过调用“psql”来运行psql。我成功使用“psql -h localhost”。当我选择“psql”时,我得到:

Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

I'm using mountain lion.

我正在使用山狮。

4 个解决方案

#1


12  

Still pretty sure that both of the existing answers are answering the wrong question. The author mentions right in the title that he is having trouble with PATH, not connecting to his DB or configuring rails. This is the situation I got into, and this is my solution.

仍然很确定现有的两个答案都回答了错误的问题。作者在标题中提到他在使用PATH时遇到问题,没有连接到他的数据库或配置rails。这是我遇到的情况,这是我的解决方案。

After getting postgres.app running and setting PATH in my .bashrc file as directed in the postgress.app documentation - http://postgresapp.com/documentation :

在postgres.app运行并按照postgress.app文档中的指示在我的.bashrc文件中设置PATH之后 - http://postgresapp.com/documentation:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

The problem was that this path setting was not taking effect after restarting terminal.app - running which psql was returning the copy in "/usr/bin/psql", this is the copy that comes installed with Lion and Mountain Lion, not the new version installed in "/Applications/". It even says in the Postgres.app instructions "run which psql to tell that the correct version is being loaded".

问题是这个路径设置在重新启动terminal.app后没有生效 - 运行哪个psql在“/ usr / bin / psql”中返回副本,这是与Lion和Mountain Lion一起安装的副本,而不是新的版本安装在“/ Applications /”中。它甚至在Postgres.app指令中说“运行哪个psql告诉正在加载正确的版本”。

Anyway - the odd thing I found was that after I ran:

无论如何 - 我发现奇怪的事情是我跑了之后:

source .bashrc

Then the command "which psql" would return the correct version located in /Applications/.

然后命令“which psql”将返回位于/ ​​Applications /中的正确版本。

At this point I was stumped and had to get some extra help. The guys I tapped also thought it was quite odd too, however they quickly found out that neither the .bashrc OR the .profile files were being loaded. This is very strange, I have not seen this on any of my other macs running leopard through lion.

在这一点上,我感到难过,不得不得到一些额外的帮助。我点击的那些人也认为这也很奇怪,但他们很快就发现.bashrc或.profile文件都没有被加载。这很奇怪,我没有在任何通过狮子跑狮子的其他mac上看到这个。

Now finally the solution- I am not sure this is proper, but it did permanently fix my problem. We found that their was one profile file being loaded into the terminal - the .bash_login file. In the end the solution was just to use the .bash_login to source the .bashrc file. Here is the edit to .bash_login:

现在终于解决了 - 我不确定这是否合适,但它确实永久地解决了我的问题。我们发现他们是一个加载到终端的配置文件 - .bash_login文件。最后,解决方案只是使用.bash_login来获取.bashrc文件。这是对.bash_login的编辑:

source $HOME/.bashrc

And that did it.

这样做了。

Anyway I can't say that this is exactly the fix that diego needed / was looking for, but it is definitely the problem for me.

无论如何,我不能说这正是diego需要/正在寻找的解决方案,但对我来说这绝对是个问题。

#2


4  

You'll need to add host:localhost to any database configuration you're using in your development environment (read development / test/ production / etc):

您需要将host:localhost添加到您在开发环境中使用的任何数据库配置(阅读开发/测试/生产/等):

config/database.yml

配置/ database.yml的

development:
  adapter: postgresql
  encoding: unicode
  database: my_awesome_app_development
  pool: 5
  host: localhost
  username: my_awesome_app_development
  password:

Edit: also see Repairing Postgresql after upgrading to OSX 10.7 Lion

编辑:还可以在升级到OSX 10.7 Lion后看到修复Postgresql

#3


2  

I know this is an old question but I just had the same problem. The issue is that there is a typo in the documentation. The app is Postgres93.app, not Postgres.app, so the path should have Postgres93.app:

我知道这是一个老问题,但我遇到了同样的问题。问题是文档中存在拼写错误。该应用程序是Postgres93.app,而不是Postgres.app,所以路径应该有Postgres93.app:

PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"

PATH = “/应用/ Postgres93.app /内容/ MacOS的/ bin中:$ PATH”

It's amazing how many posts there are about this and the typo doesn't seem to have been noticed yet. Changing that was all it took to get psql and which psql to work correctly for me.

令人惊讶的是,有多少关于此的帖子,而且错字似乎还没有被注意到。改变这就是获取psql以及哪个psql正常工作所需的全部内容。

#4


1  

Your PATH might be wrong. 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

你的PATH可能是错的。要查找psql脚本的PATH(在mac上),请在Applications / Postgres安装中从finder中打开sql shell脚本。这将为您提供有关安装位置的提示。这打开了一个窗口,告诉我它位于这里:/ 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"

然后,我通过输入以下内容从终端窗口设置PATH变量:$ PATH =“/ Library / PostgreSQL / 8.4 / bin:$ PATH”

#1


12  

Still pretty sure that both of the existing answers are answering the wrong question. The author mentions right in the title that he is having trouble with PATH, not connecting to his DB or configuring rails. This is the situation I got into, and this is my solution.

仍然很确定现有的两个答案都回答了错误的问题。作者在标题中提到他在使用PATH时遇到问题,没有连接到他的数据库或配置rails。这是我遇到的情况,这是我的解决方案。

After getting postgres.app running and setting PATH in my .bashrc file as directed in the postgress.app documentation - http://postgresapp.com/documentation :

在postgres.app运行并按照postgress.app文档中的指示在我的.bashrc文件中设置PATH之后 - http://postgresapp.com/documentation:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

The problem was that this path setting was not taking effect after restarting terminal.app - running which psql was returning the copy in "/usr/bin/psql", this is the copy that comes installed with Lion and Mountain Lion, not the new version installed in "/Applications/". It even says in the Postgres.app instructions "run which psql to tell that the correct version is being loaded".

问题是这个路径设置在重新启动terminal.app后没有生效 - 运行哪个psql在“/ usr / bin / psql”中返回副本,这是与Lion和Mountain Lion一起安装的副本,而不是新的版本安装在“/ Applications /”中。它甚至在Postgres.app指令中说“运行哪个psql告诉正在加载正确的版本”。

Anyway - the odd thing I found was that after I ran:

无论如何 - 我发现奇怪的事情是我跑了之后:

source .bashrc

Then the command "which psql" would return the correct version located in /Applications/.

然后命令“which psql”将返回位于/ ​​Applications /中的正确版本。

At this point I was stumped and had to get some extra help. The guys I tapped also thought it was quite odd too, however they quickly found out that neither the .bashrc OR the .profile files were being loaded. This is very strange, I have not seen this on any of my other macs running leopard through lion.

在这一点上,我感到难过,不得不得到一些额外的帮助。我点击的那些人也认为这也很奇怪,但他们很快就发现.bashrc或.profile文件都没有被加载。这很奇怪,我没有在任何通过狮子跑狮子的其他mac上看到这个。

Now finally the solution- I am not sure this is proper, but it did permanently fix my problem. We found that their was one profile file being loaded into the terminal - the .bash_login file. In the end the solution was just to use the .bash_login to source the .bashrc file. Here is the edit to .bash_login:

现在终于解决了 - 我不确定这是否合适,但它确实永久地解决了我的问题。我们发现他们是一个加载到终端的配置文件 - .bash_login文件。最后,解决方案只是使用.bash_login来获取.bashrc文件。这是对.bash_login的编辑:

source $HOME/.bashrc

And that did it.

这样做了。

Anyway I can't say that this is exactly the fix that diego needed / was looking for, but it is definitely the problem for me.

无论如何,我不能说这正是diego需要/正在寻找的解决方案,但对我来说这绝对是个问题。

#2


4  

You'll need to add host:localhost to any database configuration you're using in your development environment (read development / test/ production / etc):

您需要将host:localhost添加到您在开发环境中使用的任何数据库配置(阅读开发/测试/生产/等):

config/database.yml

配置/ database.yml的

development:
  adapter: postgresql
  encoding: unicode
  database: my_awesome_app_development
  pool: 5
  host: localhost
  username: my_awesome_app_development
  password:

Edit: also see Repairing Postgresql after upgrading to OSX 10.7 Lion

编辑:还可以在升级到OSX 10.7 Lion后看到修复Postgresql

#3


2  

I know this is an old question but I just had the same problem. The issue is that there is a typo in the documentation. The app is Postgres93.app, not Postgres.app, so the path should have Postgres93.app:

我知道这是一个老问题,但我遇到了同样的问题。问题是文档中存在拼写错误。该应用程序是Postgres93.app,而不是Postgres.app,所以路径应该有Postgres93.app:

PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"

PATH = “/应用/ Postgres93.app /内容/ MacOS的/ bin中:$ PATH”

It's amazing how many posts there are about this and the typo doesn't seem to have been noticed yet. Changing that was all it took to get psql and which psql to work correctly for me.

令人惊讶的是,有多少关于此的帖子,而且错字似乎还没有被注意到。改变这就是获取psql以及哪个psql正常工作所需的全部内容。

#4


1  

Your PATH might be wrong. 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

你的PATH可能是错的。要查找psql脚本的PATH(在mac上),请在Applications / Postgres安装中从finder中打开sql shell脚本。这将为您提供有关安装位置的提示。这打开了一个窗口,告诉我它位于这里:/ 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"

然后,我通过输入以下内容从终端窗口设置PATH变量:$ PATH =“/ Library / PostgreSQL / 8.4 / bin:$ PATH”