我正在尝试在资源有限的 VPS 上安装 RoR 应用程序 (Redmine),如下所示:
$ sudo apt install ruby ruby-bundler ruby-dev
$ bundle config set --local without 'development test'
$ bundle install
bundle install
失败,因为它无法编译cparse.c、arena.c和autolink.c (make: x86_64-linux-gnu-gcc: No such file or directory
)。
我真的不想在这个VPS上安装gcc。我还有其他选择吗? RoR 在运行时是否需要 C 编译器?我可以在另一个具有开发环境的相同系统(Ubuntu 22.04)上进行捆绑安装,并复制二进制文件吗?或者我可以简单地在开发系统上编译这些 C 文件并复制二进制文件吗?
日志1
current directory: /var/lib/gems/3.0.0/gems/racc-1.7.2/ext/racc/cparse
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-eh9t07.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/3.0.0/gems/racc-1.7.2/ext/racc/cparse
make DESTDIR\= clean
current directory: /var/lib/gems/3.0.0/gems/racc-1.7.2/ext/racc/cparse
make DESTDIR\=
compiling cparse.c
make: x86_64-linux-gnu-gcc: No such file or directory
make: *** [Makefile:245: cparse.o] Error 127
make failed, exit code 2
current directory: /var/lib/gems/3.0.0/gems/nio4r-2.5.9/ext/nio4r
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-ptq7pb.rb extconf.rb
checking for unistd.h... *** 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/bin/$(RUBY_BASE_NAME)3.0
--with-unistd-dir
--without-unistd-dir
--with-unistd-include
--without-unistd-include=${unistd-dir}/include
--with-unistd-lib
--without-unistd-lib=${unistd-dir}/lib
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/3.0.0/mkmf.rb:613:in `try_cpp'
from /usr/lib/ruby/3.0.0/mkmf.rb:1124:in `block in have_header'
from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:1123:in `have_header'
from extconf.rb:18:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/nio4r-2.5.9/mkmf.log
current directory: /var/lib/gems/3.0.0/gems/redcarpet-3.6.0/ext/redcarpet
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-gedcgv.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/3.0.0/gems/redcarpet-3.6.0/ext/redcarpet
make DESTDIR\= clean
current directory: /var/lib/gems/3.0.0/gems/redcarpet-3.6.0/ext/redcarpet
make DESTDIR\=
compiling autolink.c
make: x86_64-linux-gnu-gcc: No such file or directory
make: *** [Makefile:245: autolink.o] Error 127
make failed, exit code 2
root@vserver:/opt/redmine-5.1.0# bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for
all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies.....
[cuts to save electrons]
...
Installing racc 1.7.2 with native extensions
Installing nio4r 2.5.9 with native extensions
Installing date 3.3.3 with native extensions
Installing commonmarker 0.23.10 with native extensions
Installing mysql2 0.5.5 with native extensions
Installing redcarpet 3.6.0 with native extensions
Installing websocket-driver 0.7.6 with native extensions
...
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/3.0.0/gems/racc-1.7.2/ext/racc/cparse
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-eh9t07.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/3.0.0/gems/racc-1.7.2/ext/racc/cparse
make DESTDIR\= clean
current directory: /var/lib/gems/3.0.0/gems/racc-1.7.2/ext/racc/cparse
make DESTDIR\=
compiling cparse.c
make: x86_64-linux-gnu-gcc: No such file or directory
make: *** [Makefile:245: cparse.o] Error 127
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/3.0.0/gems/racc-1.7.2 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/racc-1.7.2/gem_make.out
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:95:in `run'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:44:in `block in make'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:36:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:36:in `make'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
/usr/lib/ruby/3.0.0/tempfile.rb:317:in `open'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:847:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing racc (1.7.2), and Bundler cannot continue.
In Gemfile:
rails was resolved to 6.1.7.6, which depends on
actioncable was resolved to 6.1.7.6, which depends on
actionpack was resolved to 6.1.7.6, which depends on
actionview was resolved to 6.1.7.6, which depends on
rails-dom-testing was resolved to 2.2.0, which depends on
nokogiri was resolved to 1.15.4, which depends on
racc
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/3.0.0/gems/nio4r-2.5.9/ext/nio4r
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-ptq7pb.rb extconf.rb
checking for unistd.h... *** 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/bin/$(RUBY_BASE_NAME)3.0
--with-unistd-dir
--without-unistd-dir
--with-unistd-include
--without-unistd-include=${unistd-dir}/include
--with-unistd-lib
--without-unistd-lib=${unistd-dir}/lib
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/3.0.0/mkmf.rb:613:in `try_cpp'
from /usr/lib/ruby/3.0.0/mkmf.rb:1124:in `block in have_header'
from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:1123:in `have_header'
from extconf.rb:18:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/nio4r-2.5.9/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/3.0.0/gems/nio4r-2.5.9 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/nio4r-2.5.9/gem_make.out
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:95:in `run'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
/usr/lib/ruby/3.0.0/tempfile.rb:317:in `open'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:847:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing nio4r (2.5.9), and Bundler cannot continue.
In Gemfile:
rails was resolved to 6.1.7.6, which depends on
actioncable was resolved to 6.1.7.6, which depends on
nio4r
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/3.0.0/gems/date-3.3.3/ext/date
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-80rqrj.rb extconf.rb
checking for rb_category_warn()... *** 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/bin/$(RUBY_BASE_NAME)3.0
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/3.0.0/mkmf.rb:564:in `try_link0'
from /usr/lib/ruby/3.0.0/mkmf.rb:582:in `try_link'
from /usr/lib/ruby/3.0.0/mkmf.rb:794:in `try_func'
from /usr/lib/ruby/3.0.0/mkmf.rb:1083:in `block in have_func'
from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:1082:in `have_func'
from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/date-3.3.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/3.0.0/gems/date-3.3.3 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/date-3.3.3/gem_make.out
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:95:in `run'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
/usr/lib/ruby/3.0.0/tempfile.rb:317:in `open'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:847:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing date (3.3.3), and Bundler cannot continue.
In Gemfile:
rails was resolved to 6.1.7.6, which depends on
actionmailbox was resolved to 6.1.7.6, which depends on
mail was resolved to 2.8.1, which depends on
net-imap was resolved to 0.3.7, which depends on
date
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/3.0.0/gems/commonmarker-0.23.10/ext/commonmarker
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-dc0li8.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/3.0.0/gems/commonmarker-0.23.10/ext/commonmarker
make DESTDIR\= clean
current directory: /var/lib/gems/3.0.0/gems/commonmarker-0.23.10/ext/commonmarker
make DESTDIR\=
compiling arena.c
make: x86_64-linux-gnu-gcc: No such file or directory
make: *** [Makefile:245: arena.o] Error 127
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/3.0.0/gems/commonmarker-0.23.10 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/commonmarker-0.23.10/gem_make.out
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:95:in `run'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:44:in `block in make'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:36:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:36:in `make'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
/usr/lib/ruby/3.0.0/tempfile.rb:317:in `open'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:847:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing commonmarker (0.23.10), and Bundler cannot continue.
In Gemfile:
commonmarker
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/3.0.0/gems/mysql2-0.5.5/ext/mysql2
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-y874en.rb extconf.rb
checking for rb_absint_size()... *** 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/bin/$(RUBY_BASE_NAME)3.0
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/3.0.0/mkmf.rb:564:in `try_link0'
from /usr/lib/ruby/3.0.0/mkmf.rb:582:in `try_link'
from /usr/lib/ruby/3.0.0/mkmf.rb:794:in `try_func'
from /usr/lib/ruby/3.0.0/mkmf.rb:1083:in `block in have_func'
from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
from /usr/lib/ruby/3.0.0/mkmf.rb:1082:in `have_func'
from extconf.rb:34:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.5/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/3.0.0/gems/mysql2-0.5.5 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.5/gem_make.out
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:95:in `run'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
/usr/lib/ruby/3.0.0/tempfile.rb:317:in `open'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:847:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.
In Gemfile:
mysql2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/3.0.0/gems/redcarpet-3.6.0/ext/redcarpet
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20231102-2265-gedcgv.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/3.0.0/gems/redcarpet-3.6.0/ext/redcarpet
make DESTDIR\= clean
current directory: /var/lib/gems/3.0.0/gems/redcarpet-3.6.0/ext/redcarpet
make DESTDIR\=
compiling autolink.c
make: x86_64-linux-gnu-gcc: No such file or directory
make: *** [Makefile:245: autolink.o] Error 127
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/3.0.0/gems/redcarpet-3.6.0 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/redcarpet-3.6.0/gem_make.out
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:95:in `run'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:44:in `block in make'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:36:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:36:in `make'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
/usr/lib/ruby/3.0.0/tempfile.rb:317:in `open'
/usr/lib/ruby/vendor_ruby/rubygems/ext/ext_conf_builder.rb:26:in `build'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:161:in `build_extension'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:195:in `block in build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `each'
/usr/lib/ruby/vendor_ruby/rubygems/ext/builder.rb:192:in `build_extensions'
/usr/lib/ruby/vendor_ruby/rubygems/installer.rb:847:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/source/rubygems.rb:204:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:62:in `apply_func'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:57:in `block in process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `loop'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
An error occurred while installing redcarpet (3.6.0), and Bundler cannot continue.
In Gemfile:
redcarpet
创建 deb/rpm/etc;毕竟,这正是包管理的目的。 Jordan Sissel 有一个工具(
mysql2
我就是这样做的。我使用两个虚拟机,它们是从同一个根发行版(在我的例子中是 Ubuntu 22.04 服务器)创建的。其中一个被设置为开发系统,我用它来编译 gem,然后将其复制到生产系统。
在开发系统上:
redmine # apt install build-essential
redmine # apt install libmysqlclient-dev
redmine # apt install ruby
redmine # gem install bundler
redmine # apt install ruby-dev
redmine # cd /opt/redmine-5.1.0
redmine # bundle config set --local without 'development test'
redmine # bundle install
Bundle complete! 41 Gemfile dependencies, 73 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
请注意,
build-essential
(和
libapache2-mod-passenger
,如果您正在使用它)也会安装 ruby,因此不需要上面的显式安装。确保您的开发系统和生产系统具有相同版本的 ruby。如果您想构建 libmysqlclient-dev
,则需要 mysql2
。我也在开发系统上执行此操作,这可能是也可能不是一个好主意。如果这样做,您将必须从开发系统导出数据库,并将其导入生产系统(db::migrate
设置表):
redmine # bundle exec rake generate_secret_token
redmine # RAILS_ENV=production bundle exec rake db:migrate
redmine # RAILS_ENV=production bundle exec rake redmine:load_default_data
现在你必须找出编译实际上做了什么。您可以找到每颗宝石:
redmine # bundle info mysql2 | grep -i path
Path: /var/lib/gems/3.0.0/gems/mysql2-0.5.5
或者直接运行
gem environment
。这在开发系统和生产系统上产生了相同的输出:
- GEM PATHS:
- /var/lib/gems/3.0.0
- /root/.local/share/gem/ruby/3.0.0
- /usr/local/lib/ruby/gems/3.0.0
- /usr/lib/ruby/gems/3.0.0
- /usr/lib/x86_64-linux-gnu/ruby/gems/3.0.0
- /usr/share/rubygems-integration/3.0.0
- /usr/share/rubygems-integration/all
- /usr/lib/x86_64-linux-gnu/rubygems-integration/3.0.0
但是,这两个系统中实际上只存在其中的 3 个路径:
/var/lib/gems/3.0.0
/usr/lib/ruby/gems/3.0.0
/usr/share/rubygems-integration/all
我只是将这些树复制到生产系统(大约100MB)。复制(以及数据库导入,如有必要)和 ruby 安装 (
apt install ruby
) 之后,Redmine 在生产系统上运行没有问题。不过,这有点痛苦。在理想的情况下,Redmine 维护者将创建二进制包。