Sunday, November 14, 2010

Ripping CDs on Ubuntu 10.04

Previous: Candy OM for MongoDB and Ruby - FAIL

So, using RhythmBox to rip CDs seems to work (mostly), although it's excruciatingly slow. There's an additional annoyance, too, in that it gets confused after you've processed a few CDs (people have reported the problem after ripping between 2 and 6 CDs) and you have to restart it to get it working again. It turns out, as well, that just closing the application window doesn't really kill the darned thing. You have to go into System Monitor and shoot the background process in its sleep.

I checked the Ubuntu community docs and found a fair amount of information about CD ripping.

Though there's a warning about a bug in LAME that causes problems for Sound Juicer, I gave Sound Juicer a try because there seem to be a lot of positive comments about it online. After installing the gstreamer libs needed for mp3 support, Sound Juicer consistently and silently died the instant I clicked the button to start the rip. Since this behavior does not result in any mp3 files, it doesn't quite meet my needs. I found a posting on a 2008 discussion list in which someone described exactly the same problem. No one had replied with a solution.

Next up was RipperX, which managed to generate a few corrupted files before collapsing to the floor in a useless heap of bits.

RubyRipper sounded promising, so I tried it. Despite notes to the contrary online, I was unable to find any way to tell RubyRipper that I wanted mp3 output instead of ogg output. It did a good job producing ogg files, though. For all I know, it can do mp3 too, in some mysterious way.

Next I tried Asunder, another program listed on the Ubuntu site. This was simple to install, and didn't require any additional dependencies from off-the-beaten-path repositories or other tweaks:
sudo apt-get install asunder
It has a simple UI that offers a short list of popular audio formats, including mp3. It can also go out to CDDB and look up album information. I found it easy to use, much faster than RhythmBox, and it generated playable mp3 files. A winner.

Asunder has characteristics I appreciate in software: (1) It does just one job and does it well; (2) installation and use are intuitive enough that no user manual is needed; (3) it's packaged and distributed in a way that takes the technical burden off the end user.

Next: Installing Android SDK and Eclipse ADT on Ubuntu 10.04

Thursday, November 11, 2010

Candy OM for MongoDB and ruby - FAIL

Previous: Success with rvm and ruby 1.9.2

Installing Candy and incorporating it with my experimental Sinatra project consisted of doing an rvm install:
rvm gem install candy
and updating the Gemfile with
gem "candy", :require => "candy"
Easy and clean.

Unfortunately, I had no luck at all trying to run the basic Person class example given in the readme, or the Zagnut example, or indeed any other variations I attempted, whether standalone or integrated with the sinatra app. After about four hours of trying, I posted some encouragement on the candy discussion forum and expressed the hope that it will become functional soon. I plan to check back in a couple of months to see if it's working yet. I hope the author will continue working on it, because it's a good concept. (To be fair, he does warn that candy is in an alpha-alpha state.)

Candy has, at least, provided the inspiration I needed to work through the difficulties I was having with installing rvm and ruby 1.9.2. Those bits are now installed and working well. For the moment, I think I'll try to keep going without an object mapper and see how tedious that proves to be. That's probably better for the purpose of learning MongoDB well, anyway. MongoDB has a pretty straightforward API, and it may be sufficient just to wrap persistence logic in a helper class. That way, if I decide to move to an object mapper it should be possible to replace the persistence logic without affecting the rest of the code.

Next: Ripping CDs on Ubuntu 10.04

Success with rvm and ruby 1.9.2

Previous: Ruby 1.9.2, rvm, and Sinatra follies

So, I've spent a couple of evenings playing with Sinatra and MongoDB under ruby 1.8.7. I've learned a bit and made progress in getting Sinatra apps to run on localhost. When I reached the point that I needed an object mapper, I read the descriptions of the ones listed on the MongoDB site. MongoMapper looks really good; very well thought-out, very competently designed, very clean code. But another one, Candy, stood out for me because instead of mimicking the approach of ActiveRecord, it explicitly and unapologetically takes advantage of the unique, very non-relational characteristics of MongoDB.

Candy is relatively new code, and it requires ruby 1.9 as a baseline. That meant I had reached an appropriate point to re-try rvm and ruby 1.9.2.

Having installed rvm three times previously, making plenty of educational mistakes each time, I found the installation procedure easy and quick this time around. I left the system install of 1.8.7 in place, used rvm to install 1.9.2, and set 1.9.2 as the rvm default.

Next step was to ensure existing ruby apps would work under 1.9.2. I started my local Instiki instance and got this message:
Bundler couldn't find some gems.Did you run 'bundle install'?
I tried running 'bundle install' and got
'report-activate-error': Could not find RubyGem bundler
So, I tried 'rvm gem install bundler' and it worked. The 'bundle install' command then worked, too.

