我正在尝试安装 Postgresql,以便与使用 postgres 的现有 Ruby on Rails 项目一起工作。但是,每次我$ rails s
在项目目录中运行以启动本地服务器时,都会收到此错误。
=> Booting Thin
=> Rails 3.2.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load':
/Users/******/Documents/Jellyfish/config/initializers/session_store.rb:3: syntax
error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_Jellyfish_session'
^
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:245:in `load'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:588
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:587:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/engine.rb:587
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `run_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/******/Documents/Jellyfish/config/environment.rb:5
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /Users/******/Documents/Jellyfish/config.ru:3
from /opt/local/lib/ruby/gems/1.8/gems/rack-1.4.2/lib/rack/builder.rb:51:in `instance_eval'
from /opt/local/lib/ruby/gems/1.8/gems/rack-1.4.2/lib/rack/builder.rb:51:in `initialize'
from /Users/******/Documents/Jellyfish/config.ru:0:in `new'
from /Users/******/Documents/Jellyfish/config.ru:0
我怀疑这个问题与我的 database.yml 文件中的登录信息或我的 postgres 安装有关。
我已经使用 macports 和 command 安装了 postgres sudo port install postgresql83 postgresql83-server
,并且 gem 同时运行了sudo env ARCHFLAGS="-arch x86_64" gem install pg
和gem install pg -- --with-pg-config=/opt/local/lib/postgresql83/bin/pg_config
.
我在 database.yml 文件中尝试了几种用户名/密码组合,例如我自己的计算机用户名/密码、postgres/空白密码、pg/空白密码、postgres/系统密码,但它们似乎都没有工作。
我能想到的最后一件事是,当我尝试使用
sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'
正如安装程序所建议的,它给了我这个错误:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.
我希望这是足够的信息。我发现了几个人们遇到类似问题的问题,但似乎没有一个解决方案对我有用。非常感谢您阅读本文。