Compile problem

Have you tried reinstalling Rtools? That should edit your path so that Rtools is on it. Otherwise, you’d need to edit your path yourself and ensure the appropriate existing Rtools paths are on it.

When the system finds a command, it looks up PATH, then goes down it in order looking in those directories for implementations. When things change, you might get a different first choice.

What got installed ahead of Rtools? This may be something that can’t be fixed with global configuration if that other thing is assuming a different toolchain is first on the path.