Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2011 12:54
What would you like to do?
Steps to test/fix RedCloth 4.2.6 on Mac OS X


RedCloth 4.2.6 is broken on Mac OS X. It appears to be related to the case sensitive require fix. These steps expose and fix the problem on my machine.

Software versions

$ ruby -v
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.3.0], MBARI 0x6770, Ruby Enterprise Edition 2010.01

$ gem -v

Create a folder for our test

$ cd ~
$ mkdir tmp-redcloth-test
$ cd tmp-redcloth-test

Use Bundler to install RedCloth 4.2.6

$ cat > Gemfile
source :rubygems

gem 'RedCloth', '4.2.6'

$ bundle install --path gems

Test requiring RedCloth

$ ruby -e"require 'rubygems'; require 'bundler/setup'; require 'RedCloth'"
-e:1:in `require': no such file to load -- RedCloth (LoadError)
  from -e:1

Update the gemspec

$ REDCLOTH_PATH=`bundle show RedCloth` \
ruby -e "\
gemspec_file = File.join(ENV['REDCLOTH_PATH'], 'redcloth.gemspec')
gemspec =
r = /s\.require_path.*/
gemspec = gemspec.sub(r, 's.require_paths = [\'lib\', \'lib/case_sensitive_require\', \'lib/lib/case_sensitive_require\']'), 'w') { |f| f.puts(gemspec) }"

Tell Bundler to use our custom version of RedCloth

$ REDCLOTH_PATH=`bundle show RedCloth` \
ruby -e "\
gemfile_path = 'Gemfile'
gemfile =
r = /'4\.2\.6'/
gemfile = gemfile.sub(r, ':path => \'' + ENV['REDCLOTH_PATH'] + '\''), 'w') { |f| f.puts(gemfile) }"

$ bundle install

Test requiring RedCloth

$ ruby -e"require 'rubygems'; require 'bundler/setup'; require 'RedCloth'"
Copy link

sccarr commented Oct 26, 2019

I have installed Bundler, but at the step "Use Bundler to install RedCloth," it fails for me. I get

ERROR:  Error installing RedCloth:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.6.0/gems/RedCloth-4.3.2/ext/redcloth_scan
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0 -r ./siteconf20191026-5163-5zcdpq.rb extconf.rb
checking for main() in -lc... *** 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:
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:782:in `try_func'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:1016:in `block in have_library'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:331:in `open'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
	from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/mkmf.rb:1011:in `have_library'
	from extconf.rb:5:in `<main>'

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


extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.6.0/gems/RedCloth-4.3.2 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/RedCloth-4.3.2/gem_make.out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment