I came across a way of allowing an 8 speed cassette to work with a 9 speed shifter. The method I used is similar, though different to hub-ub's fix. I use an 8 speed cassette (HG51) with XT 9 speed shifter and a 9 speed XT derailleur.
The gear cable (coming out from the barrel adjuster) goes around towards the wheel or the inside of the anchor bolt. You could pull the cable around the bolt and towards the back of the bike but it is not necessary (see image 1 and 2):
Many derailleur anchor bolts have a 'hook and tab' part or plate between the bolt and the threaded-hole:
You may need to get one of these from an older derailleur as some of the present day ones don't have ''hooks'', only the 'tabs'. The hooks are the bent parts of the plate in the image above. They fit over the edges of the threaded hole onto the body to make their own fittings more secure on the derailleur body.
The two hooks have different size and one of them (whether the narrow or the wide depends) should 'face' towards the back of the bike, i.e. towards the barrel adjuster. The opposing hook will fit to the derailleur body. You'll see it when you're down there.
N.B. there will be 'play' in the hook's position under the anchor bolt before you tighten the bolt. this is key to fine tuning the shifting.
The position of the 'edge' of the hook (touching the gear cable) when secure will affect how much the cable is shortened with each pull (movement) across the 'swing' of the derailleur, since subtle movements of the hook are what changes the cable pull.
The principle in this instance is the one of a 'cam' action. It's about cable pull and what happens at the hook if the position of the hook against the cable changes.
wanted to add a few more details to what's already posted[for clarification].
the wider hook is the main one for use with 9 speed shifters and an 8 speed cassette, not the narrow one. found this out today.
the 'narrow' hook is in play[?] to maintain an exact and secure fitting to the derailleur body[?].
am not sure if this is the case or if it's there for another reason.
the wide hook will fit exactly and won't move as the narrow hook does
the narrow hook is a problem if used. a fair bit of tweaking is necessary
you have to manouver the narrow hook's position so that when cable is pulled tight the hook doesn't move.
if the wider hook is used instead, process is straight forward...tighten down the bolt make sure the gear cable is reasonably tight. tweak the shifting at the shifter adjuster and that's about it. job done.