At that point Instiki started up normally. So far, so good! (I use Instiki for general notes and record-keeping, so it's in the nature of a "production" system for me. Getting it up and running is always the first order of business when I upgrade ruby.)

I changed to the directory where I've been playing with Sinatra and tried to start my test app. I have a Gemfile there, and when I ran 'bundle install' it appeared to download and install all the necessary gems under rvm.

When running cukes, specs, and the app itself I got a number of errors pertaining to files not found on 'require'. All these errors were due to require 'foo' instead of require './foo'. I expected this, since ruby 1.9.2 does not include the current directory in the ruby load path by default. Once I fixed that on a single line in a single file, everything that had been working before was working again under ruby 1.9.2. Nice!

I have some old side projects in rails that probably will not start. I'll get around to fixing them later. For now, I'm pleased to be up and running at last with rvm and ruby 1.9.2.

Next: Candy OM for MongoDB and ruby - FAIL

Wednesday, November 10, 2010

Ruby 1.9.2, rvm, and Sinatra follies

Previous: Ubuntu 10.04 upgrade: Summary

I recently reported success with installing Ruby Version Manager (rvm). It appeared to install and function correctly; or at least it didn't report any errors. I was able to get my local Instiki up and running with no difficulty.

I didn't do much with ruby since then, up until three days ago. I spent the next two evenings struggling to get things to work. Online resources are plentiful but unhelpful. It seems no one else has experienced the same issues as I have. That in itself suggests pibcak. I readily admit to noob status, but unfortuantely that's not enough information to get things working again.

In hindsight I would say I asked for trouble by trying to use three unfamiliar technologies at the same time: Ruby 1.9.2, rvm, and Sinatra. I saw several bewildering behaviors whose root causes I was unable to pin down:
  • require was sometimes able to locate gems and sometimes not; GEM_PATH was correct; I realized the current directory was no longer included in the ruby load path by default, and changed code accordingly; no luck.
  • It seemed as if public methods inherited by a subclass were treated as private methods at runtime.
  • In theory, you can write a Sinatra app file as a plain script and it will inherit from Sinatra::Application silently; alternatively, you can write the file as a ruby class that extends Sinatra::Base, and it will work the same. I found that with the former method, Sinatra recognized its routes and functioned as expected; when the main Sinatra app file was a ruby class, no routes were ever recognized. By the same token, cucumber and rspec only worked against a class file, and not against the plain script version of the same Sinatra file. So, I had a choice between being able to run cukes and specs, or being able to run the app.
I lacked the experience with these technologies to understand what was happening, or where the problem(s) were coming from.

I decided to eliminate the suspects one by one. I removed rvm and all traces of ruby from my system and installed ruby 1.8.7 the old-fashioned way, and got my little side projects up and running in that environment (as they had worked before). That gave me a baseline for exploring the new items, which I still want to learn about and use.

I began my investigation with Sinatra, running it under the (to me) more-familiar ruby 1.8.7. I observed the same odd behavior regarding the main app file, and it became obvious at that point that the public/private issue had to do with Sinatra and not with ruby 1.9.2. It seems to have something to do with the way Sinatra inserts its magical code under the covers.

I found a gem called cucumber-sinatra that generates a skeleton directory structure and an env.rb file tailored to work with Sinatra. Rather than trying to write my own env.rb from scratch, as I had been doing, I let cucumber-sinatra do its thing. Still no luck: It was either run the app or run the cukes, but not both.

The env.rb file generated by cucumber-sinatra looked like this:
# Generated by cucumber-sinatra. (Wed Nov 10 16:38:55 -0500 2010)
ENV['RACK_ENV'] = 'test'

require File.join(File.dirname(__FILE__), '..', '..', 'lib/my_app.rb')
require 'capybara'
require 'capybara/cucumber'
require 'rspec'

Capybara.app = MyApp

class MyAppWorld
include Capybara
include RSpec::Expectations
include RSpec::Matchers
end

World do
MyAppWorld.new
end
This still had the same odd behavior regarding inherited public methods. I was getting better at using Gemfile and bundle, but was no closer to having a usable environment. I found a github page by Aslak Hellesoy that had a slightly different sample env.rb file for cucumber-sinatra. It looked like this:
app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
require app_file
# Force the application name because polyglot breaks the auto-detection logic.
Sinatra::Application.app_file = app_file

require 'rspec/expectations'
require 'rack/test'
require 'webrat'

Webrat.configure do |config|
config.mode = :rack
end

class MyWorld
include Rack::Test::Methods
include Webrat::Methods
include Webrat::Matchers

Webrat::Methods.delegate_to_session :response_code, :response_body

def app
Sinatra::Application
end
end

World{MyWorld.new}
All that "app_file" business near the top of the file pertains to the plain script style of a Sinatra app file; that is, not a subclass of Sinatra::Base. I was happy to see the example because it suggested a way to set things up such that both cucumber and a web server could understand the file. Using this as an example, I set up an env.rb file for a small test app like this:
ENV['RACK_ENV'] = 'test'
app_file = File.join(File.dirname(__FILE__), '..', '..', 'lib/my_app.rb')
require app_file

Sinatra::Application.app_file = app_file

require 'rspec/expectations'
require 'rack/test'
require 'webrat'

Webrat.configure do |config|
config.mode = :rack
end

class MyWorld
include Rack::Test::Methods
include Webrat::Methods
include Webrat::Matchers

Webrat::Methods.delegate_to_session :response_code, :response_body

def app
Sinatra::Application
end
end

World{MyWorld.new}
With this env.rb file, I can run
bundle exec cucumber features
and I can run the app in a web browser. I'm not crazy about it and I don't fully understand how it works, but at least it works and I can proceed with development while gradually learning more about Sinatra.

I posted a question on Twitter about these problems, and three people offered help. But they're not at my beck and call, and I need to learn about these things anyway.

Now that I have a working ruby 1.8.7 environment again, my next step will be to install rvm and bring up a 1.8.7 environment, then to ensure everything that's working now works the same way in that environment. That will give me a basis to explore ruby 1.9.2 with a bit more clarity about where the differences lie. Once I get rvm working properly, I can install 1.9.2 under its control without losing my functional 1.8.7 environment. All good; but it will take this noob some time to get there.

Next: Success with rvm and ruby 1.9.2

Monday, November 8, 2010

Ubuntu 10.04 upgrade: Summary

Previous: Ubuntu 10.04 upgrade on Toshiba Satellite: TrueType fonts & VSM font

I had no problems following the basic installation procedure guided by the installation disk. Differences I noticed:

  1. 9.04 did not recognize the integrated Bluetooth adapter in my Toshiba Satellite laptop. 10.04 also does not recognize it.

  2. 9.04 did not wake up from sleep after I closed the lid on the laptop. 10.04 works properly.

  3. 9.04 did not shut down the computer on shutdown, and did not restart Ubuntu on restart. 10.04 works properly.

  4. 9.04 supported the internal microphone on my laptop. 10.04 does not support the internal microphone. I found a bug report here: https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/584051 and it appears as if the bug is not considered important. I bought an inexpensive headset and found that 10.04 works fine with the external microphone.

The biggest change is that Ubuntu no longer comes with a pre-installed Java JDK. The official JDK from Oracle is available from the Canonical partner repository. Since it is no longer free software (in the FSF sense), it cannot be part of the basic Ubuntu multiverse. The Ubuntu community recommends Open JDK, but I installed the Oracle version. No doubt the day is coming when I will switch. Same sort of thing applies to OpenOffice and MySQL. Free alternatives exist for both.

Next: Ruby 1.9.2, rvm, and Sinatra follies

Wednesday, November 3, 2010

Ubuntu 10.04 upgrade on Toshiba Satellite: TrueType fonts & VSM font

Previous: Ubuntu 10.04 upgrade on Toshiba Satellite: Instiki wiki

To install some favorite TrueType fonts, I installed the basic TT font package:
sudo apt-get install msttcorefonts


To install the very handy Value Stream Mapping font from Ambor, I followed the procedure documented in this blog entry.

Next: Ubuntu 10.04 upgrade: Summary

Tuesday, November 2, 2010

Ubuntu 10.04 upgrade on Toshiba Satellite: Instiki wiki

Previous: Ubuntu 10.04 upgrade on Toshiba Satellite: Ruby Version Manager

Recent practice migrating my wiki on the Acer netbook made the process go smoothly on the Toshiba.

First step was to install prerequisites::
sudo apt-get install
libxml2-dev
libxslt1-dev
sqlite3
libsqlite3-dev
gem install sqlite3-ruby
Then, I downloaded the latest Instiki from http://instiki.org/ and unpacked the tarball. I copied the instiki directory to /home and renamed it .wiki. Next, I changed to the .wiki directory and ran
ruby bundle
Finally, I renamed the installed db and public directories to db-shipped and public-shipped, and copied the db and public directories from my wiki backup. Instiki came up clean the first time.

Now to get my wiki startup and shutdown scripts working. I copied the icon, instiki.png, to the new .wiki directory. Created a .bin directory in /home and copied the wiki and wiki_stop scripts there. The new directory structure was different, so I edited the scripts accordingly.

My shutdown script didn't work, and after some experimentation I realized that instiki startup is a bit different than it used to be. Previously, it printed the pid to stderr, and I picked it up with awk to generate a shutdown script on the fly. This version of Instiki appears not to do that, so I need to work out another way to handle shutdown nicely. Not worth pursuing at the moment.

Next: Ubuntu 10.04 upgrade on Toshiba Satellite: TrueType fonts & VSM font

Ubuntu 10.04 upgrade on Toshiba Satellite: Ruby Version Manager

Previous: Ubuntu 10.04 upgrade on Toshiba Satellite: Skype

Installation of rvm went pretty smoothly after the practice I got installing it on the Acer netbook. First step was to install prerequisites:
sudo apt-get install
curl
git-core
build-essential
zlib1g-dev
libssl-dev
libreadline5-dev
Next step was to run curl to do the basic install of rvm:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Then I edited .bashrc and commented out the line
[ -z "$PS1" ] && return
I noticed I had made a mistake when adding the source line to .bashrc on the Acer. The line should be
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
After that, I executed .bashrc like this
. ./.bashrc
and when I ran
type rvm | head -n1
I got the response
rvm is a function
just as the original instructions said to expect.

Next I ran
rvm install 1.9.2
and it downloaded and installed ruby 1.9.2 and rubygems 1.3.7.

At this point ruby -v said "The program 'ruby' is currently not installed". After I ran
rvm --default 1.9.2
then ruby -v said "ruby 1.9.2p0..." and gem -v said "1.3.7".

I uncommented the line
[ -z "$PS1" ] && return
in .bashrc to see if my guess was right about reinstating it after rvm had been used once. I closed the Terminal window and opened a new one, and ruby -v still worked. I logged out and in again, and ruby -v still worked.

Next: Ubuntu 10.04 upgrade on Toshiba Satellite: Instiki wiki

Ubuntu 10.04 upgrade on Toshiba Satellite: Skype

Ubuntu 10.04 upgrade on Toshiba Satellite: Adobe Flash Player

The last time I checked, there was no 64-bit Skype client for Linux. On http://www.skype.com/intl/en-us/get-skype/on-your-computer/linux/ I found a beta version available, and they showed a 64-bit version available. I downloaded it to give it a try.

No instructions were provided, but I saw by the filename that it was a .deb file. Fellow noobs might recall that Ubuntu is descended from Debian, so we can use Debian utilities on Ubuntu. In Terminal, I ran the following command:
sudo dpkg -i skype-ubuntu-intrepid_2.1.0.81-1_amd64.deb
The installer complained of missing dependencies. I tried apt-get install on the exact names of packages the installer listed:
sudo apt-get install
lib32stdc++6
lib32asound2
ia32-libs
libc6-i386
lib32gcc1
Ubuntu could find no installation candidate for any of these packages.

An Internet search brought me to http://blog.mypapit.net/2007/06/how-to-install-skype-on-ubuntu.html, which mentioned adding deb http://download.skype.com/linux/repos/debian/ stable non-free to Synaptic Package Manager.

I made a backup of /etc/apt/sources/list
cd /etc/apt
sudo cp sources.list sources.list.backup
and edited the file, adding the repository at the end.

When I tried the apt-get install command above, everything was found except list32stdc++6. Another Internet search took me to http://ubuntuforums.org/showthread.php?t=1457771, where someone had reported a similar problem and later posted that an update had fixed it. I tried
sudo apt-get update
but the update complained that it could not find http://download.skype.com/linux/repos/debian/dists/stable/non-free/binary-amd64/Packages.gz.

I went back into /etc/apt/sources.list and commented out the line for that repository, then tried the update again. No complaints, so I tried
sudo apt-get install lib32stdc++6
This time it complained about unmet dependencies, and suggested running this:
sudo apt-get -f install
This did quite a lot, including installing or updating all the dependencies the dpkg command had complained about. It took a while.

To my surprise, it installed the Skype client as well. I called my wife, and she could see me but not hear me. I could see and hear her. We were unable to resolve the problem. Afterwards, I browsed the Internet and eventually found a bug report at https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/584051 that said the internal microphone on Toshiba Satellite laptops doesn't work under Ubuntu 10.04 due to a bug in the alsa driver. It's low priority and they may or may not fix it. Other postings online suggest an external microphone will work. I might try that later.

Ubuntu 10.04 upgrade on Toshiba Satellite: Ruby Version Manager

Ubuntu 10.04 upgrade on Toshiba Satellite: Adobe Flash Player

Previous: Ubuntu 10.04 upgrade on Toshiba Satellite: Prep and basic install

At the time of this installation, Adobe Flash Player for 64-bit Linux systems was still in a preview release. I went to http://labs.adobe.com/downloads/flashplayer10.html and downloaded the tarball for Linux. No installation instructions were provided.

When I unpacked the tarball, I found it contained a single file: libflashplayer.so. The filename jogged my memory, and I looked on this blog for previous notes about installing a non-production version of Flash Player with Firefox. I found it in this blog entry, and copied libflashplayer.so to /usr/lib/mozilla/plugins and restarted Firefox.

Gold!

Next: Ubuntu 10.04 upgrade on Toshiba Satellite: Skype

Ubuntu 10.04 upgrade on Toshiba Satellite: Prep and basic install

Previous: Ubuntu 10.04 upgrade on Acer netbook: Instiki migration

The "upgrade" consisted of a fresh install of Ubuntu 10.04. To prepare for the install, I did the following:
  1. Cleaned up files and directories.
  2. Moved Gnome .desktop files for certain apps from /usr/share/applications to ~/.local/share/applications.
  3. Backed up my /home and /usr directories to an external hard drive
I learned a couple of lessons in the past few months of using Ubuntu. First, I learned that it's possible to define .desktop files under one's home directory. I moved some of these so that they could be backed up and restored with my /home directory. I also learned that there's no particular benefit in a separate partition for /usr.

Before committing to the new release, I ran 10.04 from the installation disk without doing the actual install. I was pleased to see that the 5100 AGN wireless adapter was supported. Everything looked okay to go forward with the installation.

Based on lessons learned, I defined partitions as follows:
ext4    30.0 GB    /        /dev/sda1
ext4 362 GB /home /dev/sda6
swap 8 GB /dev/sda5
The installation went smoothly. I restored /home from the backup.

I checked to see if 10.04 might support the integrated Bluetooth adapter in the laptop, but unfortunately it does not.

I opened a presentation file that contains images to see whether the bug related to hardware graphics acceleration had been fixed in OpenOffice 3.2. Yes!

I opened Firefox and saw that it is now branded as Firefox instead of Shiretoko. Good! I went to http://www.xmarks.com and installed the plug-in, then synced my bookmarks.

On the local system, I went to System -> Preferences -> Appearance and changed the Theme to Radiance.

Next: Ubuntu 10.04 upgrade on Acer netbook: Adobe Flash Player

Ubuntu 10.04 upgrade on Acer netbook: Instiki migration

Previous: Ubuntu 10.04 upgrade on Acer netbook: Ruby Version Manager and Ruby 1.9.2

One final check on the Acer before attempting this install on the Toshiba: Will my local Instiki wiki run under ruby 1.9.2?

First, I installed the usual prerequisites:
sudo apt-get install
libxml2-dev
libxslt1-dev
sqlite3
libsqlite3-dev
gem install sqlite3-ruby
Then, I downloaded the latest Instiki from http://instiki.org/ and unpacked the tarball.

When I started Instiki, it complained:
Bundler couldn't find some gems. Did you run 'bundle install'?
This hasn't happened before in my experience, so I assume it has something to do with running ruby under rvm vs. running it native.

I did an Internet search for 'instiki bundle install' and found useful information at http://golem.ph.utexas.edu/wiki/instiki/show/installation. After reading that information, I thought I had everything in place to run the bundle command, so I ran it from the instiki root directory:
ruby bundle
No complaints, so I started Instiki and it came up clean.

I shut down Instiki and copied the 'public' and 'db' directories from my old wiki (still on the Toshiba) to the one just installed on the Acer. This was sort of a risky short-cut, since I didn't follow any of the instructions for migrating the database. When I started Instiki, it came up clean. Apparently there have been no changes to the basic database structure since the last release. (Whew!)

I noticed that they've added a 'Skip the navigation links' link as the first link in the navigation bar of Instiki. That's a nice accessibility feature and a convenience for anyone who prefers the keyboard to the mouse. Kudos.

At this point, it looked as if Ubuntu 10.04 was okay for the Acer.

(Actually, Ubuntu has been more than just 'okay' for the Acer. IMHO it's a very good environment for a netbook. It's functional, simple, clean, relatively safe, and supports all the usual social networking tools. OpenOffice provides the tools I need to make presentations and so forth when on the road. A $200 machine with a free operating system and all the applications I need ... ideal for the purpose.)

Open questions about how 10.04 would run on the 64-bit Toshiba and whether it would support the wireless adapter could only be answered by installing it on that machine. Installing typical development tools should be no different on either machine, and since I don't use the Acer for development there was no value in going any further with those installs.

Next: Ubuntu 10.04 upgrade on Toshiba Satellite: Prep and basic install

Monday, November 1, 2010

Ubuntu 10.04 upgrade on Acer netbook: Ruby Version Manager and Ruby 1.9.2

Previous: Ubuntu 10.04 upgrade on Acer netbook: Adobe Flash Player

The things I had done so far on the Acer did not tell me much about how 10.04 would play on the Toshiba. I was leery of 5100 AGN support, and the Adobe Flash Player for 64-bit Linux was still in a pre-release state.

Installing software development tools ought to be less problematic than all that. I found that many people were singing the praises of Ruby Version Manager (rvm). It gives you the ability to run multiple releases of ruby on the same machine without having to uninstall and install different releases. It sounded useful, and most of the comments online were very positive.

Following advice on http://web2linux.com/installing-rails-3-on-ubuntu-10-04-lucid-lynx/, I began by installing prerequisites to rvm and ruby:
apt-get install
curl
git-core
build-essential
zlib1g-dev
libssl-dev
libreadline5-dev
I then proceeded to make a series of noob mistakes, and after cleaning off various partial and incorrect installs, this is how I got rvm working. The official installation instructions at http://rvm.beginrescueend.com/rvm/install/ are pretty good, but are not exactly right.

The installation instructions mention three options — install as user, install as root, and system-wide install. I wanted to install as user so that everything would be under /home. That makes it easier to upgrade Ubuntu, since I can restore /home from a backup after doing the basic install. That was my plan for the Toshiba, anyway. For the Acer, I just blew everything away and installed fresh.

First step was to use curl to get the latest version of rvm from head:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
This step appeared to work. The author, Wayne Seguin, kindly included the following advice in the console output: "Be sure to get head often as rvm development happens fast." Sound advice.

They suggest running
rvm notes
to install dependencies, but in fact it only displays a description of dependencies.

They say you must not have any returns in .bashrc. They specifically call out a line in Unbuntu's .bashrc:
[ -z "$PS1" ] && return
and they recommend wrapping this in an if structure so that rvm will work correctly. I found that after completing the rest of the installation steps, rvm never worked. It turned out that this change is required only for the installation process, and once rvm has been installed you should reinstate the original statement. I changed it to
if [[ -n "$PS1" ]] ; then
return
fi
and afterwards changed it back to
[ -z "$PS1" ] & return
The installation instructions also say to put this line at the end of .bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
They then say you have to run
source ~/.rvm/scripts/rvm
the first time you use rvm. In fact, you have to run this command every time you want to use rvm. I added the source command to the end of .bashrc, and rvm now works properly.

The other thing to be aware of is that the installation instructions say you run
type rvm | head -n1
and it should display
rvm is a function
Then, you run the source command for the first time. In fact, that results in
rvm is hashed (/usr/local/bin/rvm)
You have to run the source command first, and then rvm will be a function.

Finally rvm was working. I used it to install ruby 1.9.2:
rvm install 1.9.2
and then to make 1.9.2 the default version of ruby (as far as rvm was concerned, anyway):
rvm --default 1.9.2
Good news: It installed rubygems automatically.

Now I could install other gems and run ruby to my heart's content, but only when running as 'user'.

Next: Ubuntu 10.04 upgrade on Acer netbook: Instiki migration

Ubuntu 10.04 upgrade on Acer netbook: Adobe Flash Player

Previous: Ubuntu 10.04 upgrade on Acer netbook: Basic install

I went to YouTube and chose a video at random from the default page. As expected, it prompted me to install the Adobe Flash Player. I clicked on the Adobe link and it took me to the Adobe download page, as expected. There was a 32-bit Linux download for APT, so I chose it. It prompted me to enable the 10.04 Partner Channel. This enables downloads of non-free software for Linux. You must enable this to download the Flash Player. After that, it prompted me for my root password.

After a rather long wait, during which the system gave no indication that anything was happening, I was prompted with the Install Additional Software? dialog, asking Do you want to install package 'adobe-flashplugin'? I chose Install, and the installation appeared to work fine. When I tried the YouTube video again, it prompted me again to download the Flash Player, as if it couldn't find the one I had just installed. This time, I clicked on the Install Additional Plugins link instead of the Install Adobe FlashPlayer link.

This time, I got a list of available plugins. I highlighted Adobe Flash Player (installer) and clicked Next. That brought up the Install Additional Software? dialog, asking Do you want to install package 'flashplugin-installer'? I clicked Install. It removed the adobe-flashplugin package I had just installed, and installed flashplugin-installer. This took a long time. The installation appeared to work.

Now I was able to play YouTube videos.

So, the key to success here is to use the Install Additional Plugins link instead of the direct link to Adobe.

Next: Ubuntu 10.04 upgrade on Acer netbook: Ruby Version Manager and 1.9.2

Ubuntu 10.04 upgrade on Acer netbook: Basic install

Previous: Border around images in OpenOfficeImpress

Time for me, a not-on-the-bleeding-edge user, to upgrade to Ubuntu 10.04. I had problems using 9.10 on my Toshiba laptop due to problems in support for the Intel 5100 AGN wireless adapter. Various bugs were reported regarding Linux support for that product. I've been running 9.04 on the Toshiba and 9.10 on the Acer netbook. Oddly, 9.04 supports the 5100 AGN just fine, while later releases do not.

The Toshiba is my main workhorse, and I use the Acer for presentations and meetings as well as a host for a Windows XP instance that I need for two particular applications. Because it's easy to install Ubuntu alongside Windows using Wubi, I decided to approach the upgrade cautiously by installing on the Acer first. My thought was this would minimize the risk of messing up my primary machine. This approach would not tell me whether 10.04 supported the 5100 AGN wireless adapter, or whether it would be possible to get the 64-bit version of Adobe Flash Player working, but it would at least identify any major issues with the new release.

The Wubi install is different from a straight install from an iso disk. I booted into Windows XP, downloaded the Wubi installer, and ran it with
wubi --32bit
The installer recognized that Ubuntu was already installed and offered to remove it. I chose Yes, the installer removed Ubuntu 9.10, and exited. I ran the command a second time, exactly the same way, and this time it downloaded the installation files and proceeded with the installation. This took quite a while, but completed without any problems.

The first thing I noticed was that it was hard for me to read the display and to distinguish the edges of windows. It seems the default desktop theme for 10.04, Ambiance, is based on a color palette of black, dark black, deep black, and pitch black. I changed the desktop theme to Radiance, which has a lighter color palette. The default on 9.04, Human, was not listed as an option. Radiance is similar.

Now that I could read the display, the next order of business was to slow down the mouse a bit. By default, 10.04 ships with the mouse set to very fast and very sensitive; that is, the sliders are about half-way between minimum and maximum. I changed the settings to be more compatible with my slow, old hands, after some difficulty in making the mouse cursor land where I wanted it.

The next thing I noticed was that .bash_aliases is called by default from .bashrc. In 9.04, those lines are commented out by default in .bashrc. I think the 10.04 default makes more sense. I put some of my favorite aliases into .bash_aliases and began to check out the new version of Ubuntu.

Next: Ubuntu 10.04 upgrade on Acer netbook: Adobe Flash Player

Sunday, October 3, 2010

Border around images in OpenOffice Impress

Previous: sudo:must be setuid root

When preparing presentations for upcoming conferences, I noticed that images on slides appeared normal in edit mode but were rendered with a border in slide show mode. I Googled for the problem and found this thread on openoffice.org where people described the same issue.

One contriubtor discovered that he could remove the border by choosing Tools > Options... to get the Options dialog, then opening OpenOffice.org > View in the dialog. In OpenOffice 3.0, a checkbox is presented with the title, "Use hardware acceleration." By unchecking the box, the contributor found the borders disappeared, but anti-aliasing was also disabled.

I found that OpenOffice 3.1 offers two separate checkboxes: One for "Use hardware acceleration" and another for "Anti-aliasing." When I unchecked "Use hardware acceleration" and left "Anti-aliasing" checked, everything worked as expected.

So, one key to solving the problem is to ensure you're using at least OpenOffice 3.1.

Next: Ubuntu 10.04 upgrade on Acer netbook: Basic install

Tuesday, June 1, 2010

sudo:must be setuid root

Previous: Installing Android development tools

As a noob, I do noobish things. Here's the latest.

Something went haywire with Firefox (probably because I deleted something inadvertently when I was getting rid of old files), and I restored /usr from my backup drive using rsync in an attempt to fix Firefox. Apparently, rsync changed the ownership of /usr to the userid under which it was executed. When I tried to run sudo, I got this:
sudo:must be setuid root
Browsing the net for advice, I found scattered, incomplete help for questions that were close to, but not quite the same as mine.

Basically, the solution is to change ownership back to root. Culling bits and pieces from different sources, here's what I ended up doing:

1. Rebooted and hit ESC at the prompt to get the grub menu.
2. Chose 'root console' from the grub menu.
3. Ran the following commands:
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
chmod 0440 /etc/sudoers
reboot
When the system came back up, everything was normal again.

Next: Border around images in OpenOffice Impress

Tuesday, May 18, 2010

Installing Android development tools

Previous: Installing Oracle Express and ADF - FAIL!

Because Android development is supported by a special Eclipse plugin, I wanted to run a separate instance of Eclipse configured for Android development. I downloaded the basic (non JEE) version of Eclipse from http://www.eclipse.org/ unpacked it into my home directory using
tar xzvf eclip*
and renamed the resulting eclipse directory to .eclipse-android.

Next, I followed the instructions at http://developer.android.com/sdk/installing.html#Installing to install the Android SDK starter package. After downloading the package (in this case, the 64-bit Linux version), I unpacked it into my home directory with
tar xzvf android-sdk*
and renamed the resulting directory from android-sdk-linux_86 to .android-sdk.

The instructions suggest adding the tools subdirectory to PATH in .bash_profile or .bashrc. Because of the way I've got my startup files organized at the moment I'm setting PATH in .profile, so I defined it there by adding the line,
PATH=$PATH:~/.android-sdk/tools
Then I followed the instructions at http://developer.android.com/sdk/eclipse-adt.html to install the Android Development Tools (ADT) plugin for Eclipse.

I started Eclipse and created the workspace android-sandbox when prompted. Then I went to Help > Install New Software > Add... and entered this URL into the Location field:
https://dl-ssl.google.com/android/eclipse/
It seemed to take longer than these things usually take, but eventually Developer Tools appeared in the list of available software. Android DDMS and Android Development Tools came up, as per the instructions. I clicked Next, accepted the license agreement, and clicked Finish. After a fairly lengthy download process and a warning about installing unsigned content, the plugins seemed to install. When Eclipse restarted, I found Android Project and Android Test Project listed under New... > Other.... So far, so good.

Next, I told Eclipse where to find the Android SDK. In Window > Preferences > Android, I browsed to the .android-sdk directory and set that as the SDK location.

In a Terminal window, I started the ddms utility, went to File > Preferences... > Usage Stats and unchecked the checkbox for sending usage statistics to Google.

The instructions say you should use the "Android SDK and AVD Manager" to download at least one platform and any additional components you want. The real name of the program is android. I determined that by starting each of the executables in the tools directory one by one. Fortunately, android was only the second one in the alphabetical list! (Note: Later I noticed that Android SDK and AVD Manager is an option on Eclipse's Window menu.)

I chose Available Packages and the program populated the list. Being new to this, I wasn't too sure what I needed. I chose the documentation as well as the platform and API for Android 1.5, API 3, revision 3, and the samples. I clicked Install Selected, accepted the license agreement, and clicked Install. This started an insanely long download. I went to bed and let it run overnight.

The next morning I browsed through the SDK directory tree to see what had been installed. Then I followed the "Hello World" tutorial at http://developer.android.com/resources/tutorials/hello-world.html. The tutorial covers some of the basic setup you have to know about in order to develop Android apps, so I suggest following it if you're doing this for the first time. The tutorial assumes you're using Eclipse for development. If you're using a different development environment you'll have to work out how to take the equivalent setup steps.

The tutorial instructions were accurate and everything worked as documented.

There doesn't appear to be much documentation about TDD for Android apps, but there is some sample test code in the ApiDemo sample app. I think my next step in learning about Android development will be to work out a good way to do TDD, with this example as a starting point.

Next: sudo:must be setuid root

Tuesday, May 11, 2010

Installing Oracle Express and ADF - FAIL!

Previous: Renaming NTFS filesystem on external drive

The client for my next coaching engagement will be using Oracle's Application Development Framework (ADF). I thought it would be a good idea to familiarize myself with some of the tools they'll be using, so I went to Oracle's website to download single-user versions of tools that are available at no charge. Oracle Express provides all the basic functionality of the Oracle RDBMS and ADF is a Java-based webapp framework tailored for Oracle back ends.

While I appreciate Oracle's willingness to make these tools available, I must say I was a bit surprised at the difficulty of obtaining them. The servers appear to be extremely slow. The Oracle Express download is a few hundred megabytes, and it took several hours. The ADF download is about 1.5 GB, and it ran more than 12 hours. Downloads of other software, videos, music, etc. from other sources have been considerably faster on the same (hotel) wireless connection and using the same laptop.

Before starting the lengthy download of Oracle Express, I first had to reach the link and click on it. Normally, clicking on a link is a relatively routine operation on the Internet. Not so on this occasion. The download page for Oracle Express for Linux reported an error refreshing the browser, and advised me to contact the site administrator. Interesting advice, as there appears to be no way to contact a site administrator.

Oracle's webapp is the only suspect that had opportunity...not quite sure about motive, though. Then again, it may be a failure of logic on my part: The business motive to provide poor customer service has never been intuitively obvious to me. I can but trust the good folks at Oracle have sound reasons for it. After spending some time searching the website for a contact link or for an alternative way to obtain the software, I gave up and did a Google search for "oracle express linux download."

Of course, the official download page was the first hit. Google offered a link to a cached version of the page. I tried that and, lo and behold! the page appeared with all links working. The software was in fact right where it was supposed to be and was available, but there was (still is?) something wrong with the website; you just can't get to the appropriate page through the front door. Thanks to Google's cache, a side window was open. I slid through and downloaded the Debian package for the Western character set.

One positive aspect of Oracle's service is that they provide documentation. The first documented step to install Oracle Express was to run the following command:
dpkg -i oracle-xe_10.2.0.1-1.0_i386.deb
It turned out this has to be done as superuser, so I tried
sudo dpkg -i oracle-xe_10.2.0.1-1.0_i386.deb
This time, I got
package architecture (i386) does not match system (amd64)
There is no mention of a 64-bit version on Oracle's site, nor any warning that the package they offer is for 32-bit systems.

What is worse than "useless?" "Misleading."

I guess I'll have to learn these tools using the client's time and equipment. The cynic in me wants to say that's part and parcel of their having chosen Oracle as a vendor. The professional in me doesn't like to say it, and wishes companies would simply provide what they claim to provide, whether free or not, or else not make the claim at all. The consultant in me says nothing about it for the moment, but has filed the experience for future reference when clients ask for advice about vendor selection.

Next: Installing Android development tools

Wednesday, April 14, 2010

Using rsync for backups

Previous: Renaming FAT32 and NTFS filesystems

Being a n00b and all, it's probably no surprise to you that I've been backing up my files by dragging and dropping folder icons in Nautilus. Knowing that, it's probably no surprise that these backup operations might take hours to complete. I used to start a backup operation before going to bed, and leave it running while I slept.

I had n00bishly assumed that when gnome asked me if I wanted to merge files with matching names, it would only copy those files that were different than the version on the target. After all, that would be the logical thing to do, wouldn't it? No such luck.

Then I discovered a very useful file syncing utility, rsync. It's already installed on Ubuntu as shipped. It's nothing new, but it's new to me. It only copies files that have changed.

I found I could back up any of my top-level directory trees to an external drive quickly. For example, this command backs up my /usr directory, which is the mount point of a partition on the internal hard drive:
sudo rsync -av /usr /media/1TB_HDD_external/
The first time, when there was nothing at the destination location, rsync took about 15 minutes to back up a partition of 320GB+. Subsequently, it ran in just a couple of minutes. Very convenient!

It was easy to script this so that everyday backups are easy to run. For instance, this
backup personal
will run
sudo rsync -av /home/dave/Personal /media/1TB_HDD_external


Next: Installing Oracle Express and ADF - FAIL!

Renaming FAT32 and NTFS filesystems

Previous: Installing Gwibber

I wanted to rename my Western Digital My Book volumes, because they are all named "My Book." It would be too easy to make a mistake and format the wrong volume or restore from the wrong backup. From community help at https://help.ubuntu.com/community/RenameUSBDrive, I learned that gparted can rename an NTFS filesystem without reformatting it.

To install gparted, I opened a Terminal and ran
sudo apt-get install gparted
sudo apt-get install mtools
sudo apt-get install ntfsprogs
Gparted is the partition management utility, mtools is a package of utilities for working with FAT filesystems, and ntfsprogs is a package of utilities for working with NTFS filesystems.

Running gparted as root (that is, sudo gparted), I saw the partitions on my internal drive but none of the external drives. There's a Devices drop-down in the GParted menu, and there I found three devices /dev/sda, sdb, and sdc. I identified the volume I wanted to rename, right-clicked on it and chose unmount. This ran for a long, long time. I checked using Nautilus and the drive was not mounted. I cancelled gparted and started it up again, to see if it would let me try the rename operation. It just kept searching and searching and searching for partitions on /dev/sbc.

I disconnected the external drive, killed gparted, and started it again. This time it immediately displayed the list of partitions on the internal drive. I shut down gparted, then reconnected the external drive. After it automounted, I unmounted it using Nautilus, but left it physically connected. Once again, gparted just looped, ostensibly searching for partitions on the device.

A FAT32 filesystem



So, gparted did not work. I tried the command-line approach outlined on the community help page cited above. I connected the external drive and waited for it to automount. Then I ran
mount
to see the mounted filesystems and found where the external drive was mounted. In this case, it was /dev/sdc1. I unmounted it with
sudo umount /dev/sdc1
Then I verified it was the volume I wanted with
sudo mlabel -i /dev/sdc1 -s ::
Finally, I changed the volume label with
sudo mlabel -i /dev/sdc1 ::500GB_FAT32_external
I mounted the volume and it worked fine.

An NTFS filesystem



Followed a similar procedure to relabel an NTFS volume. Connected it, waited for it to automount, and unmounted it with
sudo umount /dev/sdb1
Checked the current label with
sudo ntfslabel /dev/sdb1
Changed the label with
sudo ntfslabel /dev/sdb1 1TB_NTFS_external
Checked to be sure I had changed the label correctly, then re-mounted the volume. Worked great!

Next: Using rsync for backups

Tuesday, April 13, 2010

Installing Gwibber

Previous: Installing a gmail notifier

Ran the command
sudo apt-get install gwibber
Gwibber then appeared under Applications > Internet > Gwibber Microblogging Client. Defining the Twitter account was easy. Defining the Facebook account was confusing. Not sure if it worked.

The program appears to work fairly well and looks good. It locks up if I use the scroll wheel on the mouse too rapidly. It's not limited to Twitter, but when using Twitter it doesn't seem to be as functional as the basic Web interface. I will try it for a while and see how it goes.

Next: Renaming FAT32 and NTFS filesystems

Installing a gmail notifier

Previous: Upgrading Eclipse after reinstalling Ubuntu

Followed instructions at Ubuntu Geek to install CheckGmail, a Gmail notifier for Ubuntu.

Ran the command
sudo apt-get install checkgmail
Instead of pressing ALT+F2, I just typed checkgmail in Terminal. It started the program. I entered my Gmail account information, changed the External Command to
firefox-3.5 %u
and left all other defaults unchanged. The program was unable to log into Gmail. It complained that the userid or password was incorrect. After checking to be sure I had entered the correct values, I decided the program simply does not work, and I removed it with
sudo apt-get remove checkgmail


Next, I tried gm-notify from Launchpad. Downloaded the tarball, unpacked it, and read the README for installation instructions. It's a Python app and has some dependencies, duly noted in the README. Per the instructions, I ran
sudo apt-get install python-indicate python-notify python-gst0.10 python-gtk2 python-gconf python-twisted-mail
to install the prereqs, then from the top-level directory of the extracted files, ran
sudo ./setup.py install
The README says the application will appear in the menu Applications > Network > GMail Notifier, but in fact it appeared in Applications > Internet > GMail Notifier. Furthermore, the README says the configuration app will appear under System > Settings > GMail Notifier Configuration, but in fact it appeared in System > Preferences > GMail Notifier Configuration.

Sent myself an email to see what the application would do. Works well, is simple, looks good. I'll keep this one.

Next: Installing Gwibber

Upgrading Eclipse after reinstalling Ubuntu

Previous: Reinstalling some favorite apps after reinstalling Ubuntu

Ubuntu repositories have Eclipse 3.2. I wanted a more recent version. I went to http://www.eclipse.org and downloaded the basic JEE packaging of Eclipse Galileo as a tarball.

Deleted the old ~/.eclipse directory. Unpacked the tarball into /home and changed the name of the top-level directory to ~/.eclipse. Changed /usr/share/applications/eclipse.desktop to point to the executable. Works fine.

Next: Installing a gmail notifier

Shell personalization after reinstalling Ubuntu

Previous: Reinstalling some favorite apps after reinstalling Ubuntu

Shell personalization after reinstalling Ubuntu



I set up some preferences in login files a little differently than before, based on tips from Stefaan Lippens. I put environment variable definitions in .profile and sourced .profile and .bash_aliases in .bash_profile. This seems to be quite a convenient setup. Added the following to .bash_aliases
# Shortcuts for directory listings
alias ll='ls -lF --color=auto'
alias la='ls -alF --color=auto'
alias ls='ls -F'

# Highlight matches in grep
alias grep='grep --color=auto'

# Start and stop my local wiki
alias wiki='~/.bin/wiki'
alias wiki_stop='~/.bin/wiki_stop'

# Start Freemind mind-mapping tool
alias freemind='~/.freemind/freemind.sh'

# Start UMLet diagramming tool
alias umlet='umlet.sh'
Uncommented the following lines in the provided .bashrc
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi


Next: Upgrading Eclipse after reinstalling Ubuntu

Reinstalling some favorite apps after reinstalling Ubuntu

Previous: Restoring Firefox personalization after re-installing Ubuntu

So, I wanted to reinstall some of the apps I had been using before. But the way I had them scattered around the filesystem was pretty sloppy. Better this time.

Recovering my local wiki



Installed sqlite3 and sqlite ruby support (Instiki depends on them):
sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby
Put the wiki under /home/.wiki so that it would not show up in normal directory listings.

Moved the wiki icon to /usr/share/pixmaps to make it consistent with other applications.

Put a wiki icon on the top panel for convenient starting.

For more information about how I've customized Instiki for personal use, see http://kotowanandesu.blogspot.com/2009/08/pimp-my-instiki.html.

Reinstalling Google Earth



Installed Google Earth by following the instructions I documented on this blog at http://kotowanandesu.blogspot.com/2009/09/google-earth-install.html. I downloaded a fresh copy in case there have been any updates since the last time I installed it.

Had a problem this time that I didn't have last time. The installer complained that gtk2 was missing.

Searching for similar problems, I found that some people had installed lib32nss-mdns, and this solved the problem for them. I tried
sudo apt-get install lib32nss-mdns
and ran the installer again.

The console output was:
setup.data/bin/Linux/amd64/setup.gtk2: error while loading
shared libraries: libxml2.so.2: cannot open shared
object file: No such file or directory
setup.data/bin/Linux/amd64/setup.gtk: error while loading
shared libraries: libSM.so.6: cannot open shared
object file: No such file or directory
The setup program seems to have failed on amd64
Better, but apparently I forgot to install libxml2 after reinstalling Ubuntu. I found a security notice for 9.04 at http://www.ubuntu.com/usn/USN-815-1 advising an upgrade. I did that and tried
sudo apt-get install libxml2
and it informed me the latest version of libxml2 was already installed. So, that wasn't the problem.

There are many personal blogs out there written by people whose installation worked properly on the first try. I found no help that addresses the problems I'm seeing today.

I ran across a comment by Daniel Holbach buried in a long list of comments on one article that advised the following:
$ sudo apt-get install googleearth-package
$ make-googleearth-package --force
Doubleclick on the resulting .deb file.
I gave that a try, since there was little to lose at this point.

The make spewed hundreds of warning-level messages. The installer proved to be a very long-running process. I left it running during the day and checked on it after work. It worked fine.

This time I put the app in ~/.googleearth so that it would not show up in normal directory listings.

Reinstalling Freemind



Copied my old installation of Freemind from a backup. Referred to to set it up. This time, I put the app in ~/.freemind and set an alias for 'freemind' instead of putting the absolute path in the freemind.desktop file. No problems with this install.

Reinstalling UMLet



A new version of UMLet is available. I downloaded the standalone version and the Eclipse plugin from http://www.umlet.com, version 10.1. I had 10.0 previously. Recovering from a system crash offers all sorts of opportunities for improvement.

I set up the standalone version in the same way as I had set up Freemind. This time, I noticed that UMLet has its own logo. I downloaded the logo from their site and associated it with the app, instead of the icon I came up with before.

Installation of the standalone UMLet consists of unpacking the zip file. The shell script that starts the program already had execute privileges. Convenient. The default directory name is UMLet. I changed it to .umlet. I defined an alias, umlet, in .bash_aliases, ran my .bash_profile and gave it a try.

Didn't work. I took a look at the UMLet.sh file, and learned that it looks for an environment variable, UMLET_HOME. So, they've made things a bit more formal. I added these lines to my .profile:
UMLET_HOME=~/.umlet
export UMLET_HOME
then copied ~/.umlet/UMLet.sh to ~/.bin/umlet.sh and uncommented the line that changes to the UMLET_HOME directory. Typing umlet at a command prompt started the program properly.

I copied the umlet.desktop file from my backup and changed it to refer to the new logo file:
[Desktop Entry]
Encoding=UTF-8
Name=UMLet
Comment=UML diagramming tool
Exec=umlet
Icon=umlet_logo.jpg
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
and copied the logo file to /usr/share/pixmaps. At this point, UMLet appeared in the gnome menu under Applications > Programming, but the logo image was not displayed. I used Gimp to change it from .jpg to .png. Worked!

Logged out and in and tried to run UMLet from the menu. The launcher was unable to start the child process. It complained that there was no such file or directory as "umlet." I checked .bash_aliases and it looked correct. There must be something about launchers I don't quite understand. I changed the alias to give the absolute path of umlet.sh, logged out and in, and tried again. Worked!

Dropped the jar for the UMLet Eclipse plugin into the Eclipse plugin directory and started Eclipse. Created a UML diagram from Eclipse's New... dialog. Looks good.

Reinstalling Banshee



Ran the command
sudo apt-get install banshee
Banshee appeared in the gnome menu, and started normally. It imported my music files correctly. It played mp3 files correctly. It imported my video files correctly. It played .flv, .mov, .mp4, .mpg, .mpeg correctly.

Next: Shell personalization after reinstalling Ubuntu

Sunday, April 11, 2010

Restoring Firefox personalization after re-installing Ubuntu

Previous: Installing .NET development support

1. Version update

sudo apt-get update
sudo apt-get install firefox-3.5

Then edited the Properties for the Firefox launcher in the Applications menu to invoke firefox-3.5 instead of firefox.

Fortunately, the Ubuntu Modifications for Firefox aren't compatible with this version, so there was no need to disable them manually.

2. Plugins

Went to http://get.adobe.com/flashplayer to try and install Flash Player. (I've had problems with this in the past. Expectations are low.) Selected the .deb file option from the dropdown list. The installer complained about "wrong architecture." FAIL.

A search for "install flash 64-bit linux" found http://labs.adobe.com/downloads/flashplayer10_64bit.html, with instructions to download a tarball of a beta 64-bit version of Flash Player 10. Adobe provides no help about what to do with the tarball's contents. I found several threads about problems with multimedia on Ubuntu, and surmised that plugins might belong in /usr/lib/mozilla/plugins. I unpacked the tarball and copied libflashplayer.so to that location, then restarted Firefox. Youtube videos then played normally.

3. Preferences

In Firefox, I went to Edit > Preferences.

* On the Main tab, under Startup, for the When Firefox starts dropdown, I selected "Show a blank page."

* On the Main tab, under Downloads, I left the default setting of "Desktop" for Save files to. Previously, I had a downloads directory under /home. Now I think that was only an invitation to be lazy. If downloaded file icons appear on my desktop, it's an incentive to put them where they really belong or delete them.

* On the Main tab, under Location Bar, set "...suggest" to "Bookmarks". When I had it set to "History and Bookmarks" it tended to be too cluttered to be useful after several hours online. This way, I can whitelist useful sites by adding them to my bookmarks.

* On the Privacy tab, under History, I deselected "Keep my history..." and "Remember what I enter..." and left "Remember what I've downloaded" selected. I don't use the history to find sites I've visited before. To me, the other options are more distracting than useful. I like simplicity.

* On the Privacy tab, under Private Data, I selected "Always clear...when I close..." and deselected "Ask me..." In Settings I left the default selections.

* On the Security tab, under Passwords, I deselected "Remember passwords for sites." This is a laptop, and there is a risk of identity theft or other problems if people can discover passwords easily. Besides, if I have to enter passwords every time, I'm less likely to forget them.

* On the Advanced tab, under Browsing, I deselected "Check my spelling as I type." Another distraction of dubious value.

* On the Tabs tab, selected "When I open a link in a new tab, switch to it immediately". Why else would I open a link, besides wanting to read it? What were they thinking when they defined this default?

4. Add-ons

* From http://www.xmarks.com installed the XMarks plugin. When you complete the installation, it walks you through a series of dialogs to help you get set up. I logged in with my XMarks account and told it to "Keep data on the server; discard data on this computer." This was the first time I had used the service in this way. It worked perfectly.

* From http://readitlaterlist.com/firefox/, installed Read It Later. It did not recognize the Read It Later folder in Bookmarks, and thought I had no entries. After searching for help on that without success, I decided there was no need to keep those bookmarks anyway. I had marked them to read later, but had never bothered to do so. They must not have been important after all.

I didn't bother with all the add-ons for development and testing, email notification, and so forth. I'll add them as I find I need them. I think I got carried away with add-ons last time around. Clean start this time.

Next: Reinstalling some favorite apps after reinstalling Ubuntu

Installing .NET development support

Previous: Installing Tomcat (partial FAIL)

I'm not actively working on a mono project at the moment, so I didn't spend too much time configuring a development environment. Actually, I didn't spend any time configuring a development environment. I installed the basic tools with these commands:

sudo apt-get install
mono-devel
libmono-winforms2.0-cil
monodevelop
monodevelop-nunit
monodevelop-debugger-mdb

If you're interested, my notes about getting started with these tools are in this post: http://kotowanandesu.blogspot.com/2009/08/installing-support-for-net.html.

Next: Restoring Firefox personalization after re-installing Ubuntu

Installing Tomcat (partial FAIL)

Previous: Installing Java support

The last time I installed Tomcat on Ubuntu 9.04, the documented easy installation method didn't work and I resorted to installing from a tarball. Since I'm installing 9.04 again rather than a later release, there's no reason to expect different behavior from the installer today.

This time, I want to run Tomcat from a hidden directory under /home so that the everyday view of /home won't be cluttered with various development tools, as before. I decided to go with Tomcat 5.5 for the moment.

I wanted to be able to run customized Tomcat instances for particular development projects on localhost. To that end, I configured a vanilla instance to use as a template to copy into different projects as needed.

This is what I did:

Install Tomcat Core



1. Went to http://tomcat.apache.org/ and download the following distros:

* Core
* Deployer (did not install this)
* Administration Web Application (did not install this)

2. Under /home/.bin I created a directory for local Tomcat instances, tomcat. So I had /home/.bin/tomcat.

3. Moved the Core tarball to /home/.bin/tomcat and unpacked it in place using

tar xzfv *

This resulted in a directory containing the Tomcat core at /home/.bin/tomcat/apache-tomcat-5.5.28.

4. Deleted the tarball apache-tomcat-5.5.28.tar.gz.

5. Granted execute permission on everything in Tomcat's bin directory

cd /home/.bin/tomcat/apache-tomcat-5.5.28/bin
chmod +x *


6. Edited [TOMCAT-HOME]/conf/tomcat-users.xml and changed the default entries

<tomcat-users>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="role1" password="tomcat" roles="role1" />
<user name="both" password="tomcat" roles="tomcat,role1" />
</tomcat-users>

to

<tomcat-users>
<user name="tomcat" password="tomcat" roles="tomcat" />
<user name="admin" password="admin" roles="tomcat,manager" />
</tomcat-users>


7. Set the JAVA_HOME environment variable. To find out the value to set, I looked in /etc/alternatives for the java link and found /usr/lib/jvm/java-6-sun/jre/bin/java. So, the value for JAVA_HOME should be /usr/lib/jvm/java-6-sun/jre. Edited /etc/environment and added the line:

JAVA_HOME="/usr/lib/jvm/java-6-sun/jre"


8. Gave Tomcat a trial run:

cd [TOMCAT-HOME]/bin
startup.sh

Exceptions were thrown complaining that native libraries recommended for good performance in a production environment were not found. This is not relevant to my localhost dev environment.

Opened a browser and went to localhost:8080. Tomcat was up and running. The Manager application worked with the userid and password I had set in tomcat-users for the admin role.

Install Administration Web Application — FAIL



1. Unpacked the Administration Web Application tarball to a temporary location.

2. Copied directory server/webapps/admin to [TOMCAT-HOME]/server/webapps.

3. Copied conf/Catalina/localhost/admin.xml to [TOMCAT-HOME]/conf/Catalina/localhost.

4. Restarted Tomcat.

Tomcat restarted normally. Going to http://localhost:8080/admin just resulted in the default message that the Administration app is not shipped by default anymore. Going to Manager, I could see the admin application deployed but not active. Choosing start resulted in an unhelpful message telling me that the app could not be started.

I found a number of threads online where people had reported the same problem. There were several workarounds, and I tried a couple. Apparently this problem occurs sometimes, but not always, and people are able to work around it by uninstalling and reinstalling, possibly five or six times, but this does not always fix the problem. In my case, it made no difference.

My personal view is that tools should not get in our way. The truth is I don't need the Administration app for local development. I don't really need the Deployer, either, so I blew off even trying to install it.

Since I finally got a basic Tomcat instance up and running, I won't delete it. However, the next time I'm working on a Java-based webapp, I'm going to try some alternatives to Tomcat. I've heard good things about Jetty and Glassfish. There are others, as well. Tomcat used to be pretty handy, but now it's evolved to the point that there's more administrative overhead involved with it than the value it returns, for purposes of development. It's still a nice servlet container when used in conjunction with Apache HTTP Server in production, but I'm done using it as a development tool unless and until they make it work smoothly.

Next: Installing .NET development support

Installing Java support

Previous: Installing Ruby testing tools

Since my system was trashed anyway, I decided to take the opportunity to apply lessons learned over the past few months of using Ubuntu as my primary work platform. I didn't reinstall exactly the same tools as before for Java development. I want to check out some different tools for building, version control, and continuous integration. This time around, I just installed the basic Java tools.

If you're curious about experiences with installing maven2 and/or migrating Java projects from Mac OSX to Linux, please see this post: http://kotowanandesu.blogspot.com/2009/08/installing-support-for-java.html.

These commands get the latest and greatest JDK and make it the system default.

sudo apt-get install sun-java6-jdk sun-java6-plugin
sudo update-java-alternatives -s java-6-sun

Although Java is available for free, it is not Open Source. The Java install will prompt you to agree with license terms. So, don't expect to "fire and forget" this installer.

To verify that Java 6 is the system default, check the default version:

java -version


Next: Installing Tomcat

Installing Ruby testing tools

Previous: Installing Rails

These are tools for test-driven-, behavior-driven-, and storytest-driven-development:

* Autotest - continuous testing (part of ZenTest)
* Cucumber - storytest tool
* RCov - coverage tool
* rspec - BDD tool
* Webrat - browser simulator (used by Cucumber)

On Debian variants (like Ubuntu), you have to install a couple of libraries before installing Webrat. They are needed by Nokogiri, the XML libary used in Webrat.

sudo gem install ZenTest
sudo gem install rcov
sudo gem install rspec rspec-rails
sudo gem install cucumber
sudo apt-get install libxslt1-dev libxml2-dev
sudo gem install webrat


Next: Installing Java support

Installing Rails

Previous: Installing MySQL and Ruby bindings

Use Gems to install Rails. Open a Terminal window and enter

cd ~
sudo gem install rails

If the installation succeeded, the following command will display version information:

rails -v

Next: Installing Ruby testing tools

Saturday, April 10, 2010

Installing MySQL and ruby bindings

Installing MySQL and ruby bindings

Previous: Installing basic ruby support

MySQL Server


In Terminal, install MySQL Server with apt:

sudo apt-get install mysql-server

During installation, you will be prompted to enter a password for the root mysql user. While it's possible to run mysql with no root password, it's generally considered a good practice to use a password.

The installation will automatically start the server. To verify the installation was successful, check to see if the server is running:

ps ax | grep mysql

You can also check for the existence of this file, which exists when the server is running:

/var/run/mysqld/mysqld.pid

The commands to stop and start MySQL Server are

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

If you want to stop the server while continuing to install software, you can do so.

MySQL command-line client


I wanted to configure MySQL to put database data somewhere under my /home directory because it's in a large partition and so that it will be easy to backup and restore my data. To do this, I created the data directory and set permissions so mysql could use it:

cd
mkdir -p .mysql/data
chown mysql .mysql .mysql/data

Now stop the mysql server.

Edit the file /etc/mysql/my.cnf. Look for the section labeled [mysqld] and change (or add) the datadir specification:

datadir=/home/you/.mysql/data

After making those changes, start the server.

To see if the configuration changes worked, start a command-line client

mysql -u root -p

If it starts normally, then the server is running and the localhost connection is working. To ensure mysql is using the datadir you specified, create a test database:

create database test1;

Exit the command-line client by typing "quit". Change to the directory you specified as datadir. If you don't have permission to cd to the directory, use sudo to add read and execute privileges on it. (You need execute privileges to cd to a directory.)

MySQL GUI client


From the main menu bar, choose Applications > Add/Remove....

1. If prompted to update the list of available packages, do so.

2. Under Show, choose All available applications.

3. A few applications may be pre-selected for you. Browse the list and see if you really want any of these. De-select the checkboxes for the ones you don't want. In some cases, the system will warn you that other packages depend on the one you're trying to de-select. In that case, you will need to install it.

4. Select "MySQL Administrator" for a GUI client and "MySQL Query Browser" for a GUI tool to run queries. (If you type "my" in the Search: field, the list will jump right to these entries.)

5. Choose Apply Changes to proceed with the installation. If any of the applications requires administrator rights to install, the system will prompt for your administrator password. This is normal and not an exploit.

After the installer finishes, the two applications will appear under Applications > Programming from the main menu bar.

To ensure MySQL Administrator was installed correctly, with the MySQL server running, go to Applications > Programming and select MySQL Administrator from the menu. The program should open a window containing a form where you can enter connection information. Enter "localhost" for host, "root" for user, and the password you defined earlier for password. If you didn't define a password earlier, then leave the password field empty. Choose Connect.

Check the installation of MySQL Query Browser in the same way.

Install Ruby bindings for MySQL



Open a Terminal window and enter the following commands:

cd ~
sudo apt-get install libmysql-ruby libmysqlclient-dev

The package libmysqlclient-dev is a virtual package. When you run the command above, you will see an error message that shows the name of the real package. Substitute it in the command line and run it again. When I ran it, it showed libmysqlclient15-dev, so I ran the command this way:

sudo apt-get install libmysql-ruby libmysqlclient15-dev

Run this command to build it:

sudo gem install mysql

Expect a lot of error messages for missing definitions in ri and rdoc. As long as the gem and native extensions build okay, you're good to go.

Next: Installing Rails

Friday, April 9, 2010

Installing basic ruby support

Previous: Rethinking directory structure

Still recovering from the system problem reported earlier.

I documented this before, but I've learned a few things since then so some of these steps may be a bit different. If you're using this as a guide for setting up your own Ubuntu system, I'd suggest using the latest posts on each topic.

First, I need support for git:

sudo apt-get install git-core

I want to install various software development tools. Let's start with Ruby. I'll take care of plug-ins and so forth later, when setting up specific projects. For the moment I just want to get basic tools installed.

sudo apt-get install ruby-full

and verify it worked

ruby -v

Also need ruby gems support. The ruby community reports problems when apt is used to install rubygems. The following procedure is recommended instead.

Take your browser to http://rubyforge.org/frs/?group_id=126. In the list of available downloads, hover the mouse cursor over the name of the one you want to see which URL would be downloaded (but don't download it yet). In my case, the URL was http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz.

The key elements to note are the numerical path segment 69365 and the version number, 1.3.6. These elements will vary as new releases are posted. Not very RESTful, I suppose.

Armed with this information, get rubygems this way:

cd ~
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
tar xzvf rubygems-1.3.6.tgz
cd rubygems-1.3.6
sudo ruby setup.rb

The setup.rb script will display the name of the rubygems executable on the console, like this:

RubyGems installed the following executables:
/usr/bin/gem1.8

Use the name to set a symlink like the following

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

and verify it worked

cd ~
gem -v

It will display the version number of gems that is installed. This should match the version number you found on rubyforge.

Now you can delete the installation directory and the tarball:

rm -r rubygems-1.3.6
rm rubygems-1.3.6.tgz

Note that the software is installed under /usr. This is the reason I decided to mount /usr from its own partition. I will be able to repair or upgrade Ubuntu itself without having to reinstall all my software piece by piece.

Next: Installing MySQL, admin tools, and ruby bindings

Rethinking directory structure

Previous: Interesting times

Recovering from interesting times



So, I've got most of my work on an external drive and I've got a nice fresh /home in its own partition. Why not just slap the contents of the backup into /home and declare victory? Well, a fair amount of cruft has accumulated in my /home directory. It could be organized more conveniently. I've got various software development tools installed here and there, and shell scripts in various places. And I really don't need all the jar files and libraries and sample code and old projects and local maven repo and copies of articles to read in my spare time and on and on and on. It's just clutter.

I took the time to decide what I really need on this machine and how it should be organized, and then selectively restore those items from the backup. I also decided to reinstall just the software that I'm actively using, rather than to reinstall everything that had been on the system before.

The default /home directory structure is:


/home
|
+---- Desktop
|
+---- Documents
|
+---- Music
|
+---- Pictures
|
+---- Public
|
+---- Templates
|
+---- Videos


Microsoft Windows and Mac OS X also ship with a similar default directory structure. The default structure is only a suggestion, to help novice computer users get started. But I just don't organize information according to file type (music, pictures, videos, etc.) I keep files that pertain to a given topic together, whatever their various formats and types. I decided to define a structure that reflects the way I usually think about what I'm doing with the computer.

At the highest level, I don't want to have to look at a million folder names to find what I'm looking for. It boils down to this:


/home
|
+---- Desktop
|
+---- Personal
|
+---- Professional
|
+---- .bin


I changed the top-level directory structure just below /home to the above, and removed the old directory names from the Places pane.

Next: Installing basic ruby support

Interesting times

Previous: Microsoft drives another Windows user to Linux

Interesting times


My Ubuntu system had a bad night. I deleted some files from my external hard drive. When I clicked on "empty the trash," odd things started to happen. The external drive's filesystem switched to read-only mode. No error messages that I could find. At some point while I was fiddling around to try and clear out the trash folders, either I did something inadvertently or a glitch in the driver corrupted part of the Ubuntu kernel.

Now Ubuntu couldn't mount filesystems on the internal hard drive. I tried rebooting, on the chance that a fresh start would clear up whatever was wrong. No such luck. Now Ubuntu couldn't boot.

Using someone else's system and Internet connection, I searched for help. I discovered this sort of thing has happened to other Ubuntu users. Apparently the only thing to be done is to reinstall fresh.

The downside: My system was dead in the water. I was in a hotel room, far from any helpful resources I might have had in my home office.

The upside: I had a backup of my work from a few days earlier. I had bootable CDs with me for Ubuntu 9.10 and 9.04. I had my Firefox bookmarks online on XMarks, where I could sync them when ready. Finally, this very blog contains instructions for installing and configuring my system, and warnings about what not to do, just in case I've forgotten. Things could have been so much worse!

Recovering the system


I decided to take the opportunity to do a bit of housecleaning and to apply some of the lessons learned so far in my n00b journey. My hard drive had a dual-boot configuration with Ubuntu and Microsoft Windows Vista. It occurred to me that I hadn't even thought about booting into Windows in the past few months. Why use up half the hard drive space with Windows partitions?

More housecleaning: I had read that most Ubuntu users define a separate partition for their /home directory. It makes upgrades easier, since you can install a new release of the OS in the root partition and keep your /home intact. Another thing I've learned is that /usr/local and /usr/share are updated when you install software and customize gnome. You don't have to install things in those locations, but they are default locations. With that in mind I wiped the drive and created the following partitions:

* /
* /usr
* /home
* swap

I tried installing from the 9.10 disk, and had problems. Again using someone else's system to look for help, I learned that 9.10 has some known kernel issues, one of which is that it doesn't support the wireless adapter that my machine has (Intel AGN 5100). It also seemed to have problems mounting the /home and /usr partitions. No helpful error messages.

Next I installed from the 9.04 disk, and had similar problems booting and mounting the partitions. I also noticed that there was no driver for the wireless adapter and that audio was disabled. I remembered that these problems had been fixed at some stage in the evolution of 9.04, and surmised that I had an old release of Ubuntu on that disk.

I installed from the 9.04 disk again, this time defining just one partition for the whole OS. This instance could boot, but had no network support. Again using another system, I downloaded the last stable Ubuntu 9.04 iso from releases.ubuntu.com/9.04 to a thumb drive, and used the old 9.04 instance to burn it to a DVD.

This version of 9.04 installed nicely into the partitioning scheme described above and booted without complaint. I felt like the Apollo 13 astronauts after they'd restarted the Command Module. Well, okay, maybe that's a stretch.

Update mistake


To bring the new instance up to date, I opened a Terminal window and ran these commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get build-essential


At this point I made a mistake. I used Update Manager to check for available updates and install them. After more than two hours, the update process became confused when trying to install a package. The process hung, and the last message on the console was "stopping bluetooth." I waited a while just in case it was doing something under the covers, but ultimately I killed the process and rebooted. The system was very confused about what was installed and what wasn't. Network support was gone again.

Since I was still early in the recovery process, I just reinstalled from scratch again. This time, after running the update commands in Terminal, I didn't try to do any updates through Update Manager.

To the contrary, I started the gnome configuration editor (alt+F2, enter gconf-editor, click Run), went to apps > Update Notifier, and deselected the auto-run checkbox. This is to protect myself from responding to the prompt about available updates. I'll update packages that are flagged as dependencies for software that I want to install. Otherwise, I'll stick with the working version of 9.04.

Next: Rethinking directory structure