Archive for 'Ruby on Rails'

RMagick & ImageMagick from Source: Mac OSX Leopard

Wednesday, April 9th, 2008

The Problem

I know that there are a lot of dependencies that go along with installing RMagick from source on Leopard.  For this reason, I was very interested in the idea of packing all of the commands into a script and just letting it run.  If you are like me, your past with scripts has been grey at best; i.e. there always seems to be some sort of problem that kills your script. Then you have to search through it to find where it broke and you spend a lot of time aligning yourself with something that might not even work.

The reason most of these scripts will fail is that references are now broken or code deprecated. If it fails, I then have to make sure that http://whatever.com still exists and is hosting the file and version that I need. I got to thinking… so often I would like (at least) the option of using something that is a bit older, but can be run smoothly.

The ‘Dependencies’/Libraries

This script uses Ruby to install ImageMagick and RMagick, with the necessary dependencies for gif, jpg, png, freetype, tiff, libwmf (?), littlecms (?), and ghostscript (?).  It rely’s on these libraries:

JPEG:
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

PNG:
http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.22.tar.bz2

Freetype:
http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz

TIFF:
ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz

http://jaist.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz

LittleCMS:
http://www.littlecms.com/lcms-1.17.tar.gz

Ghostscript:
ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz

Ghostscript Fonts:
ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz

ImageMagick:
ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.8-11.tar.gz

When I found this script these URLs were built in so that if one of the URLs didn’t work, it would break. That is fine, but it is not built to find the newest and greatest, or make sure that the newest still works with everything else. So why not just package all of those url’s libraries together and make that downloadable here. I may be breaking a law or something… (if I am let me know) but I think these are all open-source.

The Instructions

So here is how it is done.

Download the zip (39.5 MB)
– Unpack it
– Open Terminal.app

cd /to/inside/the/unzipped/dir
ruby setup.rb

Now just let it run. (You may have to put in your password every once in a while because of the ’sudo’s).

I should also note that I had X11 (Applications > Utilities > X11) and Xcode 3.0 (Macintosh HD > Developer > Applications > Xcode) installed when I ran this script.  I am not sure how much this helped/effected the script running, but I do have these installed and runnable.

The Original

Again, a special thanks to Solomon White who originally posted this script at his blog.

Here are some other references for this technique.

John Ford:
http://www.aldenta.com/2007/11/26/installing-imagemagickrmagick-on-leopard/

Ben Reubenstein:
http://www.benr75.com/articles/2008/03/16/install-rmagick-on-mac-os-x-leopard-from-source

Here is what I found at Solomon’s website.

#!/bin/sh
curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
tar xzvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.22.tar.bz2
tar jxvf libpng-1.2.22.tar.bz2
cd libpng-1.2.22
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
tar xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b
ln -s `which glibtool` ./libtool
export MACOSX_DEPLOYMENT_TARGET=10.5
./configure --enable-shared --prefix=/usr/local
make
sudo make install
cd ..

curl -O ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz
tar xzvf tiff-3.8.2.tar.gz
cd tiff-3.8.2
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O http://jaist.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz
tar xzvf libwmf-0.2.8.4.tar.gz
cd libwmf-0.2.8.4
make clean
./configure
make
sudo make install
cd ..

curl -O http://www.littlecms.com/lcms-1.17.tar.gz
tar xzvf lcms-1.17.tar.gz
cd lcms-1.17
make clean
./configure
make
sudo make install
cd ..

curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz
tar zxvf ghostscript-8.60.tar.gz
cd ghostscript-8.60/
./configure --prefix=/usr/local
make
sudo make install
cd ..

curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz
tar zxvf ghostscript-fonts-std-8.11.tar.gz
sudo mv fonts /usr/local/share/ghostscript

curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.8-11.tar.gz
tar -xzvf ImageMagick-6.3.8-11.tar.gz
cd ImageMagick-6.3.8
export CPPFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts
make
sudo make install
cd ..

sudo gem install rmagick

Deprec2- chgrp: invalid group

Wednesday, March 19th, 2008

I was using deprec2 to install RoR, MySQL, Nginx, etc. to Slicehost using the crack_the_nut instructions on my mac.  I came to where I had to run the rails_stack (cap deprec:rails:install_rails_stack) and I kept getting an error that said “chgrp: invalid group deploy”.

Deprec automatically creates the deploy group as part of it’s recipes.  I was stunned.  Upon looking for an hour or two I came across a ‘grep’ that deprec runs.  It runs “sudo -p ’sudo password: ‘ grep ‘deploy:’ /etc/group || sudo /usr/sbin/groupadd deploy”.  This grep checks the /etc/group file for any occurances of ‘deploy’. My deploy user was named pd_deploy.  Users live in the /etc/group file under their group following the following convention:

group: user1,user2,user3

My /etc/group file contained the following:

admin:root,pd_deploy

Deprec found ‘deploy’ in my user, pd_’deploy’, and thought that the group already existed.  It therefore failed to create a new one and blew up when it was trying to change a group that did not exist.

To save yourself a lot of hassle, don’t have ‘deploy’ anywhere in your /etc/group file, meaning, don’t have a user with ‘deploy’ anywhere in the name.  So no ‘deployuser’ or ‘user_deploy’.

Ruby on Rails: Upload Column (Not Found) issue

Tuesday, September 4th, 2007

