Archive for the 'fixes' Category

16
Jul

Multiple renaming utilities: mmv

There are many multiple file rename utilities that you can dig up.

One that I am used to on Debian/Ubuntu-based distros is called rename which is one that is derived from the Perl Cookbook. However, note that this rename script does not seem to exist on other UNIX variants in a packaged format. It definitely does not seem to exist on a Fedora Core 9 box I use nor does it exist on a FreeBSD machine.

While it would not be too hard to swipe the perl script and copy it in place onto a system. I hate having to remember moving that script around and around with me from place to place so I looked around for other equivalents and found one called mmv. One nice thing is that there are packages for at least FreeBSD, FC9, and Debian/Ubuntu variants so it should be quite lazy to install compared to rename.

Below I give an example of using it to do a multiple renaming where I want to append the value 1 to the end of a bunch of filenames.

$ ls
cat_100  cat_15  cat_200  cat_50  cat_500
$ mmv cat"*" cat#1_1
$ ls
cat_100_1  cat_15_1  cat_200_1  cat_500_1  cat_50_1
03
Jul

svnbackup-restore.rb, svnbackup’s handy companion tool

Doug Hellman’s svnbackup script tool is a really handy tool for setting up automated backups for a subversion repository.

However, the non-fun time comes when one wants to restore a subversion repository that has way too many dumpfiles parts. The instructions for restoration are basically ‘roll your own’ if you want to try to automate the restore procedure. What would be nicer is if there was the converse tool that made it easier to not have to figure out how to re-order the backup files in the proper manner in order to perform the restore.

I spent a few minutes thinking about it and wrote a small Ruby script to help with this that I call svnbackup-restore.rb. Here is the (hastily written) source code. (Download here)

#!/usr/bin/ruby
# Program Name: Restore the restore
# Purpose:      Take all the svn dumpfiles generated from svnbackup
#               sort them and try loading them via svnadmin
# Usage:        1. Create the new repo path with svnadmin create
#               2. Set repo_name to the repo backup file names
#               3. Set restore_path to the new path to restore to
#               4. Run it ./svnbackup-restore.rb
# Assumptions:  svnrestore-backup.rb is in the same dir as the svn dump files

# CHANGE PARAMETERS HERE
repo_name = 'myrepo'
restore_path = '/path/to/myrepo'

# Print out debugging?
DEBUG = true

# DON'T CHANGE BELOW

