Skip to content

Instantly share code, notes, and snippets.

@chrisroos
Created February 11, 2011 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisroos/822298 to your computer and use it in GitHub Desktop.
Save chrisroos/822298 to your computer and use it in GitHub Desktop.
Steps to test/fix RedCloth 4.2.6 on Mac OS X

Intro

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
1.3.7

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'
<ctrl-d>

$ 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 = File.read(gemspec_file)
r = /s\.require_path.*/
gemspec = gemspec.sub(r, 's.require_paths = [\'lib\', \'lib/case_sensitive_require\', \'lib/lib/case_sensitive_require\']')
File.open(gemspec_file, '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 = File.read(gemfile_path)
r = /'4\.2\.6'/
gemfile = gemfile.sub(r, ':path => \'' + ENV['REDCLOTH_PATH'] + '\'')
File.open(gemfile_path, 'w') { |f| f.puts(gemfile) }"

$ bundle install

Test requiring RedCloth

$ ruby -e"require 'rubygems'; require 'bundler/setup'; require 'RedCloth'"
@sccarr
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:
	--with-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/local/Cellar/ruby/2.6.5/bin/$(RUBY_BASE_NAME)
	--with-redcloth_scan-dir
	--without-redcloth_scan-dir
	--with-redcloth_scan-include
	--without-redcloth_scan-include=${redcloth_scan-dir}/include
	--with-redcloth_scan-lib
	--without-redcloth_scan-lib=${redcloth_scan-dir}/lib
	--with-clib
	--without-clib
/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:

  /usr/local/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/RedCloth-4.3.2/mkmf.log

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