Re: gcc12 fault?
On 2/6/2023 16:47, Ken Cunningham wrote: You have probably already noted that which and type are both built in to the default zsh on Ventura and as far as I can tell from my testing here give identical results in every case. Both correctly predict the binary that will be executed in every case I tried. Indeed, zsh is a bit special and implements both 'which' and 'type' in terms of its 'whence' builtin (which has a lot of options and can tell you pretty much anything you would ever want to know about a command's disposition, check it out.) You will notice /usr/bin/which can thus give different results to just 'which'. What will happen when you add and remove binaries from an upstream PATH folder is a bit difficult to predict accurately. I won't try to summarize the findings only to have someone point out their idea of an exception, but it's fair to say that it's best to open a new shell to get predictable results. You would want to start a new shell if you changed the startup files. Otherwise 'hash -r' is quite sufficient. Changing the value of PATH at runtime will do that automatically in modern shells, BTW. - Josh
Re: gcc12 fault?
> On Jun 1, 2023, at 6:18 PM, Joshua Root wrote: > > 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 > You have probably already noted that which and type are both built in to the default zsh on Ventura and as far as I can tell from my testing here give identical results in every case. Both correctly predict the binary that will be executed in every case I tried. What will happen when you add and remove binaries from an upstream PATH folder is a bit difficult to predict accurately. I won't try to summarize the findings only to have someone point out their idea of an exception, but it's fair to say that it's best to open a new shell to get predictable results. K
Re: gcc12 fault?
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
Re: gcc12 fault?
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 Now you know that /opt/local/bin/gcc will not actually exist, unless you have "selected" a gcc in macports to be your default gcc. You probably want to unselect that if you did select one, as having it always set can cause problems that can be hard to debug. I do set a selected gcc sometimes, but unset it right after. Ken On 2023-06-01, at 8:17 AM, David Nicholls via macports-users wrote: > I upgraded OSX to the latest Ventura, installed the latest Xcode, and Xcode > tools, accepted the license, then reinstalled Macports as per the > instructions. Versions of gcc older than gcc12 failed (as advised in the > resintall), so I installed gcc12, ran port select to activate gcc12 and > gfortran12. All ok so far. > > 'which gcc' gives /opt/local/bin/gcc > > But: > > :~ username$ gcc --version > Apple clang version 14.0.3 (clang-1403.0.22.14.1) > Target: x86_64-apple-darwin22.5.0 > Thread model: posix > InstalledDir: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin > > and > > :~ username$ /opt/local/bin/gcc --version > gcc (MacPorts gcc12 12.3.0_0+stdlib_flag) 12.3.0 > Copyright (C) 2022 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > Why does the command 'gcc --version' not give that same result as > '/opt/local/bin/gcc --version' ? > > 'gfortan --version' works as expected > > DN
Re: gcc12 fault?
You're right, it's zsh. And "which" seems to be builtin with zsh. > On Jun 1, 2023, at 11:46, contextnerror wrote: > > I thought zsh was the new default shell? > >> On Jun 1, 2023, at 8:38 AM, Richard L. Hamilton wrote: >> >> Try "type" rather than "which"; "type" is a builtin command in bash, dash, >> sh, and ksh. "which" is typically not a builtin. Usually they should say the >> same thing, but if they're not, something is odd, perhaps with your .bashrc >> or .profile or whatever. >> >> Pretty sure dash is the default shell in Ventura (actually in Monterey >> too?), apparently Apple wasn't thrilled with the bash license. >> >> Nothing else seems obvious, and since I'm having some network issues, I'm >> not going to start my Ventura VM to look at it right now. >> >> >>> On Jun 1, 2023, at 11:17, David Nicholls via macports-users >>> wrote: >>> >>> I upgraded OSX to the latest Ventura, installed the latest Xcode, and Xcode >>> tools, accepted the license, then reinstalled Macports as per the >>> instructions. Versions of gcc older than gcc12 failed (as advised in the >>> resintall), so I installed gcc12, ran port select to activate gcc12 and >>> gfortran12. All ok so far. >>> >>> 'which gcc' gives /opt/local/bin/gcc >>> >>> But: >>> >>> :~ username$ gcc --version >>> Apple clang version 14.0.3 (clang-1403.0.22.14.1) >>> Target: x86_64-apple-darwin22.5.0 >>> Thread model: posix >>> InstalledDir: >>> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin >>> >>> and >>> >>> :~ username$ /opt/local/bin/gcc --version >>> gcc (MacPorts gcc12 12.3.0_0+stdlib_flag) 12.3.0 >>> Copyright (C) 2022 Free Software Foundation, Inc. >>> This is free software; see the source for copying conditions. There is NO >>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >>> >>> Why does the command 'gcc --version' not give that same result as >>> '/opt/local/bin/gcc --version' ? >>> >>> 'gfortan --version' works as expected >>> >>> DN >>> >> >
Re: gcc12 fault?
I thought zsh was the new default shell? > On Jun 1, 2023, at 8:38 AM, Richard L. Hamilton wrote: > > Try "type" rather than "which"; "type" is a builtin command in bash, dash, > sh, and ksh. "which" is typically not a builtin. Usually they should say the > same thing, but if they're not, something is odd, perhaps with your .bashrc > or .profile or whatever. > > Pretty sure dash is the default shell in Ventura (actually in Monterey too?), > apparently Apple wasn't thrilled with the bash license. > > Nothing else seems obvious, and since I'm having some network issues, I'm not > going to start my Ventura VM to look at it right now. > > >> On Jun 1, 2023, at 11:17, David Nicholls via macports-users >> wrote: >> >> I upgraded OSX to the latest Ventura, installed the latest Xcode, and Xcode >> tools, accepted the license, then reinstalled Macports as per the >> instructions. Versions of gcc older than gcc12 failed (as advised in the >> resintall), so I installed gcc12, ran port select to activate gcc12 and >> gfortran12. All ok so far. >> >> 'which gcc' gives /opt/local/bin/gcc >> >> But: >> >> :~ username$ gcc --version >> Apple clang version 14.0.3 (clang-1403.0.22.14.1) >> Target: x86_64-apple-darwin22.5.0 >> Thread model: posix >> InstalledDir: >> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin >> >> and >> >> :~ username$ /opt/local/bin/gcc --version >> gcc (MacPorts gcc12 12.3.0_0+stdlib_flag) 12.3.0 >> Copyright (C) 2022 Free Software Foundation, Inc. >> This is free software; see the source for copying conditions. There is NO >> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >> >> Why does the command 'gcc --version' not give that same result as >> '/opt/local/bin/gcc --version' ? >> >> 'gfortan --version' works as expected >> >> DN >> >
Re: gcc12 fault?
Try "type" rather than "which"; "type" is a builtin command in bash, dash, sh, and ksh. "which" is typically not a builtin. Usually they should say the same thing, but if they're not, something is odd, perhaps with your .bashrc or .profile or whatever. Pretty sure dash is the default shell in Ventura (actually in Monterey too?), apparently Apple wasn't thrilled with the bash license. Nothing else seems obvious, and since I'm having some network issues, I'm not going to start my Ventura VM to look at it right now. > On Jun 1, 2023, at 11:17, David Nicholls via macports-users > wrote: > > I upgraded OSX to the latest Ventura, installed the latest Xcode, and Xcode > tools, accepted the license, then reinstalled Macports as per the > instructions. Versions of gcc older than gcc12 failed (as advised in the > resintall), so I installed gcc12, ran port select to activate gcc12 and > gfortran12. All ok so far. > > 'which gcc' gives /opt/local/bin/gcc > > But: > > :~ username$ gcc --version > Apple clang version 14.0.3 (clang-1403.0.22.14.1) > Target: x86_64-apple-darwin22.5.0 > Thread model: posix > InstalledDir: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin > > and > > :~ username$ /opt/local/bin/gcc --version > gcc (MacPorts gcc12 12.3.0_0+stdlib_flag) 12.3.0 > Copyright (C) 2022 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > Why does the command 'gcc --version' not give that same result as > '/opt/local/bin/gcc --version' ? > > 'gfortan --version' works as expected > > DN >
gcc12 fault?
I upgraded OSX to the latest Ventura, installed the latest Xcode, and Xcode tools, accepted the license, then reinstalled Macports as per the instructions. Versions of gcc older than gcc12 failed (as advised in the resintall), so I installed gcc12, ran port select to activate gcc12 and gfortran12. All ok so far. 'which gcc' gives /opt/local/bin/gcc But: :~ username$ gcc --version Apple clang version 14.0.3 (clang-1403.0.22.14.1) Target: x86_64-apple-darwin22.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin and :~ username$ /opt/local/bin/gcc --version gcc (MacPorts gcc12 12.3.0_0+stdlib_flag) 12.3.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Why does the command 'gcc --version' not give that same result as '/opt/local/bin/gcc --version' ? 'gfortan --version' works as expected DN