For a while now, I have kept notes of technical problems I've encountered and solved. The goal was to save myself the hassle of re-Googling answers, if the same problem reoccured. Judging by my web site's usage logs, it helps others, too. :)

Text between backticks, `like this`, should be typed as-is (minus the backticks themselves) at the command line, usually as root. Text between single quotes, 'like this', should be typed as-is (minus the apostrophes themselves) wherever the instructions say they should be.

FAQ Revised: Friday 24 October 2008 23:26:07


Table of Contents

1. Drupal
2. JavaScript
3. Linux
4. MySQL
5. Ruby
6. Subversion
7. Web

1. Drupal

1.1. PHP PostgreSQL support not enabled

This error isn't actually a Drupal bug, but the PostgreSQL extension not being loaded for PHP. You're supposed to just add extension=pgsql.so to your php.ini file, double-check that extension_dir is correctly set, and everything Just Works™.

So there's something else wrong with my PHP configuration, but in the meantime there is a work-around for getting Drupal to work. In your Drupal directory, edit the file include/database.pgsql.inc. Find the function db_connect and add the following code to the beginning of it:

if (!extension_loaded('pgsql')) {
   dl('pgsql.so');
}

This just makes PHP dynamically load the module at runtime, if it hasn't already been loaded. Kludge, but it works until I figure out what's wrong with my PHP installation itself.



1.2. Users do not stay logged in. I'm using PHP 5.2.

This problem is documented on the Drupal site. Download the patch files drupal_php5.2.0.patch.txt and drupal_php5.2.0_session.patch.txt to the top directory of your Drupal installation and apply them by running `patch -p0 < drupal_php5.2.0.patch.txt` and `patch -p0 < drupal_php5.2.0_session.patch.txt`.




2. JavaScript

2.1. Using JavaScript setAttribute doesn't work in IE.
The setAttribute method is indeed somewhat buggy in IE. However, IE also non-standardly allows full HTML to be passed via document.createElement(), which lets you get around the problem. See the ByteClub wiki for more information.

2.2. In IE, the JavaScript getElementById also looks at elements' names.
Apparently, IE treats name and id very similarly, to the point that getElementById also gets element by name, contrary to what you might logically expect. The workaround is to use the same name and id on a single element, and to not reuse ids as names on any elements. See also this Usenet thread.

2.3. Variables in closures within loops always have same value

Read A huge gotcha with Javascript closures and loops by Keith Lea.




3. Linux

3.1. What version of Mandrake am I running?
`cat /etc/mandrakelinux-release`

3.2. How do I install new TTF fonts manually?
`mv foo.ttf /usr/lib/X11/fonts/TTF`, `cd /usr/lib/X1/fonts/TTF`, `ttmkfdir -o fonts.scale`, `mkfontdir`, `xset fp rehash`,

3.3. An admin user is not in the sudoers file.
`su` (i.e., become root), `visudo`. In the "User privileges" section, add the line 'foo ALL = (ALL) ALL' to let user "foo" have full root-like access, or add 'foo localhost = /usr/bin/doStuff' to give him root-like access to only the command "doStuff". Save and exit (:wq) from the sudoers file.

3.4. ld error: cannot find -lfoo
`ls /usr/lib/libfoo*`. If there is a file like libfoo.so.0.2.1 or similar, make a symlink: `ln -s libfoo.so.0.2.1 libfoo.so`. Verify by `ldd /usr/lib/libfoo.so`.

3.5. `urpmi --update` doesn't see latest version of RPMs.
`urpmi.update updates` to refresh the package list.

3.6. The scroll wheel doesn't scroll.
Edit /etc/X11/XF86Config, section "InputDevice," Identifier "Mouse1." Change the line that reads 'Option "ZAxisMapping" "6 7"' to use the numbers '"4 5"' instead. Restart the X server (Ctrl-Alt-Backspace).

3.7. The printer stopped printing.
`lpstat -t`. If it hangs, check printer power (then wait a minute or so if you had to turn it on). `/usr/bin/enable HPDeskJet5550` (substituting the printer name the previous command returned where I have "HPDeskJet5550"). `lpstat -t` agaoin to confirm that it's enabled now. `lprm -` to remove all previously queued print jobs. This step isn't necessarily necessary.

3.8. How do I reset password protecting my Apache-served website?
cd into your Apache's passwd directory and `../bin/htpasswd passwd <user>`. See also Apache's authorization docs.

3.9. checking if UIC has KDE plugins available... no. configure: error: you need to install kdelibs first.
./configure --with-qt-dir=/usr

3.10. I tried to install Firefox from the binary tarball, but the installer crashes when I click the "Forward" button.
If the error message looks like:
SCIM: im_module_init
free(): invalid pointer 0x81f2f88!
free(): invalid pointer 0x81f2f60!
./firefox-installer: line 56: 15182 Segmentation fault      ./${BINNAME}-bin $@
then try installing from an RPM instead. Search RPMs for "mozilla-firefox" and install (or upgrade) via the RPM.

