Project

General

Profile

Actions

Bug #21692

open

Basic gems like `date` require a compiler

Bug #21692: Basic gems like `date` require a compiler

Added by getajobmike (Mike Perham) about 4 hours ago. Updated about 3 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:123831]

Description

I'm trying to use Ruby in a high security environment which does not allow a compiler to be installed. This was easy years ago when all of standard library was included with Ruby itself and I could use apt install ruby. But as the standard library has broken off into separate, optional gems it has become impossible to bundle a reasonable pure Ruby application without requiring basic gems like date which require a compiler to install.

Are there any plans to make native extensions optional for gems? With tools like ZJIT it can be better to use pure Ruby for performance; I would like to see Ruby encourage fewer native extensions and/or make them optional.

Updated by mame (Yusuke Endoh) about 3 hours ago Actions #1 [ruby-core:123832]

I think what you want is bundle install --prefer-local. (I wonder why this option is not the default.)

Updated by getajobmike (Mike Perham) about 3 hours ago ยท Edited Actions #2 [ruby-core:123834]

  • ruby -v changed from 3.4.5 to 3.2.3

mame (Yusuke Endoh) wrote in #note-1:

I think what you want is bundle install --prefer-local. (I wonder why this option is not the default.)

Unfortunately this does not seem to work for me.

$ gem list | grep date
date (default: 3.3.3)

$ more Gemfile
source "https://rubygems.org"

gem "net-imap"
gem "date", "3.3.3"

$ bundle version
Bundler version 2.5.23 (2024-11-05 commit 35f4611265e)

$ ruby -v
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [x86_64-linux-gnu]

$ bundle install --prefer-local
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Installing date 3.3.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.2.0/gems/date-3.3.3/ext/date
/usr/bin/ruby3.2 -I/usr/lib/ruby/vendor_ruby 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.
[...]
/usr/lib/ruby/3.2.0/mkmf.rb:490:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
Actions

Also available in: PDF Atom