由于要部署在 Heroku 上,所以必须要用 PostgreSQL。就有了这样的依赖关系:data_mapper -> dm-postgres-adapter -> do_postgres
。但是安装do_postgres
的时候总提示找不到某些头文件。这下问题就来了,我用两种策略在本机上安装 PostgreSQL:
直接安装不行,所以要手动指定include
,于是我尝试了:
$ sudo gem install dm-postgres-adapter -- --with-pgsql-server-include=/usr/Applications/Postgres93.app/Contents/MacOS/include
$ sudo gem install dm-postgres-adapter -- --with-pgsql-server-include=/usr/Applications/Postgres93.app/Contents/MacOS/include/postgresql
$ sudo gem install dm-postgres-adapter -- --with-pgsql-server-include=/usr/Applications/Postgres93.app/Contents/MacOS/include/postgresql/server
都得到提示:
checking for main() in -lpq... yes
checking for libpq-fe.h... no
brew install postgres
依旧无果用brew
安装的 PostgreSQL 是9.2.4
版的,再次尝试安装 gem,情况貌似有所好转:
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for postgres.h... yes
checking for mb/pg_wchar.h... no
情况如这位哥们儿所说,mb/pg_wchar.h
确实存在,但有 error,但出错的地方不一样。
have_header: checking for mb/pg_wchar.h... -------------------- no
"xcrun clang -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin13 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 -I. -I/usr/local/Cellar/postgresql/9.2.4/include -I/usr/local/Cellar/postgresql/9.2.4/include/server -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_NO_DATETIME_NEWBANG -c conftest.c"
In file included from conftest.c:3:
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:303:16: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len);
~^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:303:9: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len);
~~~~~~~ ^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:303:14: error: function cannot return function type 'int (unsigned char *, int)'
typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len);
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:328:2: error: unknown type name 'uint32'
uint32 utf; /* UTF-8 */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:329:2: error: unknown type name 'uint32'
uint32 code; /* local code */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:337:2: error: unknown type name 'uint32'
uint32 code; /* local code */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:338:2: error: unknown type name 'uint32'
uint32 utf; /* UTF-8 */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:346:2: error: unknown type name 'uint32'
uint32 utf1; /* UTF-8 code 1 */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:347:2: error: unknown type name 'uint32'
uint32 utf2; /* UTF-8 code 2 */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:348:2: error: unknown type name 'uint32'
uint32 code; /* local code */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:356:2: error: unknown type name 'uint32'
uint32 code; /* local code */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:357:2: error: unknown type name 'uint32'
uint32 utf1; /* UTF-8 code 1 */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:358:2: error: unknown type name 'uint32'
uint32 utf2; /* UTF-8 code 2 */
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:416:8: error: unknown type name 'mbcharacter_incrementer'
extern mbcharacter_incrementer pg_database_encoding_character_incrementer(void);
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:456:27: error: function cannot return function type 'bool' (aka 'int (int *)')
extern bool pg_verifymbstr(const char *mbstr, int len, bool noError);
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:457:28: error: function cannot return function type 'bool' (aka 'int (int *)')
extern bool pg_verify_mbstr(int encoding, const char *mbstr, int len,
^
/usr/local/Cellar/postgresql/9.2.4/include/server/mb/pg_wchar.h:485:28: error: function cannot return function type 'bool' (aka 'int (int *)')
extern bool pg_utf8_islegal(const unsigned char *source, int length);
^
2 warnings and 15 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <mb/pg_wchar.h>
/* end */
--------------------
不得不说,被彻底恶心到了。