As Protoss:
The safest thing to do as protoss is to build at least one sentry as early as possible from your first gateway. This will let it save up energy so that you can cast more force fields.
If you do this and also scout the roach rush you should be prepared to place the force field well (trap 1 or two roaches on your side of the ramp so that you can pick them off).
Since all maps except scrap station (which has a really long rush distance) have small ramps this is probably the only thing you need to do to beat it.
Is the rush really done that often? Doesn't feel very strong against protoss because since the ff at the ramp totally negates it.
As Zerg:
Scout (overlord, drone, first group of lings), zvz is the match-up where you absolutely have to know what your opponent is doing at all times, hence you should see it coming.
Plant one or two spine crawlers and build a batch of lings and you should be able to fend it off. If you think its really close: pull probes early in the fight, they're reasonably good against roach.
OR: when you see him going roach, build a bunch of lings and make him pay. Going roach without any lings first is rather risky as I see it.
As Terran:
Build a free bunker, if needed send a scv and click auto-repair.