3.11. `showkey` complains: "Couldnt get a file descriptor referring to the console".
If you are running this command in a GUI console window under X, try switching to a tty terminal: Ctrl-Alt-F1, then `showkey`. You can return to your X session with Alt-F1.

3.12. How do I make Bash tab completion case-insensitive?
Put in /etc/inputrc or ~/.inputrc the following line: 'set completion-ignore-case On'.

3.13. When running make, I get this error: /usr/bin/ld: cannot find -lc.
`urpmi glibc-static-devel`

3.14. What do device names hda, hdb, hdc, and hdd mean?
primary master, primary slave, secondary master, secondary slave

3.15. How do I access Samba shares?
I'm assuming you already have Samba installed on your Linux server. Modify the default /etc/samba/smb.conf to include the following options:
   workgroup = YOUR_WINDOWS_WORKGROUP ; not necessary, but is easier
   encrypt passwords = yes
   smb passwd file = /etc/samba/smbpasswd
   interfaces = eth0 lo

   [sharename]
      comment = Your Share's Name
      path = /path/to/files
      ; use the following two lines for a private share
      public = no
      valid users = your_username
      ; or, uncomment and use the following one line for a public share
      ;public = yes
      writable = yes
      printable = no
Restart Samba with `/etc/init.d/smb restart`, and create a password for your_username with `smbpasswd -a your_username`. Under Windows, browse to \\servername\sharename\ and type in your_username and the password you set with smbpasswd.

3.16. How do I upgrade the kernel?
  1. download the latest kernel from kernel.org and extract the file to /usr/src
  2. `sudo su`
  3. `cd /usr/src/linux<version number>`
  4. `cp /proc/config.gz ./`
  5. `gunzip /proc/config.gz`
  6. `mv config .config`
  7. `make oldconfig` and answer any prompts (probably with the default values unless you know better)
  8. `make`
  9. `make modules_install`
  10. `cp ./arch/i386/boot/bzImage /boot/linux<version number>`
  11. `cp System.map /boot/System.map-<version number>`
  12. modify /etc/lilo.conf (or whatever your system uses to choose its kernel) to include the new kernel image
  13. `lilo -v` to install the modified configuration file, if you use Lilo
  14. `reboot`


3.17. attr complains: "Operation not supported"

The filesystem must be mounted with the user_xattr option. For example:

   /dev/hda3   /home   ext3   defaults,user_xattr   1 2

in /etc/fstab. Remount any filesystems you modify: `mount -o remount /home`.



3.18. `attr -l <filename>` segfaults after assigning files an attribute.

There is a bug in attr 2.4.28. Apply this patch to fix it, then recompile and reinstall attr.



3.19. How do I start using RAID 1?

The Linux Documentation Project maintains a comprehensive RAID HOWTO. The instructions below are merely what worked for me, in my specific situation.

I had my system partitions on one drive and my /home partition on a separate drive. That second drive was just about out of space, so I bought two new, larger drives to replace it. While I was at it, I figured I'd turn the two drives into a RAID 1 setup (that is, one would mirror the other). If your situation is substantially different than mine, I suggest you read the TLDP's HOWTO.

  1. Plug in the new IDE drives and remove any unnecessary ones. I ended up with my system drive, CD-ROM drive, and the two new drives in my computer case. The old /home drive was attached via an external USB enclosure.
  2. Boot the system. mount any system partitions that didn't mount themselves.
  3. Edit /etc/fstab to comment out the drive that contained `cd /usr/src/linux-2.6.15.6` or whenever your kernel source directory is.
  4. `make menuconfig`. Select "Device Drivers" > "Mult-device support (RAID and LVM)". From there, turn on as built-in (rather than as modules) "Multiple devices driver support (RAID and LVM)," "RAID support," and "RADI-1 (mirroring) mode."
  5. `make`
  6. `cp arch/i386/boot/bzImage /boot/linux-2.6.15.6`
  7. Edit /etc/lilo.conf to include the new image.
  8. `lilo -v` and `reboot now`
  9. After the reboot, `hdparm -i /dev/hdb` or whichever is one of the two new drives. Repeat for the other drive, partitioning each with one partition.
  10. The HOWTO says to use the mkraid command to initialize the RAID array, but I got an "invalid chunk size (0kb)" error message. Instead, I used `mdadm --create -l 1 -n 2 /dev/md0 /dev/hdb /dev/hdc`
  11. Edit /etc/mdadm.conf to look like:
    DEVICE /dev/hdb1 /dev/hdc1
    ARRAY /dev/md0 devices=/dev/hdb1,/dev/hdc1
  12. `reboot now`



4. MySQL

