Rails耙db:schema:load无法运行

时间:2018-06-25 21:53:23

标签: ruby-on-rails

我正在尝试做rake db:schema:load,但是遇到错误,看来问题出在enable_extension("pg_repack")步骤上:

rake db:schema:load --trace
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
**************************************************
⛔️ WARNING: Sidekiq testing API enabled, but this is not the test environment.  Your jobs will not go to Redis.
**************************************************
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:load
-- enable_extension("plpgsql")
   -> 0.2005s
-- enable_extension("pg_repack")
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR:  could not open extension control file "/Applications/Postgres.app/Contents/Versions/10/share/postgresql/extension/pg_repack.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "pg_repack"
...
Tasks: TOP => db:schema:load

我正在使用Postgres 9.6.6:

which postgres
/usr/local/Cellar/postgresql@9.6/9.6.6/bin/postgres

有什么想法可以让pg_repack工作吗?

编辑:

运行pgxn install pg_repack时得到以下提示:

INFO: best version: pg_repack 1.4.3
INFO: saving /var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmp02_KE6/pg_repack-1.4.3.zip
INFO: unpacking: /var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmp02_KE6/pg_repack-1.4.3.zip
INFO: building extension
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -I/usr/local/Cellar/postgresql@9.6/9.6.6/include -DREPACK_VERSION=1.4.3 -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/internal -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2   -c -o pg_repack.o pg_repack.c
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -I/usr/local/Cellar/postgresql@9.6/9.6.6/include -DREPACK_VERSION=1.4.3 -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/internal -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2   -c -o pgut/pgut.o pgut/pgut.c
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -I/usr/local/Cellar/postgresql@9.6/9.6.6/include -DREPACK_VERSION=1.4.3 -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/internal -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2   -c -o pgut/pgut-fe.o pgut/pgut-fe.c
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/local/Cellar/postgresql@9.6/9.6.6/lib -lpq -L/usr/local/Cellar/postgresql@9.6/9.6.6/lib -L/usr/local/Cellar/postgresql@9.6/9.6.6/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -Wl,-dead_strip_dylibs   -lpgcommon -lpgport -lssl -lcrypto -lz -lreadline -lm -o pg_repack
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -DREPACK_VERSION=1.4.3 -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/internal -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2   -c -o repack.o repack.c
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -DREPACK_VERSION=1.4.3 -I. -I./ -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/server -I/usr/local/Cellar/postgresql@9.6/9.6.6/include/internal -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2   -c -o pgut/pgut-spi.o pgut/pgut-spi.c
awk '/^[^#]/ {printf "_%s\n",$1}' exports.txt >exports.list
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -bundle -multiply_defined suppress -Wl,-undefined,dynamic_lookup -o pg_repack.so repack.o pgut/pgut-spi.o -L/usr/local/Cellar/postgresql@9.6/9.6.6/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -Wl,-dead_strip_dylibs   -bundle_loader /usr/local/Cellar/postgresql@9.6/9.6.6/bin/postgres
sed 's,REPACK_VERSION,1.4.3,g' pg_repack.sql.in > pg_repack--1.4.3.sql;
sed 's,REPACK_VERSION,1.4.3,g' pg_repack.control.in > pg_repack.control
make[1]: Nothing to be done for `all'.
INFO: installing extension
/bin/sh /usr/local/Cellar/postgresql@9.6/9.6.6/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql@9.6/9.6.6/bin'
/usr/bin/install -c  pg_repack '/usr/local/Cellar/postgresql@9.6/9.6.6/bin'
/bin/sh /usr/local/Cellar/postgresql@9.6/9.6.6/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql@9.6/9.6.6/lib'
/bin/sh /usr/local/Cellar/postgresql@9.6/9.6.6/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql@9.6/9.6.6/share/postgresql@9.6/extension'
/bin/sh /usr/local/Cellar/postgresql@9.6/9.6.6/lib/pgxs/src/makefiles/../../config/install-sh -c -d '/usr/local/Cellar/postgresql@9.6/9.6.6/share/postgresql@9.6/extension'
/usr/bin/install -c -m 755  pg_repack.so '/usr/local/Cellar/postgresql@9.6/9.6.6/lib/pg_repack.so'
/usr/bin/install -c -m 644 .//pg_repack.control '/usr/local/Cellar/postgresql@9.6/9.6.6/share/postgresql@9.6/extension/'
/usr/bin/install -c -m 644  pg_repack--1.4.3.sql pg_repack.control '/usr/local/Cellar/postgresql@9.6/9.6.6/share/postgresql@9.6/extension/'
make[1]: Nothing to be done for `install'.

但是当我运行psql -c "CREATE EXTENSION pg_repack" tr_dev时,仍然收到此消息:

ERROR:  could not open extension control file "/Applications/Postgres.app/Contents/Versions/9.6/share/postgresql/extension/pg_repack.control": No such file or directory

1 个答案:

答案 0 :(得分:2)

此错误表明pg_repack不存在。首先检查您的目录以查看pg_repack是否存在,但错误仍然存​​在,您可以尝试

使用DROP EXTENSION pg_repack删除pg_repack或仅删除重新打包模式。

1)从

下载新的pg_repack扩展名

pg repack download

2)$ pgxn install pg_repack

3)$ cd pg_repack $ make $ sudo make install

4)安装后,将pg_repack扩展名加载到要处理的数据库中。 pg_repack被打包为扩展,因此您可以执行:

$ psql -c "CREATE EXTENSION pg_repack" -d your_database