ruby-on-rails – 在Ubuntu 12.04上安装gem pg版本0.12.2时出错

ruby-on-rails – 在Ubuntu 12.04上安装gem pg版本0.12.2时出错,第1张

概述即时通讯在Ubuntu 12.04上运行,我正在尝试在 Ruby 1.9.3p194 / Rails 3.2.3上安装pg gem v’0.12.2′.我已经安装了libpq-dev和build-essential但我仍然得到同样的错误: ERROR: While executing gem ... (Gem::FilePermissionError) You don't have wr 即时通讯在Ubuntu 12.04上运行,我正在尝试在 Ruby 1.9.3p194 / Rails 3.2.3上安装pg gem v’0.12.2′.我已经安装了libpq-dev和build-essential但我仍然得到同样的错误:

ERROR:  While executing gem ... (Gem::filePermissionError)    You don't have write permissions into the /var/lib/gems/1.9.1 directory.fernando@ubuntu:/media/fernando/OS/Rails/oops_booking$sudo gem install pg -v '0.12.2'Building native extensions.  This Could take a while...ERROR:  Error installing pg:    ERROR: Failed to build gem native extension.        /usr/bin/ruby1.9.1 extconf.rbchecking for pg_config... yesUsing config values from /usr/bin/pg_configchecking for libpq-fe.h... yeschecking for libpq/libpq-fs.h... yeschecking for PQconnectdb() in -lpq... yeschecking for PQconnectionUsedPassword()... yeschecking for PQisthreadsafe()... yeschecking for PQprepare()... yeschecking for PQexecParams()... yeschecking for PQescapestring()... yeschecking for PQescapestringConn()... yeschecking for PQgetCancel()... yeschecking for lo_create()... yeschecking for pg_enCoding_to_char()... yeschecking for PQsetClIEntEnCoding()... yeschecking for rb_encdb_alias()... yeschecking for rb_enc_alias()... nochecking for struct pgNotify.extra in libpq-fe.h... yes0checking for unistd.h... yeschecking for ruby/st.h... yescreating extconf.hcreating Makefilemakecompiling compat.ccompiling pg.cpg.c: In function ‘pgconn_wait_for_notify’:pg.c:2117:3: warning: ‘rb_thread_select’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/intern.h:379) [-Wdeprecated-declarations]pg.c: In function ‘pgconn_block’:pg.c:2592:3: error: format not a string literal and no format arguments [-Werror=format-security]pg.c:2598:3: warning: ‘rb_thread_select’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/intern.h:379) [-Wdeprecated-declarations]pg.c:2607:4: error: format not a string literal and no format arguments [-Werror=format-security]pg.c: In function ‘pgconn_locreate’:pg.c:2866:11: warning: variable ‘lo_oID’ set but not used [-Wunused-but-set-variable]pg.c: In function ‘find_or_create_johab’:pg.c:3947:3: warning: implicit declaration of function ‘rb_encdb_alias’ [-Wimplicit-function-declaration]cc1: some warnings being treated as errorsmake: *** [pg.o] Error 1

我确实成功安装了最新版本的pg gem,但我真的需要使用版本0.12.2

提前致谢

解决方法 安装

$sudo apt-get install ruby-dev build-essential

要么

$sudo apt-get install postgresql-clIEnt libpq5 libpq-dev$sudo gem install pg

更新

以下是我遵循的步骤:

安装Postgresql和开发包

$sudo apt-get install postgresql-9.1$sudo apt-get install libpq-dev

设置与我的Ubuntu登录相同的用户

$sudo su postgres -c psqlpostgres=# CREATE RolE <username> SUPERUSER LOGIN;postgres=# \q

修改Gemfile

# Remove gem 'sqlite3'gem 'pg'

修改app目录中的database.yml

development:  adapter: postgresql  enCoding: unicode  database: appname_development  pool: 5  timeout: 5000  username: <username>  password:test:  adapter: postgresql  enCoding: unicode  database: appname_test  pool: 5  timeout: 5000  username: <username>  password:

运行捆绑安装

$bundle install

创建数据库和迁移

$rake db:create:all$rake db:migrate

以下是我过去帮助的来源:
http://mrfrosti.com/2011/11/postgresql-for-ruby-on-rails-on-ubuntu/
http://railsless.blogspot.in/2012/05/howto-install-postgresql-in-ubuntu11.html

总结

以上是内存溢出为你收集整理的ruby-on-rails – 在Ubuntu 12.04上安装gem pg版本0.12.2时出错全部内容,希望文章能够帮你解决ruby-on-rails – 在Ubuntu 12.04上安装gem pg版本0.12.2时出错所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1280966.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存