将 Gitlab 从 9.3.7 更新到 9.3.8 安装 re2 时出错

Posted

技术标签:

【中文标题】将 Gitlab 从 9.3.7 更新到 9.3.8 安装 re2 时出错【英文标题】:Updating Gitlab from 9.3.7 to 9.3.8 getting Error installing re2 【发布时间】:2017-12-25 13:19:35 【问题描述】:

我们在 Ubuntu 14.04 上运行,Gitlab 9.3.7 运行良好。我们正在尝试更新到 Gitlab v9.3.8 的最新安全补丁,但它给了我们这个错误:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/re2-1.0.0/ext/re2
/usr/local/bin/ruby -r ./siteconf20170720-19622-15i0edf.rb extconf.rb
checking for main() in -lstdc++... yes
checking for stdint.h... yes
checking for rb_str_sublen()... yes
checking for main() in -lre2... no
You must have re2 installed and specified with --with-re2-dir, please see https://github.com/google/re2/wiki/Install
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=$opt-dir/include
    --with-opt-lib
    --without-opt-lib=$opt-dir/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/bin/$(RUBY_BASE_NAME)
    --with-re2-dir
    --without-re2-dir
    --with-re2-include
    --without-re2-include=$re2-dir/include
    --with-re2-lib
    --without-re2-lib=$re2-dir/lib
    --with-stdc++lib
    --without-stdc++lib
    --with-re2lib
    --without-re2lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/git/gitlab/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/re2-1.0.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/re2-1.0.0 for inspection.
Results logged to /home/git/gitlab/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/re2-1.0.0/gem_make.out

An error occurred while installing re2 (1.0.0), and Bundler cannot continue.
Make sure that `gem install re2 -v '1.0.0'` succeeds before bundling.

In Gemfile:
  re2

mkmf.log 文件包含:

have_library: checking for main() in -lstdc++... -------------------- yes

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: 
5:   return 0;
6: 
/* end */

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lstdc++  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: 
 7:   if (argc > 1000000) 
 8:     printf("%p", &t);
 9:   
10:
11:   return 0;
12: 
13: int t(void)  void ((*volatile p)()); p = (void ((*)()))main; return !p; 
/* end */

--------------------

have_header: checking for stdint.h... -------------------- yes

"gcc -E -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <stdint.h>
/* end */

--------------------

have_func: checking for rb_str_sublen()... -------------------- yes

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic    -lstdc++  -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lstdc++  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: 
 7:   if (argc > 1000000) 
 8:     printf("%p", &t);
 9:   
10:
11:   return 0;
12: 
13: int t(void)  void ((*volatile p)()); p = (void ((*)()))rb_str_sublen; return !p; 
/* end */

--------------------

have_library: checking for main() in -lre2... -------------------- no

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic    -lstdc++  -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lre2 -lstdc++  -lpthread -ldl -lcrypt -lm   -lc"
/usr/bin/ld: cannot find -lre2
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: 
 7:   if (argc > 1000000) 
 8:     printf("%p", &t);
 9:   
10:
11:   return 0;
12: 
13: int t(void)  void ((*volatile p)()); p = (void ((*)()))main; return !p; 
/* end */

"gcc -o conftest -I/usr/local/include/ruby-2.3.0/x86_64-linux -I/usr/local/include/ruby-2.3.0/ruby/backward -I/usr/local/include/ruby-2.3.0 -I. -I/usr/local/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wall -Wextra -funroll-loops conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic    -lstdc++  -Wl,-R/usr/local/lib -L/usr/local/lib -lruby-static -lre2 -lstdc++  -lpthread -ldl -lcrypt -lm   -lc"
conftest.c:13:13: error: conflicting types for ‘main’
 extern void main();
             ^
conftest.c:5:5: note: previous definition of ‘main’ was here
 int main(int argc, char **argv)
     ^
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: 
 7:   if (argc > 1000000) 
 8:     printf("%p", &t);
 9:   
10:
11:   return 0;
12: 
13: extern void main();
14: int t(void)  main(); return 0; 
/* end */

--------------------

我尝试添加 ruby​​-dev 和 ruby​​2.3-dev,因为我们使用的是 Ruby 2.3。更新中没有变化。由于这是一个相当新的补丁,Gitlab 在他们的网站上没有更多信息,re2 的安装说明也没有帮助。

【问题讨论】:

【参考方案1】:

安装 lib 后我能够安装 re2-gem:

apt-get install libre2-dev

【讨论】:

我们已经尝试过这个修复,但 14.04 似乎没有 libre2-dev。我还没有进一步检查它是否在替代存储库中可用。 我在 Ubuntu 16.04 上遇到了同样的错误。按照这个答案安装库解决了我的问题。 对“debian jessie”也有同样的帮助【参考方案2】:

我有同样的问题 它对我有用,请自行承担风险

Ubuntu 14.04 没有libre2-devhttps://launchpad.net/ubuntu/+source/re2

我是从源头安装的https://github.com/google/re2/wiki/Install

cd /tmp git clone https://github.com/google/re2.git cd re2/ make make test sudo checkinstall -D --install=no sudo dpkg -i re2_20170720-1_amd64.deb

然后运行ldconfig

【讨论】:

libre2-dev 在我们的 Ubuntu 14.04 上安装没有问题。等待一个安静的时刻来测试带有 re2 的 Gitlab v9.3.8 在我们的 VM 上是否喜欢这个。假设 checkinstall 的默认值没问题是否安全? 按上述方式安装的包可以正常工作 出现错误时也请按照回答中的wiki页面。这个答案确实有效。【参考方案3】:

我在 macOS Big Sur 上遇到了同样的错误。下面安装解决问题

brew install re2

【讨论】:

感谢您分享这个。【参考方案4】:

您好,我刚刚遇到了同样的错误。至少我们不是唯一的。

我在 GitLab 中提出了问题:https://gitlab.com/gitlab-org/gitlab-ce/issues/35342

【讨论】:

Gitlab 问题跟踪器中提到了相同的修复,正如@serg-b 建议的那样。感谢您发布错误!我也开始创建一个错误,并且在我睡眠不足的情况下,从不点击提交:(

以上是关于将 Gitlab 从 9.3.7 更新到 9.3.8 安装 re2 时出错的主要内容,如果未能解决你的问题,请参考以下文章

gitlab从8.6.5升级到8.11.7(补丁版本通用更新指南)

gitlab-11.1.4继续升级到15.9.3

php三种排序算法

Java Array和大数据运算

gitlab-11.1.4继续升级到15.9.3

码头 HTTP2Client jar 丢失