rake db:create throws “database does not exist” error with postgresql

前端 未结 10 902
忘了有多久
忘了有多久 2021-01-30 19:58

I\'m using rails 4.1.5 with postgresql 9.1 under Debian 7, and I\'m not able to create a database in my development environment. When I run

bin/rake db:create
         


        
10条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 20:54

    Rails 4.1 ships with spring preloader, and

    New Rails 4.1 applications will ship with "springified" binstubs. This means that bin/rails and bin/rake will automatically take advantage of preloaded spring environments.

    which means that the "springified" bin/rake will attempt to preload the app, which in turn will attempt to run the initilizers resulting in the problem you're seeing.

    To fix / work around this you want to run the initial setup rake tasks without spring. One way to achieve that is to run it with bundler instead:

    bundle exec rake db:create
    

提交回复
热议问题