It can't capture in that direction. The white pawn is moving to the 8th rank, and so can only attack g5 and e5.
The rook is behind the pawn.
the white pawn goes toward the 8th rank, so the rook is actually behind the pawn, so the pawn cannot capture.
if funny ask here a lichess.org game
so easy solution ) thank you