Postgres.app升级,现在Rails应用程序不会启动 [英] Postgres.app upgrade, now Rails app won't start

查看:200
本文介绍了Postgres.app升级,现在Rails应用程序不会启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将Postgres.app升级到最新版本(9.2.4.1),现在无法使用Foreman或Rails服务器启动我的Rails应用程序。

/Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg.rb:4:in`require':dlopen(/ Users / memoht / Sites /myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg_ext.bundle,9):未加载库:@executable_path /../ lib / libssl.1.0.0.dylib(LoadError )



引用自:/Applications/Postgres.app/Contents/MacOS/lib/libpq.dylib



原因:找不到图片 - /Users/memoht/Sites/myapp/.gem/ruby/1.9.3/ gems / pg-0.15.1 / lib / pg_ext.bundle







  • 通过 Postgres.app文档查看


  • 从9.2.2.0升级到9.2.4.1不是新的次要版本,因此不应涉及pg_upgrade


  • .bashrc具有正确的设置PATH PATH =/ Applications /Postgres.app/Contents/MacOS/bin:$PATH


  • 卸载并重新安装PG gem。


  • 错误地认为我需要通过自制程序安装PostGIS,但通过Brew自动安装Postgres以及其他一些依赖项。 b $ b



如果我将Postgres.app版本换成9.2.2.0版本,所有工作都会重新开始。由于Postgres.app是一个拖放式安装,为什么从9.2.2.0升级到9.2.4.1造成这种情况?

解决方案

我找到了适用于我的解决方案,并且需要最少的黑客入侵/配置。你只需要这样做一次,它将适用于每个软件包的安装。将以下内容添加到.bash_profile,.bash_rc或同等文件中:

  export DYLD_FALLBACK_LIBRARY_PATH = / Applications / Postgres.app / Contents / MacOS / lib:$ DYLD_LIBRARY_PATH 

(假设您在默认位置安装了Postgres.app)。然后重新启动终端会话并重试。



直接导出到DYLD_LIBRARY_PATH可能会导致其他依赖于它的应用程序出现严重问题,但使用回退路径可避免这些问题。 / p>

另见:



编辑:设置DYLD_FALLBACK_LIBRARY_PATH似乎会导致错误运行psql。为了解决这个问题,你可以在你的.bash_profile文件中添加以下两行:

$ p $ alias psql =(。〜/ .bash_profile ;未设置DYLD_FALLBACK_LIBRARY_PATH; psql);

假设您使用的是bash,而您的.bash_profile位于您的主目录中。如果情况并非如此(或者如果您使用的是.bashrc或其他环境设置而不是.bash_profile),请将命令的〜/ .bash_profile 部分更改为路径到你的环境设置脚本。



别名命令基本上启动了一个不影响当前bash环境的子shell。所以当它解除DYLD_FALLBACK_LIBRARY_PATH变量时,它只是暂时的。在你退出psql之后,环境变量将被重新设置,以便rails正常工作。


I just upgraded my Postgres.app to latest version (9.2.4.1) am now unable to start my Rails app using Foreman or Rails server.

/Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg.rb:4:in `require': dlopen(/Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg_ext.bundle, 9): Library not loaded: @executable_path/../lib/libssl.1.0.0.dylib (LoadError)

Referenced from: /Applications/Postgres.app/Contents/MacOS/lib/libpq.dylib

Reason: image not found - /Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg_ext.bundle


  • Looked through Postgres.app documentation

  • Upgrade from 9.2.2.0 to 9.2.4.1 isn't a new minor release so shouldn't involve pg_upgrade

  • .bashrc has correct setting for PATH PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

  • Uninstalled, and reinstalled PG gem.

  • Made the mistake of thinking I needed to install PostGIS via homebrew, but that automatically installed Postgres via Brew plus a slew of other dependencies.

If I swap out the Postgres.app version back down to 9.2.2.0 everything works again. Since Postgres.app is a drag and drop install, why has upgrading from 9.2.2.0 to 9.2.4.1 caused this?

解决方案

I found a solution that works for me and requires minimal hacking/configuring. You only need to do this once and it will work for every bundle install. Add the following to your .bash_profile, .bash_rc, or equivalent:

export DYLD_FALLBACK_LIBRARY_PATH=/Applications/Postgres.app/Contents/MacOS/lib:$DYLD_LIBRARY_PATH

(Assuming you installed Postgres.app in the default location). Then restart your terminal session and try again.

Exporting to DYLD_LIBRARY_PATH directly can cause serious problems with other apps that depend on it, but using the fallback path avoids these problems.

See also:

EDIT: It seems that setting DYLD_FALLBACK_LIBRARY_PATH causes an error when you try to run psql. To fix this, you can add the following two lines to your .bash_profile:

alias psql="(. ~/.bash_profile; unset DYLD_FALLBACK_LIBRARY_PATH; psql)";

This is assuming that you're using bash and that your .bash_profile is located in your home directory. If that's not the case (or if you're using a .bashrc or other environment setup instead of .bash_profile) change the ~/.bash_profile part of the command to the path to your environment setup script.

The aliased commands basically start a subshell which does not effect your current bash environment. So when it unsets the DYLD_FALLBACK_LIBRARY_PATH variable, it's only temporary. After you exit psql the environment variable will be set again so that rails functions properly.

这篇关于Postgres.app升级,现在Rails应用程序不会启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