# Filename format is 'dumpfile---.bzip2'
svn_dumpfiles = Dir["dumpfile-#{repo_name}*.bzip2"]
sorted_files = svn_dumpfiles.sort do |a, b|
  left_rev = a.split(’-')[2].to_i
  right_rev = b.split(’-')[2].to_i
  left_rev  right_rev
end
sorted_files.each do |dump_part|
  results = `bzcat #{dump_part} | svnadmin load #{restore_path}; echo $?`
  puts results if DEBUG
  res = results.split.last.to_i
  if res != 0
    puts “Error on trying to load up #{dump_part}!”
    exit 1
  end
end
12
Jun

Can’t install anymore extensions in Firefox 3? Kill extensions.rdf

I’ve been trying out Firefox 3 and one strategy I do is to copy my Mozilla Firefox folder with me to whatever machine I go to so I don’t have to reinstall plugins, re-enter all my passwords, and configure everything about Firefox until I’m happy.

However, it seems due to some reason or another I lost the ability to install extensions. After Googling around I dug up a nice hint on Ubuntu’s Launchpad site.

Basically delete the file named extensions.rdf in your Mozilla directory

  • Windows: C:\Documents And Settings\[Username]\Application Data\Mozilla Firefox\
  • Linux (Fedora 9 and Ubuntu 7.10): $HOME/.mozilla/firefox/profile/MY_PROFILE/

Read the Ubuntu fix

30
Apr

One way to clean out a gazillion files in a directory without causing the server to hang on IO

Had a case where I had some rails app that was using files for its session store and had been running like that for months. While it was a careless (and dumb) thing to run it that way, we had to do something about it since it was eating up close to 85% of the system partition. The dumb way to try to do this is below:

nice find /tmp/ -name 'ruby_sess.*' | xargs -n 100 rm -fv

However, the problem is that this causes insanity on IO which is NOT good for a running service. (Luckily this service was merely important instead of critical) So, I present to you my quick and dirty script that will clean up all those nefarious ruby sessions files that have run amok for months.

while true; do
    nice find /tmp/ -name 'ruby_sess.*' | head -n 20 | xargs rm -fv; sleep 10
done
14
Apr

OS X 10.4.11 update, you suck

After a long time of not updating my trusty old iLamp iMac, I finally updated it to 10.4.11 over the weekend and let it lie. Later on I hear a report that Safari won’t start up.

That’s odd, I’ve never heard of Safari having launch problems before. I check the log and I see something like the following:

Date/Time:      2008-04-14 22:06:45.474 +0900
OS Version:     10.4.11 (Build 8S165)
Report Version: 4

Command: Safari
Path:    /Applications/Safari.app/Contents/MacOS/Safari
Parent:  WindowServer [86]

Version: 3.1 (4525.13)

PID:    20987
Thread: Unknown

Link (dyld) error:

Symbol not found: _WebDatabaseDirectoryDefaultsKey
  Referenced from: /Applications/Safari.app/Contents/MacOS/Safari
  Expected in: /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit

Those type of messages go on and on in Console.app. My first round of Googling brought me to a Macrumors thread that recommended deleting the history.plist and other parts from ~/Library/Safari. I tried removing various files from that directory to no effect and finally just removing the directory altogether. Nada.

Troubleshooting a PC WITHOUT a web browser really sucks. I suggest everyone try it once in awhile to see just how much the nature of debugging IT problems has changed when you are deprived of a very powerful tool. Luckily, this Mac had a very crufty version of IE lurking so the first thing I tried was a download of Firefox. However, the disk image refused to be mounted! Seems this is also tied in with the security update. So basically, I’m left with using IE as my main tool for debugging on this Mac.

After a bit of googling, it seems that the fix is tied requiring the latest OS X security update (Available at the Support Download page). For OS X 10.4.x users you can find a link to the latest Universal here.

However, there is a catch. The security update is only available from that page as a Disk Image. Guess what you can’t open it up under the affected Mac. At this point you’re left with 2 options:

  1. Burn the Disk Image to a CD-R/DVD-R and use it that way
  2. Transfer the disk image to another Mac and unarchive it then push it back

I decided on the latter option since I hate wasting a CD-R if I don’t have to. After applying the Security Update and rebooting, Safari boots up and things seem chipper again but that was a serious side trip on something I’ve rarely seen Apple ever mess up. Anti-kudos to Apple for making this update on your ‘legacy’ OS really sucky.

10
Apr

Fixing that really irritating perl: warning: Setting locale failed. on OS X leopard

Anytime I’ve been running a perl based script on my leopard box I got this really irritating output with whatever else I was expecting:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
     LC_ALL = "En_US",
     LANG = (unset)
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

With a quick Google search I found an answer in this Rubify post. Basically the solution / fix is to make sure the following is set in either your ~/.profile or ~/.bashrc or ~/.cshrc

# This setting is for the new UTF-8 terminal support
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Read more at Rubify!

07
Apr

Data center used to heat swimming pool

I love reading about these smart uses of waste byproducts I bet this might work well in Japan if it wasn’t for those pesky earthquakes.

A new data center in Switzerland is being used to heat a nearby swimming pool. In what appears to be a first, the town pool in Uitikon, Switzerland will be heated by waste heat from a data center

Read more at Datacenter Knowledge

21
Mar

Getting erlang to build on MacPorts with an installed iPhone Open SDK

I had some serious unexpected fun trying to install erlang on my OS X box using MacPorts. In general it’s usually a no brainer you usually type sudo port install <foo> and you have a new package installed without that much fuss. However here is the partial log of trying to install erlang and it blowing up…

$ sudo port install icu erlang
... ICU installs without a problem ...
--->  Fetching tcl
--->  Attempting to fetch tcl8.5.1-src.tar.gz from http://downloads.sourceforge.net/tcl
—>  Verifying checksum(s) for tcl
—>  Extracting tcl
—>  Configuring tcl
—>  Building tcl with target all
Error: Target org.macports.build returned: shell command ” cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix” && make all ” returned error 2
Command output: /usr/bin/gcc-4.0 -c -Os -O2 -pipe    -Wall -Wno-implicit-int -fno-common -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../generic -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../libtommath -DPACKAGE_NAME=\”tcl\” -
…
…
…
_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c
In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:62:
/usr/local/include/mach-o/arch.h:35: error: nested redefinition of ‘enum NXByteOrder’
/usr/local/include/mach-o/arch.h:35: error: redeclaration of ‘enum NXByteOrder’
/usr/local/include/mach-o/arch.h:36: error: redeclaration of enumerator ‘NX_UnknownByteOrder’
/usr/include/architecture/byte_order.h:137: error: previous definition of ‘NX_UnknownByteOrder’ was here
/usr/local/include/mach-o/arch.h:37: error: redeclaration of enumerator ‘NX_LittleEndian’
/usr/include/architecture/byte_order.h:138: error: previous definition of ‘NX_LittleEndian’ was here
/usr/local/include/mach-o/arch.h:39: error: redeclaration of enumerator ‘NX_BigEndian’
/usr/include/architecture/byte_order.h:140: error: previous definition of ‘NX_BigEndian’ was here
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c: In function ‘TclpFindSymbol’:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:382: warning: ‘NSLookupSymbolInImage’ is deprecated (declared at /usr/include/mach-o/dyld.h:182)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:415: warning: ‘NSLinkEditError’ is deprecated (declared at /usr/include/mach-o/dyld.h:217)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:419: warning: ‘NSLookupSymbolInModule’ is deprecated (declared at /usr/include/mach-o/dyld.h:181)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:428: warning: ‘NSAddressOfSymbol’ is deprecated (declared at /usr/include/mach-o/dyld.h:188)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c: In function ‘TclpUnloadFile’:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:493: warning: ‘NSUnLinkModule’ is deprecated (declared at /usr/include/mach-o/dyld.h:169)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c: In function ‘TclpLoadMemory’:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:697: warning: ‘NSCreateObjectFileImageFromMemory’ is deprecated (declared at /usr/include/mach-o/dyld.h:146)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:730: warning: ‘NSLinkModule’ is deprecated (declared at /usr/include/mach-o/dyld.h:161)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:732: warning: ‘NSDestroyObjectFileImage’ is deprecated (declared at /usr/include/mach-o/dyld.h:147)
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_tcl/work/tcl8.5.1/unix/../unix/tclLoadDyld.c:740: warning: ‘NSLinkEditError’ is deprecated (declared at /usr/include/mach-o/dyld.h:217)
make: *** [tclLoadDyld.o] Error 1

Error: The following dependencies failed to build: tk tcl
Error: Status 1 encountered during processing.

Pretty sucky, huh? My first lazy thought was, “I thought the point of a package manager was to avoid all these problems.”

After a little bit of thinking and staring at the error message, I did the workaround and moved the /usr/local/include directory away and tried rebuilding which made things much happier. Check the log below…

$ cd /usr/local
l$ ls
arm-apple-darwin	include			man
bin			info			share
docs			lib
etc			libexec
$ sudo mv include include.ignore
l$ sudo port install icu erlang
Skipping org.macports.activate (icu ) since this port is already active
--->  Cleaning icu
--->  Building tcl with target all
--->  Staging tcl into destroot
--->  Installing tcl 8.5.1_0
--->  Activating tcl 8.5.1_0

Voila. A working erlang install. Don’t forget to move back the include directory back to its old place.

10
Mar

Rereading a disk partition table in Linux without rebooting

Ran into a problem with trying to partition up a disk on a running system. The idea is I wanted to create a new partition on a disk with partitions already mounted and use it without rebooting.

Here’s what you’ll mostly likely run into…

# sudo fdisk /dev/sda
... Steps for adding disk  elided ...

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

ahoang@jp-db-3:~$ sudo mke2fs -m 0 -j /dev/sda3
mke2fs 1.40.2 (12-Jul-2007)
Could not stat /dev/sda3 --- No such file or directory

The device apparently does not exist; did you specify it correctly?

# ls -la /dev/sda*
/dev/sda   /dev/sda1  /dev/sda2

The simplest thing to do is just reboot and Linux will redetect everything on restart. However, sometimes you just can’t reboot. After Googling around it seems that partprobe does the job handily. Luckily this tool is already on an Ubuntu system so no need to apt-get install but it’s only a few keystrokes away.

Here’s the rest of the log once I ran partprobe and was humming along…

# sudo partprobe
# ls /dev/sda*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3
# sudo mke2fs -m 0 -j /dev/sda3
mke2fs 1.40.2 (12-Jul-2007)
... Creating a file system output elided ...
06
Feb

How to play mplayer in the desktop fullscreen on Ubuntu

I was experimenting with trying to play videos in the desktop background so I can work on other things while passively watching videos that I really didn’t want to spend 100% of my concentration on. However when I tried to use mplayers -rootwin option under Ubuntu it did not show anything.

After doing some Googling around, it seems that the problem is tied with how rich desktop environments like KDE and Gnome manage the ‘desktop’. They normally override the traditional X11 root window with their own which means that sending output to rootwin won’t show anything.

However, luckily there are ways around this. One post on the mplayer list mentioned ways to disable background handling by GNOME and KDE. However I could not get this working under Gnome. After some more Googling around I found that Lifehacker had a hint on how to enable screensavers in the background. So using that information it was rather simple. The recipe for Ubuntu is:

# Tell GNOME to not handle the desktop
$ gconftool-2 –type bool –set /apps/nautilus/preferences/show_desktop false
# Play a video file in the rootwin as fullscreen
$ mplayer -rootwin -fs my_cool_video.avi

30
Nov

Some long term thoughts on using a Kohjinsha SA1F00V

Awhile back I bought a Kohjinsha SA1F00V to test it out as a lightweight Tablet PC. After a few months of usage, I can say that I’ve not been that impressed with the device but neither have I been so frustrated with the device that I felt the need to toss the thing out the window.

The Bad

Annoying default partitioning scheme

I hate these laptops that advertise the hard drive size (40Gigs) then you get some weird partitioned scheme that you didn’t ask for
(with of course a few more gigs knocked off for a recovery partition). What this means is that you really only get 16GB or 19GB but not the full 40GB - (Win XP + Bundled Garbage) thanks to these partitions if you’re not willing to suck it up and reinstall the preinstalled OS

Slow

Yes it’s slow as a dog. This is one of those things that I wish you could test drive at the store by being allowed to install a stack of apps that you like and play around with it for a couple of hours. Once I loaded up an AntiVirus program, iTunes and Firefox life got pretty miserable trying to use iTunes and Firefox together. Also, the virus scan just slows the machine down each time I boot up Windows since it feels compelled to download updates and run full disk scans when I’m planning on using it. *sigh*

Keyboard tactile is awful

There have been other reviews on the keyboard not being that great and I’ve even came to the conclusion it wasn’t that great before I picked one up but decided to forge ahead anyways. After using it for a longer period of time I realize a crappy keyboard makes it very annoying to do anything requiring serious input on it without readjusting your brain how to type well on it.

Graphics drivers don’t support monitor mirroring

This is really bizarre and disappointing. I came up with a plan to try to use it as a cheap tablet by mirroring the output of the display to a larger monitor and drawing on the 7″ screen however the drivers for some inexplicable reason don’t have mirroring support which sucks. I spent some time trying to see if I could just use the touchscreen while outputting to an external monitor but it’s really disorienting. Even some SLIGHT visual feedback on the 7″ touchscreen itself would have been REALLY helpful.

The Good

Okay now that you’ve read some of my more outstanding gripes on the device. Here are some things that I considered nice about the Kohjinsha

Not a complete ripoff

The price point wasn’t that bad considering you do get lightweight tablet functionality

Standard components

The parts that most people will fiddle with are mostly standard laptop components instead of weird proprietary junk. The hard drive is a normal 2.5″ PATA drive which you can swap out if you try instructions like these (I just did). The memory is standard SO-DIMM instead of Micro DIMMs which saves a bit on price.

Portability

This thing is easy to toss into a bag and be mobile with it. I’ve even held it one handed while traveling on the train from Yokohama to Tokyo and that didn’t kill my arm (try that in a crowded train you 17″ notebook warriors)

Decent battery life

The battery life is around 3-4 hours with the usage that I do

Standby when the lid closes doesn’t suck

I’ve had so many variables with trying to get a Windows laptop to sleep when I close the lid compared to a Mac. I’m happy to say the Kohjinsha does the job without requiring a lot of fiddling with anything. Perhaps if I was a heavier power user on it I’d bork the drivers to prevent it but in my usage it worked which was a lifesaver when you’re trying to catch a train transfer.

Better than the rest of the PDAs at reading PDFs

The design of the Kohjinsha makes it a very good platform for reading stuff while on the move. I’ve tried a Zaurus, Palm, and a couple of other PDAs and reading novel or long textbook type of stuff was very painful due to screen resolution and slowness of the platform. I can say that the Kohjinsha makes a better eBook reader than these other solutions.

09
Nov

Fix the ‘missing key: categories: Cannot read the portsdb!’ for portupgrade

I ran into this exact problem when trying to upgrade a bunch of ports lying around on my FreeBSD system.

Luckily Well-Rounded documents the fix for this. You’ll have to upgrade portupgrade manually to rebuild its database with an updated version.

07
Apr

Linux and the MSI-7265, the final straw

I’ve written before before on my battles with Linux and Core 2 Duos. After waiting a long time for Feisty to get closer to a release state I loaded up Feisty (after some initial install pains. The alternate install CD recognizes enough to install but the desktop version doesn’t and requires a USB CD-ROM or something)… I hit the final straw my efforts to get to my ORIGINAL plan months ago of working with virtualization on Linux.

$ sudo modprobe kvm-intel
FATAL: Error inserting kvm_intel (/lib/modules/2.6.20-14-generic/kernel/drivers/kvm/kvm-intel.ko): Operation not supported
$ dmesg | tail -n 2
[ 176.258182] kvm: disabled by bios
[ 1198.635777] kvm: disabled by bios

For the record I have:

  1. A 2.6.20 based linux kernel that DEFINITELY supports kvm (Pending hardware)
  2. Definitely a CPU that supports extensions
  3. Enabled VT extensions in the BIOS

What the hell? I can only surmise it’s this stupid MSI-7265 motherboard that I’ve been trying to live with for the past X months. In my past post I read in a review it is a no-frills motherboard that is ‘lean and mean’. Well I’ve about had it with ‘lean and mean’. Give me a stupid motherboard that isn’t brain damaged in the BIOS. I’m going to start shopping for less sucktactular alternatives. If anyone has recommendations I’m more than happy to hear any.

07
Feb

Migrating instiki from one database type to another

The Rant

Instiki is one of the premier wikis for Ruby on Rails which is another way of saying the other rails-based solutions don’t look that great so far from what I’ve seen. Here is an except from the instiki website:

1. Download
2. Run “instiki” with Ruby 1.8.4 or greater. (on windows, that’s instiki.cmd)
3. Chuckle… There Is No Step Three™! :) (See note)

Yeah, nice and simple… to install. Here’s some facts that instiki DOESN’T tell you without digging around:

  • It uses sqlite as its database backend to store all wiki information (except images and file uploads).
  • It’s NOT Rails 1.2.x ready
  • It was written BEFORE ActiveRecord and was migrated to ActiveRecord later
  • You can export your data but have no way to import your data easily (more later)
  • The documentation from a USER perspective is pretty sparse
  • Active development seems to be moving at a snail’s crawl

So what does this all mean? Well, if you want to migrate your instiki instance to a different instance you’d like to think you have a couple of options.

  1. Just copy the whole application to the new server, kickstart done (This works)
  2. Dump out the wiki in some export friendly format and re-import it back in

Option #1 works quite well however if you want to switch database backends you’re stuck with option #2. However save yourself hours of time (I didn’t) and DON’T try the following things (unless you’re a rails god. In which case why are you reading this?)

  • Try exporting the wiki in textile format and importing it…. oops import is busted. A stub is there (http://localhost:2500/wiki/import) but it is definitely broken
  • Dump the sqlite database with sqlite utilities then re-import them into target database. This doesn’t work with MySQL as far as I know. I bet it’s broken with Postgresql too
  • Look at the source code
    to find where the issue might be. Don’t worry, even the changelogs say import is busted and there is no other sign of some way to input data easily
  • Write some tool to import textile in. That would require reading the APIs, right? bleh
  • Write some sort of ActiveRecord translator? Well sort of… but it’d be nice if there was a tool available. And if you’re not a rails guru you’re sort of screwed in this case.

Now I’m sure DHH (the creator of instiki) will grumble about something about this not being ‘appropriate’ for its original intentions and blah-blah. Gee that’s nice. Maybe you better put that down in the caveats, before I commit a whole bunch of data into it.

The Fix

Okay, enough ranting about half-baked Open Source Rails apps. Here’s the fix.

1. Add plugin script to instiki app

Most normal rails app will include a file called plugin inside $RAILS_ROOT/script/plugin. Unfortunately, instiki doesn’t include it. Luckily the script is really small since it just calls out to the rails framework to handle most of the hardwork. So try this:

$ echo "
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
" >> $INSTIKI_HOME/script/plugins
$ chmod +x $INSTIKI_HOME/script/plugin  # Make it executable
2. Install the manage_fixtures plugin

I’m afraid I don’t have time to explain what a Rails Fixture is in this post but just think of it as a portable way of representing data going into a database for rails. It works well but don’t try hundreds of megabytes of data.

I also won’t go much into rails plugins except to say it’s a way of extending a rails application with more functionality (probably for a Rails developer rather than an end user of the application). We’re going to use a really sweet tool called manage_fixtures which allows us to move around data between different databases with ease (assuming the rails app isn’t doing weird SQL crap).

$ cd $INSTIKI_HOME
$ script/plugin discover    # Hit enter a gazillion times
$ script/plugin install manage_fixtures
3. Export the data into fixtures

The following will export all your db entries as fixtures into $INSTIKI_HOME/test/fixtures. You need to set the RAILS_ENV to production because by default it will try to use the development database.

$ cd $INSTIKI_HOME         # You SHOULD be here anyways
$ RAILS_ENV='production' rake  db:fixtures:export_all
4. Change the database connection to desired

Now change the file in $INSTIKI_HOME/config/databases.yml from:

production:
  adapter: sqlite3
  database: db/production.db.sqlite3

to the following (adjust mysql parameters to suit your setup)

production:
  adapter: mysql
  host: localhost
  database: instiki
  username: root
  password:
4. Create database and the appropriate tables

The following commands will create a database named instiki (or whatever you put in databases.yml) and make sure the database schema in the database matches instiki’s schema.

$ echo "create database instiki" | mysql -u root
$ RAILS_ENV='production' rake migrate
5. Finally re-import the data from fixtures

Whew! Finally we can re-import the data into MySQL (or whatever) and continue on using instiki for something.

$  RAILS_ENV='production' rake db:fixtures:import_all
21
Dec

gem install mysql failing on Ubuntu fix

The problem

Did you try something stupid (and expect something hopeful) like:

$ sudo gem install mysql

Then get something beautiful like:

ERROR:  While executing gem ... (RuntimeError)
    ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.

Welcome to getting bit by the
policy of the Debian packaging policy problem where one software package can be split into muliple pieces. In general the policy makes sense unless you’re doing development then you have to remember this.

The fix

Assuming you installed mysql server via something like sudo apt-get install mysql-server the next thing you need is the MySQL development headers in order for the Ruby Gem to compile. Simple eh? sudo apt-get install mysql-dev. Well not that but close. It’s (because you need to specify the particular version of development libraries very often):

$ sudo apt-get install libmysqlclient5-dev

Now back to business

$ sudo gem install mysql
Select which gem to install for your platform (i486-linux)
 1. mysql 2.7.1 (mswin32)
 2. mysql 2.7 (ruby)
 3. mysql 2.6 (ruby)
 4. mysql 2.5.1 (ruby)
 5. Cancel installation
> 2
Building native extensions.  This could take a while...
[snip]
creating Makefile

make
gcc [stuff]
gcc [stuff]
make install
mkdir -p /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib
/usr/bin/install -c -m 0755 mysql.so /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib

make clean
Successfully installed mysql-2.7

Now back to business.




Pages

 

September 2008
S M T W T F S
« Jul    
 123456
78910111213
14151617181920
21222324252627
282930  

Badge Farm

  • Firefox 2
  • CSSEdit 2
  • Textmate
  • Powered by Redoable 1.0

Protected by AkismetBlog with WordPress