4.1. The MySQL client can't connect.
`mysql -p` gives "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)". Check that mysqld is running: `ps aux | grep mysqld'. If not, start it with `/usr/local/mysql/bin/mysqld_safe &`.

4.2. mysqld_safe ends immediately (during installation).
Check the bottom of the error log, in the dir mentioned by the error message, "Starting mysqld daemon ... /usr/local/mysqld/data". If the log says, "Can't read dir of '/bad/foo' (Errcode 13)", then mysqld doesn't have permissions there. `export TMPDIR=/tmp`. Verify by `echo $TMPDIR`. `./scripts/mysql_install_db --user=mysqlf`, `./bin/mysqld_safe --user=mysql &`.


5. Ruby

5.1. Ruby scripts fail with in `require': no such file to load -- SomeFile (LoadError)

Ruby scripts that require some modules, and even Ruby utility programs like gem and gemwhich fail to run unless they're invoked as root or via sudo. In my case, just running `gem` gave the following error:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:10:in `require': no such file to load -- digest/sha2 (LoadError)
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:10
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:461:in `require'
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:461
        from /usr/local/bin/gem:9:in `require'
        from /usr/local/bin/gem:9

Running `sudo gemwhich digest/sha2` told me that this particular file was located at /usr/local/lib/ruby/1.8/i686-linux/digest/sha2.so, so I cd'd into that directory and checked out the file permissions with `ls -l`.

Lo and behold, the permissions made the file unreadable to anyone but root, which explained the problem. From the directory /usr/local/lib/ruby/1.8/i686-linux I ran `sudo chmod -R a+rX *` to set all files to be readable and all directories both readable and executable to everyone. Now everything works for the normal users.



5.2. Installed Ruby gems fail with in `require': no such file to load -- SomeFile (LoadError)

I had this problem while installing my first Ruby gem, which happened to be FasterCSV. I installed the gem without any error messages via `sudo gem install fastercsv`, but I couldn't even include it in a Ruby program, much less use the module.

This problem is addressed in the RubyGems manual, which basically says you have to tell Ruby that you're using gems before it can load the installed files. The command `ruby -e 'require "fastercsv"'` fails with the above error message, while both `ruby -rubygems -e 'require "fastercsv"'` and `ruby -rubygems -e 'require "rubygems";require "fastercsv"'` work.

So, you have three options for fixing this problem:

  1. invoke Ruby scripts with ruby -rubygems
  2. include require 'rubygems' in every script
  3. `export RUBYOPT=-rubygems`

You'll probably want to put the RUBYOPT solution into your .profile or equivalent, so you don't have to type it each time you log in.



5.3. Ruby fails with command not found: pg_config --libdir when installing the postgres module.

If pg_config is installed, try `export POSTGRES_INCLUDE=/usr/local/pgsql`.



5.4. Upgraded rake fails: undefined method `last' for {}:Hash in resolve_args

After upgrading a Rails 1.2.3 application to 2.0, rake stopped working with the above error message. Turns out that the override_task plugin (or anything that calls Rake.application.resolve_args method) needs a very slight modification to work with rake version greater than 0.7.3.

The first argument of resolve_args now expects an array, so wrap up the argument you were passing:

names, deps = Rake.application.resolve_args([args])


5.5. A copy of ApplicationController has been removed from the module tree but is still active

Add unloadable to all Rails plugin controller classes. See the Rails tracker.



5.6. stack level too deep

When require'ing rubyclr in a Rails plugin controller, requests handled by that controller would only work the first time. All subsequent calls would give me the stack level too deep error message.

See also:




6. Subversion

6.1. Subversion won't commit because has unexpectedly changed special status.

Subversion can't handle changing a file to a symlink or vice versa in one step. You have to remove the old file completely, then re-add and commit the new type of file. I don't know of any way to keep the file's history once you do this, unfortunately.



6.2. skipped C:\Documents and Settings\USERNAME\Temp\svn42.tmp

After upgrading TortoiseSVN to version 1.5.4, trying to update a working copy reports the message skipped C:\Documents and Settings\USERNAME\Temp\svn42.tmp and exits, not updating anything. This means you did not reboot after installing version 1.5.4. Rebooting should fix the problem.




7. Web

7.1. How can I suppress the <?xml version="1.0" ?> line when converting XML to HTML?
XML defaults to <xsl:output method="xml" />, which isn't quite what you want in this case. <xsl:output method="text" /> isn't what you want either, but <xsl:output method="text" omit-xml-declaration="yes" /> will give you what you want. You can have an even better solution, however: <xsl:output method="html" />. This will insert line breaks in logical places between HTML elements, making the source code much prettier and more readable.

7.2. Greasemonkey's GM_log doesn't show up in Firebug's console.

According to the Greasemonkey wiki, as of Firebug 1.0 you have to set extensions.firebug.showChromeMessages to true via about:config for the GM_log messages to show up in the Firebug console..