2013-04-28 36 views
6

我升級並隨後在OS X Mountain Lion上重新安裝PostGIS & PostgreSQL。當嘗試使用PostGIS的擴展,我收到以下錯誤:PostGIS Homebrew安裝引用舊路徑?

ERROR: could not open extension control file "/usr/local/Cellar/postgresql/ 
9.2.3/share/postgresql/extension/postgis.control": No such file or directory 

看來,PostGIS的(和PostgreSQL以及??)仍然在/postgresql/9.2.3/目錄尋找所需的文件,而不是在/postgresql/9.2.4/目錄。我用自制通過以下命令刪除的PostgreSQL所有先前版本:

brew remove --force postgresql 

可能有人請點我在正確的方向,爲什麼發生此問題? (有什麼地方必須有一個揮之不去的配置文件?)

任何幫助將不勝感激。

回答

1

Homebrew的設計通常會在removeupgrade期間留下用戶可編輯的配置文件和生成的數據文件,以便在版本之間保留它們。聽起來你是對的,這是一個配置文件留下的地方。

/usr/local/etc中沒有postgres的全局配置文件。所以這可能是用戶數據文件。您是否使用以前版本的postgres創建了任何數據庫並在其中使用了postgis擴展?這些數據庫中的配置文件可能指的是舊的postgres版本。這些數據庫通常在/usr/local/var/postgres之下。查看下面的.conf文件,看看是否可以編輯它們來修復擴展路徑或重新創建數據庫。

12

問題是你有一個運行在代碼庫9.2.3版本上的psql服務器。爲了測試這個,加載一個psql控制檯,你應該在頂部看到這個:

psql (9.2.4, server 9.2.3) 
Type "help" for help. 

請注意上面的「server 9.2.3」註釋。如果你正在運行的服務器的正確的版本,你反而會看到這一點:

psql (9.2.4) 
Type "help" for help. 

爲了解決這個問題,只要按照brew info postgresql上卸載給出裝載LaunchAgent的說明 - 這將重新啓動服務器與新代碼:

To reload postgresql after an upgrade: 
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 
+0

爲我修好了!謝謝 – bantic 2013-08-06 01:51:57

+0

非常感謝 – rurabe 2014-04-24 22:36:53

1

我只是碰到了這個確切同樣的問題,之後,這些解決方案並沒有解決它,我發現我自己的一個:

brew uninstall postgis && brew install postgis 

這一工作的關鍵站出來我在構建輸出的PostGIS:

==> ./configure --with-projdir=/usr/local --with-jsondir=/usr/local/opt/json-c --with-pgconfig=/usr/local/Cellar/postgresql/9.4.4/bin/pg_config --disable-nls 

注意,它使用pg_config,最有可能的,以確定需要的地方存儲所有必要的擴展名的文件。

0

在終端,我跑

$ psql 

在psql裏,它給我這個

> psql (9.6.3, server 9.5.7) 
> Type "help" for help. 

我試圖運行下面的

> CREATE EXTENSION postgis; 

,並得到該錯誤消息

> ERROR: could not open extension control file "/usr/local/Cellar/[email protected]/9.5.7/share/[email protected]/extension/postgis.control": No such file or directory 

我不幹PSQL通過

> \q 

然後跑到

$ brew services list 

,然後回來,結果如下

Name   Status User  Plist 
mysql   stopped   
[email protected]  stopped   
postgresql  stopped   
[email protected] started doquyena /Users/doquyena/Library/LaunchAgents/[email protected] 
redis   stopped 

我的工作,我的psql的是上運行不兼容的psql服務器,所以我用下面的命令糾正它

$ brew services stop [email protected] 
$ brew services start postgresql 

當我回到PSQL

$ psql 

現在顯示這表明我現在是一個匹配的服務器上

> psql (9.6.3) 
> Type "help" for help. 

因此,沒有錯誤消息當我再嘗試再次創建擴展名

> CREATE EXTENSION postgis; 

然後我w因爲能夠創建像這樣的postgis數據表而沒有任何問題

> CREATE TABLE s_test(geom geometry);