So I have been working my way through this Ruby on Rails/Object Oriented Programing business and have been loving it. I have now set up on a PC. I have been using the NetBeans Ruby IDE which is amazing because it has everything setup for you. I use WAMP as my development web service and MySQL database. My most recent problem was with the Upload Column plugin. I had the Upload Column plugin installed, but every time I ran the app and tried to upload a photo I got a URL ‘NOT FOUND’ Webrick error. It was frustrating mostly because there was no documentation for any fixes.

Sadly, instead of fixing the issue I assumed it was something with NetBean’s setup for webrick and decided to try “Instant Rails” which uses Mongrel instead of Webrick. This change was successful and now Upload Column works perfectly fine. If you know how to do this, go for it. I will paste my steps below.

  1. Download Instant Rails at http://rubyforge.org/frs/?group_id=904
    (note where you will run instant rails from… I just put mine in ‘C:/’)
  2. Inside of NetBeans follow: TOOLS > OPTIONS > MISCELLANEOUS > RUBY
  3. Change the ruby interpreter to you your Instant Rails folder… Mine looks like ‘C:\InstantRails\ruby\bin\ruby.exe’
  4. Might have to download sync-stdio.rb and put it in your NetBeans Ruby IDE folder. Mine is ‘…/nbrubyide/ruby1/sync-stdio.rb’
  5. Then Run Instant Rails
  6. Install the appropriate gems in the ‘Ruby Console Window’ (Right click on the big ‘I’ in the system tray RAILS APPLICATIONS > OPEN RUBY CONSOLE WINDOW)
  7. Update your database using phpMyAdmin (also via Instant Rails’ system tray)
  8. In NetBeans Ruby IDE start your app

That should fix the “Not Found” error. Or at least it did for me. Let me know if I need to clarify anything else a little better. Thanks…

Subversion on Mac Instructions

Tuesday, May 15th, 2007

I have been looking and looking for a solution for Mac using subversion and have found NO streamlined instructions for how to setup and use subversion on a Mac. I have found a lot of helpful instructions in different areas which I will list here. These may explain some things better than others but I will explain what I did and what worked for me.

I have tried using all of the mac clients for subversion and have found no luck with any of them. I have found the best way to use subversion on the mac is by using the scplugin available at the tigris website. This is something like the third step but wanted it to be known that was my plan.

Getting subversion installed and usable

  1. Using your host admin panel, create a repository with users and passwords for you to use. You will need these later when you actually checkout the repositories.
  2. I am leaving this kind of vague because it depends on your host. I am using dreamhost for ruby on rails application development. Using DreamHost, I login at http://panel.dreamhost.com. Click Goodies>Subversion and then follow the instructions for creating a new repository.

  3. Now you are going to have to enable your mac to use subversion. Now we have to install the subversion client found at tigris’ website.
    1. Visit the subversion client download page.
    2. You are going to want to scroll down to the Mac options and choose the non-Fink universal binary .dmg.
    3. Download and run the installation for the subversion client. (I am using version 1.3.1)
  4. At this point in scplugin’s development tigris has not enabled a check for username and password so the first time that you access a project with subversion you are going to have to do it in terminal. For this reason we want to make sure that svn commands are accessible in Terminal.
    1. Open up terminal.
    2. Type svn in the command line. You should get “Type ’svn help’ for usage”.
    3. If you get a -bash error ‘command not found’ (like I did) you have to let terminal know where to look for your svn client in the .bash_profile file. Good instructions for this is in the Subversion Client installation area in Josh Buhler’s blog from 2005. Let me know if these somehow get outdated or you want me to go through them here.

  5. Now we have to install the SCPlugin so that we can use Subversion with finder. I have tried most of the other clients and have found this one to be the most secure and fully developed.
    1. Download the scplugin from tigris.
    2. Note: I had to download the 1.3 version because the Subversion client that I downloaded was 1.3.1.

    3. The SCFinderPlugin does not have an installer yet but they make it extremely easy to install. Unzip the file that you had downloaded and simply move the .plugin file into the Contextual Menu Items folder that is right next to it. They include a link to this folder on your computer so you are really copying the file onto your hard drive in the appropriate place.
    4. Now you should check to make sure that the scplugin is installed correctly. Right-click/control-click on a folder. There should be a subversion option at the bottom. If there is, it is installed correctly.

    Using subversion with SCFinderPlugin

    Like I said earlier, the first time you checkout the repository (associate your local copy with your online repository) you are going to have to do it in terminal. The SCPlugin does not check for your username and password so it will always fail if you try to check it out in finder before doing it in the terminal.

    1. Open Terminal.
    2. Navigate to a local folder you wish to check the repository out to.
    3. Type svn co http://url_to_your_repository.com
    4. Type in the username and password when prompted. All of the files (if any) should copy to your computer’s hard-drive. This is good even if you don’t have any files in your repository because it establishes the location and steps needed to access your subversion repository with the username and password. From now on you wont need to use terminal to do anything more with this repository.
    5. Note: If you have anymore questions about using or installing the SCFinderPlugin the Tigris website might help you.

    Now you can navigate (in Finder) to the folder that you checked out your repository to. If you right click on the top folder of the application you should have two extra commands ‘Subversion Commit…’ and ‘Subversion Update’. If these two commands are there you checked the repository out correctly.

    To use subversion, just make changes to the files you wish to and save them. Go to the main folder of your application and right-click. ‘Subversion Commit…’ will send all of the changes that you have made to the repository. To get changes that someone else has made select ‘Subversion Update’.

I am planning on updating this, cleaning it up, and adding some screenshots for help. If you have any questions please let me know. I know it is frustrating if you get lost and confused.