Ruby on Rails / PostgreSQL

编程入门 行业动态 更新时间:2024-10-19 00:23:04
本文介绍了Ruby on Rails / PostgreSQL-启动服务器时未加载库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Heyo。如果这个问题已经在其他主题中得到解答,我谨此致歉。我搜索了整个网站,但没有找到答案。但是,最接近的相关问题是 Ruby在Rails / PostgreSQL上-启动服务器libq.5.dylib 时出现库未加载错误,但此问题从未得到解决,答案也无济于事。

Heyo. I apologize in advance if this question has been answered in another thread. I've searched through the site but I didn't find an answer. However, the closest related issue was Ruby on Rails / PostgreSQL - Library not Loaded error when starting server- libq.5.dylib, but it was never resolved, and the answer doesn't help me.

我试图让PostgreSQL在Mac OSX 10.6.8上运行。我已经安装了Ruby 1.9.3p392和Rails 3.2.13。

I'm trying to get PostgreSQL running on my Mac OSX 10.6.8. I already have Ruby 1.9.3p392 and Rails 3.2.13 installed.

由于我已经安装了10.6.8,而PostGresApp需要10.7+,因此我尝试使用该手册安装PG安装程序(v9.2.3)可以在这里找到: www.enterprisedb/products -services-training / pgdownload

Since I've 10.6.8, and PostGresApp requires 10.7+, I tried installing PG using the manual installer (v9.2.3) available here: www.enterprisedb/products-services-training/pgdownload

我首先将其安装到默认路径:/Library/PostgreSQL/9.2/。然后我安装了pg gem( PATH = $ PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg )。当我尝试使用 rails s 启动本地主机时,出现以下错误。

I first installed it to its default path at: /Library/PostgreSQL/9.2/. I then installed the pg gem (PATH=$PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg). When I tried rails s to launch my localhost, I got the error below.

经过一番阅读,我猜可能是路径错误,所以我删除了pg gem,然后使用了postgresql卸载程序。然后,我将pg重新安装在/users/stewartmccoy/Library/PostgreSQL/9.2 / ...中,然后重新安装pg gem。但是我仍然遇到同样的错误。

After some reading, I guessed it might be a path error, so I removed the pg gem, and then used the postgresql uninstaller. I then reinstalled pg in /users/stewartmccoy/Library/PostgreSQL/9.2/...and then reinstalled the pg gem. But I still get the same error.

关于如何正确安装PostgreSQL并使Rails服务器运行的任何想法?

Any thoughts on how I might correctly install PostgreSQL and get my rails server running?

stewart-mccoys-macbook:footy_subs stewartmccoy$ rails s /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `require': dlopen(/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError) Referenced from: /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle Reason: image not found - /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler.rb:132:in `require' from /Users/stewartmccoy/Code/footy_subs/config/application.rb:13:in `<top (required)>' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' stewart-mccoys-macbook:footy_subs stewartmccoy$ gem uninstall pgSuccessfully uninstalled pg-0.14.1 stewart-mccoys-macbook:footy_subs stewartmccoy$ PATH=$PATH:/users/stewartmccoy/Library/PostgreSQL/9.2/bin sudo gem install pg Password: Fetching: pg-0.14.1.gem (100%) Building native extensions. This could take a while... Successfully installed pg-0.14.1 1 gem installed Installing ri documentation for pg-0.14.1... Installing RDoc documentation for pg-0.14.1... stewart-mccoys-macbook:footy_subs stewartmccoy$ rails s /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `require': dlopen(/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError) Referenced from: /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle Reason: image not found - /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.3.4/lib/bundler.rb:132:in `require' from /Users/stewartmccoy/Code/footy_subs/config/application.rb:13:in `<top (required)>' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap' from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>'

推荐答案

错误的关键部分是:

Library not loaded: libpq.5.dylib (LoadError)

这表明ruby在运行时找不到 libpq 。为了解决这个问题,您可能应该将 DYLD_LIBRARY_PATH 环境变量设置为指向PostgreSQL安装的 lib 目录(全局)或用于启动Rails的包装脚本中。有关更多信息,请参见此超级用户问题。

This suggests that ruby can't find libpq at runtime. To address that you should probably set the DYLD_LIBRARY_PATH environment variable to point to the lib directory of your PostgreSQL install, either globally or in a wrapper script you use to start Rails. See this superuser question for some more info.

The Pg gem可以在编译和安装过程中找到该库,因为 pg_config 可执行文件位于 PATH ,并使用它来找到 libpq 。似乎它不存储在运行时使用的路径,因此您必须自己设置运行时动态链接器。

The Pg gem can find the library during compilation and installation because the pg_config executable is on the PATH and it uses that to find libpq. It appears that it doesn't store the path for use at runtime so you have to set the runtime dynamic linker up yourself.

一个简单的包装器脚本(如果您不这样做)不想修改您的全球环境)就像这样:

A simple wrapper script (in case you don't want to modify your global environment) is something like:

#!/bin/bash export DYLD_LIBRARY_PATH=/path/to/pg/lib exec rails "$@"

$ @基本上是指将所有参数传递给此脚本,就像它们直接传递给此处一样。它保留正确的引用,从本质上讲意味着rails命令不能告诉您没有直接运行它。

The "$@" basically means "pass all arguments to this script through as if they were passed here directly". It preserves quoting correctly and essentially means that the rails command can't tell you didn't run it directly.

更多推荐

Ruby on Rails / PostgreSQL

本文发布于:2023-10-24 14:22:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524166.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Ruby   Rails   PostgreSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!