Heroku&Rails:尝试减小子弹大小后无法部署-无法构建charlock_holmes

时间:2019-05-20 12:37:42

标签: ruby-on-rails ruby heroku rubygems

heroku上的Rails应用程序的塞子大小开始变得太重,因此我尝试使用以下2条命令来减小它:

heroku repo:gc --app your-app-name 
heroku repo:purge_cache --app your-app-name

以下部署出现此错误:

remote:        An error occurred while installing charlock_holmes (0.7.6), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install charlock_holmes -v '0.7.6'` succeeds before
remote:        bundling.
remote:
remote:        In Gemfile:
remote:          charlock_holmes
remote:
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to app-name.
remote:

完整跟踪:

remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:
remote:        current directory:
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/vendor/ruby-2.5.1/bin/ruby -r
remote:        ./siteconf20190520-506-kmncq3.rb extconf.rb
remote:        checking for -licui18n... yes
remote:        checking for -licui18n... yes
remote:        checking for unicode/ucnv.h... yes
remote:        checking for -lz... yes
remote:        checking for -licuuc... yes
remote:        checking for -licudata... yes
remote:        creating Makefile
remote:
remote:        current directory:
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
remote:        make "DESTDIR=" clean
remote:
remote:        current directory:
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
remote:        make "DESTDIR="
remote:        compiling converter.c
remote:        compiling encoding_detector.c
remote:        compiling ext.c
remote:        compiling transliterator.cpp
remote:        cc1plus: warning: command line option ‘-Wimplicit-int’ is valid for C/ObjC but
remote:        not for C++
remote:        cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid
remote:        for C/ObjC but not for C++
remote:        cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid
remote:        for C/ObjC but not for C++
remote:        cc1plus: warning: unrecognized command line option ‘-Wno-self-assign’
remote:        cc1plus: warning: unrecognized command line option
remote:        ‘-Wno-constant-logical-operand’
remote:        cc1plus: warning: unrecognized command line option ‘-Wno-parentheses-equality’
remote:        linking shared-object charlock_holmes/charlock_holmes.so
remote:        /usr/bin/ld:
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/.apt/usr/lib/x86_64-linux-gnu/libicui18n.a(smpdtfmt.ao):
remote:        relocation R_X86_64_PC32 against symbol `_ZTIN6icu_6013DecimalFormatE' can not
remote:        be used when making a shared object; recompile with -fPIC
remote:        /usr/bin/ld: final link failed: Bad value
remote:        collect2: error: ld returned 1 exit status
remote:        Makefile:257: recipe for target 'charlock_holmes.so' failed
remote:        make: *** [charlock_holmes.so] Error 1
remote:
remote:        make failed, exit code 2
remote:
remote:        Gem files will remain installed in
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/vendor/bundle/ruby/2.5.0/gems/charlock_holmes-0.7.6
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_7a7e1aff2dd1ed9791db1eba7f656cba/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/charlock_holmes-0.7.6/gem_make.out
remote:
remote:        An error occurred while installing charlock_holmes (0.7.6), and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install charlock_holmes -v '0.7.6'` succeeds before
remote:        bundling.
remote:
remote:        In Gemfile:
remote:          charlock_holmes
remote:
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to app-name.
remote:

如果我尝试从bash终端安装charlock_holmes gem,我会得到:

  

gem install charlock_holmes -v'0.7.6'

Fetching: charlock_holmes-0.7.6.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing charlock_holmes:
    ERROR: Failed to build gem native extension.

    current directory: /app/vendor/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/charlock_holmes-0.7.6/ext/charlock_holmes
/app/vendor/ruby-2.5.1/bin/ruby -r ./siteconf20190520-7-dzkpmo.rb extconf.rb
checking for -licui18n... *** 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=/app/vendor/ruby-2.5.1/bin/$(RUBY_BASE_NAME)
    --with-icu-dir
    --without-icu-dir
    --with-icu-include
    --without-icu-include=${icu-dir}/include
    --with-icu-lib
    --without-icu-lib=${icu-dir}/lib
    --with-icui18nlib
    --without-icui18nlib
/app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:777:in `try_func'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:1004:in `block in have_library'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
    from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/mkmf.rb:999:in `have_library'
    from extconf.rb:31:in `<main>'

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

  /app/vendor/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/charlock_holmes-0.7.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /app/vendor/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/charlock_holmes-0.7.6 for inspection.
Results logged to /app/vendor/ruby-2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/charlock_holmes-0.7.6/gem_make.out

如果显示.../charlock_holmes-0.7.6/mkmf.log文件的输出,则显示:

"gcc -o conftest -I/app/vendor/ruby-2.5.1/include/ruby-2.5.0/x86_64-linux -I/app/vendor/ruby-2.5.1/include/ruby-2.5.0/ruby/backward -I/app/vendor/ruby-2.5.1/include/ruby-2.5.0 -I.    -O3 -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict  -fPIC conftest.c  -L. -L/app/vendor/ruby-2.5.1/lib -Wl,-rpath,/app/vendor/ruby-2.5.1/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-rpath,'/../lib' -Wl,-rpath,'/../lib' -lruby  -lpthread -lgmp -ldl -lcrypt -lm   -lc"
In file included from /app/vendor/ruby-2.5.1/include/ruby-2.5.0/ruby/ruby.h:29:0,
                 from /app/vendor/ruby-2.5.1/include/ruby-2.5.0/ruby.h:33,
                 from conftest.c:1:
/app/vendor/ruby-2.5.1/include/ruby-2.5.0/ruby/defines.h:112:10: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
          ^~~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

在heroku上,我有这些buildpacks

  

=== my_app Buildpack网址

     
      
  1. https://github.com/heroku/heroku-buildpack-apt

  2.   
  3. heroku / ruby​​

  4.   

我的Aptfile是:

libicu52 
libicu-dev

有什么想法吗?

谢谢!

0 个答案:

没有答案