1

我已经尝试了几个小时来正确设置我的本地环境,这样我就可以在本地运行一个应用程序并在它上面工作,但它只是不工作......我已经安装了所有似乎需要的东西,但是为了我的生活我只是无法启动 Rails 服务器。

这是我尝试启动 rails 服务器时返回的代码。有任何想法吗?

localhost:badger user$ rails s

/Users/user/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/pg-0.11.0/lib/pg.rb:4:in `require': cannot load such file -- pg_ext (LoadError)
from /Users/user/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/pg-0.11.0/lib/pg.rb:4:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler 1.1.3/lib/bundler/runtime.rb:68:in `require'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
from /Users/user/badger/config/application.rb:7:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Users/user/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require' 
from script/rails:6:in `main'


现在我要收回这个...

localhost:badger user$ rails s
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:929:in `initialize': FATAL:  password authentication failed for user "edwin" (PGError)

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:929:in `new'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:929:in `connect'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:228:in `initialize'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `new'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `postgresql_connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:237:in `checkout_new_connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:191:in `block (2 levels) in checkout'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `loop'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:187:in `block in checkout'

from /Users/user/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:94:in `connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:317:in `retrieve_connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/associations.rb:1806:in `create_has_and_belongs_to_many_reflection'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/associations.rb:1411:in `has_and_belongs_to_many'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.0.7/lib/active_record/autosave_association.rb:137:in `has_and_belongs_to_many'

from /Users/user/badger/app/models/user.rb:7:in `<class:User>'

from /Users/user/badger/app/models/user.rb:1:in `<top (required)>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:454:in `load'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:454:in `block in load_file'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:453:in `load_file'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:340:in `require_or_load'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:491:in `load_missing_constant'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:183:in `block in const_missing'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:181:in `each'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:181:in `const_missing'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:124:in `block in constantize'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `each'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `constantize'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:528:in `block in <class:Reference>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:538:in `yield'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:538:in `default'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:538:in `get'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/devise-1.4.2/lib/devise/mapping.rb:84:in `to'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/devise-1.4.2/lib/devise/rails/routes.rb:180:in `block in devise_for'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/devise-1.4.2/lib/devise/rails/routes.rb:176:in `each'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/devise-1.4.2/lib/devise/rails/routes.rb:176:in `devise_for'

from /Users/user/badger/config/routes.rb:2:in `block in <top (required)>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:233:in `draw'

from /Users/user/badger/config/routes.rb:1:in `<top (required)>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in `load'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in `block in load'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `block in load_dependency'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:235:in `load'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application.rb:127:in `block in reload_routes!'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application.rb:127:in `each'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application.rb:127:in `reload_routes!'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application.rb:120:in `block in routes_reloader'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/file_update_checker.rb:32:in `call'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application/finisher.rb:51:in `block (2 levels) in <module:Finisher>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application/finisher.rb:52:in `call'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `block in run_initializers'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'

from /Users/user/badger/config/environment.rb:5:in `<top (required)>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `block in require'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `block in load_dependency'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'

from /Users/user/badger/config.ru:3:in `block in <main>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/builder.rb:46:in `instance_eval'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/builder.rb:46:in `initialize'

from /Users/user/badger/config.ru:1:in `new'

from /Users/user/badger/config.ru:1:in `<main>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/builder.rb:35:in `eval'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/builder.rb:35:in `parse_file'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/server.rb:162:in `app'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/server.rb:253:in `wrapped_app'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.2.5/lib/rack/server.rb:204:in `start'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/commands.rb:30:in `block in <top (required)>'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'

from /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'

from script/rails:6:in `require'

from script/rails:6:in `<main>'
4

3 回答 3

1

打开config/database.yml并记下开发数据库连接的用户名。

在您的终端类型createuser #<the username>上,对超级用户说不,对创建数据库说是,对创建角色说不。(不,是,不)。

然后rake db:createrake db:migrate

现在rails s

你应该启动并运行。

于 2012-09-20T22:01:35.673 回答
0

您是否使用 安装了 Gemfile 中列出的所有 gem bundle

于 2012-09-20T09:47:22.140 回答
0

简单的解决方案

sqlite3在开发和pg生产中使用。

#Gemfile
gem 'sqlite3'

group :production do
  gem 'pg'
end
于 2012-09-20T10:34:57.043 回答