You might find that this can also happen if your X session is owned by a normal user who's su'd to root to do the installation. If this scenario bites you and you don't want to start another X session, just ssh as root to localhost with X exported (if your machine is configured to allow X exports via SSH) then perform the installation.
There's probably a cleaner way to do this, but I've never sought it out.