Hi, We are using RedCloth to provide note formatting inside an open source project called the Dradis Framework [i] and [ii]. This is a Rails-based application that end users install in their computers. What we have done in the past is including RedCloth's binary .gem into the Dradis installer and that has worked out perfectly. However, we are looking into upgrading Dradis to Rails 3 and Ruby 1.9.2. Unfortunately, we are running into some issues in Windows with the Ruby Installer (1.9.2p0) and the binary version of RedCloth (RedCloth-4.2.2-x86-mswin32-60.gem). It installs ok but then fails when trying to load 'msvcrt-ruby18.dll'. I have successfully used DevKit to compile and use RedCloth 4.2.3 in a test system, but I would like to be able to create a Ruby Installer compatible binary gem to distribute it with the installer (thus removing the extra dependency on DevKit for end users). Is this possible? What is the best way to do this? Going to the gem folder (C:\Ruby192\lib\ruby\gems\1.9.1\gems\RedCloth-4.2.3) and running rake fails with a "no such file to load" error. After tweaking the Rakefile and running 'rake mingw compile' also fails [iii]. Can anyone give me a hand to figure out what is going on? Many thanks, Daniel [i] http://dradisframework.org/ [ii] http://dradisframework.org/images/screenshot/v2.5/... [iii] http://pastie.org/1311243
on 2010-11-19 18:12
on 2010-11-19 21:16
> However, we are looking into upgrading Dradis to Rails 3 and Ruby 1.9.2. > Unfortunately, we are running into some issues in Windows with the Ruby > Installer (1.9.2p0) and the binary version of RedCloth > (RedCloth-4.2.2-x86-mswin32-60.gem). It installs ok but then fails when > trying to load 'msvcrt-ruby18.dll'. Hi Daniel, One of the problems that you found was that the RedCloth binary gem was only built to support Ruby 1.8. RedCloth would need to provide a version of its native .so library linked against the Ruby 1.9 DLL in order to run correctly under Ruby 1.9.x. > I have successfully used DevKit to compile and use RedCloth 4.2.3 in a > test system, but I would like to be able to create a Ruby Installer > compatible binary gem to distribute it with the installer (thus removing > the extra dependency on DevKit for end users). Is this possible? What is > the best way to do this? It's possible by creating what many call a "fat binary" gem. A fat gem is basically one that includes a version of their native library linked against 1.8 and a version linked against 1.9, both in the same gem. At runtime, the gems code determines what Ruby version it's running under and loads the correct native library. Two well known libraries that do this are https://github.com/tenderlove/nokogiri and https://github.com/luislavena/sqlite3-ruby I believe the authors of these mingw binary fat gems build them on Linux or OSX using the tool https://github.com/luislavena/rake-compiler which makes it easy for *nix-based gem authors to provide fat binary gems for their Windows users. It would be great to have a fat binary RedCloth :) If you have any questions on the rake-compiler tool after you check it out, search our group at http://groups.google.com/group/rubyinstaller and if you can't find anything that helps, post a question. Luis (author of rake-compiler) can point you in the right direction. Jon
on 2010-11-20 15:55
Daniel, I've been hard at work the last couple weeks on RedCloth. Give the master <https://github.com/jgarber/redcloth> a try and let me know how it goes. You'll need rake-compiler to cross-compile the fat binary like Jon mentioned. There is a very specific version of Ruby you need to make it work (1.9.1-p243), so use rvm as well. rake gems:build should take care of everything, then. Thanks for giving it a test run. I'm hoping to release it soon if I can get a Java expert to help me fix the JRuby whitespace problem. Jason
on 2010-11-21 23:02
Thanks Jon and Jason, After some tweaks I was able to get the gem cross-compiled (from master). First thing I had to do was amend the Rakefile to include after 'rake/clean' the following: require 'rake/gempackagetask' Otherwise I would get an error running rake. After that I installed ragel, rake-compiler, mingw32 and got that up and running. Running rake gems:build also worked. It created a lib/redcloth_scan.so and lib/1.9/redcloth_scan.so and a pkg/redcloth-4.2.3.gem Unfortunately this .gem didn't contain any of the .so files. Copying the gem across to the Windows box would install Ok but then fail when requiring 'redcloth' with: no such file to load -- 1.9/redcloth_scan So I copied the 1.9/ folder to by windows <rubygems\redcloth> path and it worked like a charm. I guess that there is some tweaking around to be made in the gemspec to ensure that the .so files are included in the gem file. Is this an easy fix? I'm asking because I've never distributed a Gem myself and I was thinking that probably someone with more experience will spot the issue more quickly. Many thanks for your help, Daniel
on 2010-11-23 06:57
Daniel, I've fixed the README to include instructions about bundler and rvm and fixed the gem build tasks to include the proper files. I tested it on Ruby installer 1.9.2p0. You can try it out by pulling the latest from master or use the pre-compiled one I pushed up to rubygems.org with rake install RedCloth --pre Let me know how it goes! Jason
on 2010-11-23 09:00
Hi Jason, This worked. I didn't have to touch the Rake file and the .so files were included in the gem. The gem ran flawlessly on the Windows box. Many thanks for your support on getting this up and running. The only thing I had to tweak was to comment out tasks/gems.rake#18 rvm ruby-1.8.6-p398@redcloth rake cross compile RUBY_CC_VERSION=1.8.6 This is because my rake-compiler only had support for 1.9.1 but that is more specific to my case. I reckon that the hole rake-compiler business is a bit messy for people not familiar with it so maybe adding a couple of basic steps in the README will help people out. Something along the lines of what you have when running rake build:win if rake-compiler is not properly configured. Or maybe a wiki page in GitHub on how to get everything up and running for cross-compilation (and a reference to it in the README). Let me know if you need a hand with documentation, I'm more than happy to spend some time putting that together if you think it would be of use. Otherwise I may just write a blog post so I have it for myself in case I need to run through this again. Anyways, thank you very much for your time, Daniel
on 2010-11-23 15:43
Great! The thing with not having 1.8.6 installed for rake-compiler is because a warning message that you don't have it installed only shows up when you don't have *any* rubies installed for rake-compiler. Thus, you didn't see it. I added it to the compile steps in the README per your suggestion. Thanks! That should save people a lot of trouble. Best, Jason
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.