gcc12 fault?
Joshua Root
jmr at macports.org
Fri Jun 2 01:18:18 UTC 2023
Ken Cunningham wrote:
> what you see is difficult to explain, unless the PATH changed between the two tests.
>
> if
>
> 'which gcc' gives /opt/local/bin/gcc
>
> then
>
> gcc --version
>
> should give exactly the same as
>
> /opt/local/bin/gcc --version
Not necessarily. Shells cache command locations, so if 'gcc' was run
prior to the creation of /opt/local/bin/gcc, subsequently invocations
will continue to run the previously found gcc. Running 'hash -r' or
starting a new shell will give you an empty cache and thus set things right.
The 'which' command doesn't know about the shell's cache state; it only
looks at the current PATH. This is why 'type' often helps to understand
what's going on in these situations, as Richard hinted.
- Josh
More information about the macports-users
mailing list