ruby-on-railsrubybundlerredmine

Rails without gcc?


I'm trying to install a RoR app (Redmine) on a resource-limited VPS, as follows:

$ sudo apt install ruby ruby-bundler ruby-dev
$ bundle config set --local without 'development test'
$ bundle install

The bundle install fails because it can't compile cparse.c, arena.c, and autolink.c (make: x86_64-linux-gnu-gcc: No such file or directory).

I really don't want to install gcc on this VPS. Do I have any other options? Does RoR require a C compiler at runtime? Can I carry out the bundle install on another identical system (Ubuntu 22.04) which does have a dev environment, and copy over binaries? Or can I simply compile these C files on the dev system and copy over binaries?

LOG 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

LOG 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

LOG3

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

BUNDLER OUTPUT

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

Solution

  • The two most obvious approaches are:

    1. Create a deb/rpm/etc; after all, this is exactly what package management is for. Jordan Sissel has a tool (fpm) that will help with packaging gems, but I haven't tried it
    2. Luis Lavena has a Gem compiler here. Again, I haven't used it, but I think I recall reading a blog where someone did use this to recompile mysql2

    Redmine actually has 8 gems which are built with native extensions; not just the 3 that your logs show. These are the ones that need to be compiled.

    This is how I do it. I use two VMs, which are created from the same root distro (in my case, a Ubuntu 22.04 server). One is set up as a dev system, and I use it to compile the gems, which are then copied to the production system.

    On the dev system:

    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.
    

    Note that build-essential (and libapache2-mod-passenger, if you're using that) also install ruby, so the explicit install above isn't required. Make sure your dev system and production system have the same version of ruby. libmysqlclient-dev is required if you want to build mysql2.

    I also do this on the dev system, which may or may not be a good idea. If you do this, you will have to export your database from the dev system, and import it on the production system (db::migrate sets up the tables):

    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
    

    Now you've got to find out what the compilation actually did. You can find out for each gem:

    redmine # bundle info mysql2 | grep -i path
        Path: /var/lib/gems/3.0.0/gems/mysql2-0.5.5
    

    Or just run gem environment. This produced the same output on both the dev and production systems:

      - 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
    

    However, only 3 of these paths actually exist on the 2 systems:

    /var/lib/gems/3.0.0
    /usr/lib/ruby/gems/3.0.0
    /usr/share/rubygems-integration/all
    

    I just copy these trees to the production system (about 100MB). After the copy (and database import, if necessary), and a ruby install (apt install ruby) Redmine runs on the production system without problems. This is all a bit painful,though. In an ideal world, the Redmine maintainers would create the binary packages.