PG :: UndefinedFile:错误:无法打开扩展控制文件

时间:2015-10-24 03:54:23

标签: ruby-on-rails macos postgresql ruby-on-rails-4 osx-yosemite

升级Postgres后,我尝试迁移数据库时收到以下错误。

enable_extension(:postgis)
  SQL (17.2ms)  CREATE EXTENSION IF NOT EXISTS "postgis"
PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
   (0.3ms)  ROLLBACK
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
PG::UndefinedFile: ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

不确定从哪里开始。大多数其他问题似乎与Linux有关,当我尝试创建符号链接时,它也无效。

2 个答案:

答案 0 :(得分:3)

你应该安装postgresql-9.4-postgis-2.1

答案 1 :(得分:1)

对于 MacOS,使用以下命令安装 postgis 对我有用:

res

对于 Ubuntu,以下命令有效:

brew install postgis