Re: [R-SIG-Mac] gfortran: command not found
Hello, Simon Urbanek and Professor Ripley: On 7/7/23 4:21 AM, Simon Urbanek wrote: On Jul 7, 2023, at 6:54 PM, Prof Brian Ripley wrote: An alternative is not to have gfortran on the path and use a personal Makevars file, as documented at https://cran.r-project.org/doc/manuals/r-devel/R-admin.html#macOS-packages . Reasons to do it that way include a) GCC builds have included other compilers including gcc in the same directory as gfortran, and I have been caught in the past by badly-written software looking for gcc as a C compiler and finding that one rather than Apple's gcc which is a wrapper for clang. (The current gfortran distribution only includes x86_64-apple-darwin20.0-gcc and similar.) b) If the gfortran you have installed differs from that used to build R, you may need to set FLIBS, and this has happened as different CRAN distributions have been built with different versions of gfortran. When I do want gfortran on the path, for example to build other software, I do symlink it to somewhere on my path. I would prefer if Simon continues to give the full path as FC in etc/Makeconf: anyone who wants a different compiler can use a personal Makevars. (Continues at least for arm64, and I would prefer consistency.) I agree - it wasn't entirely intentional (it's really historical), but then there was request for a PATH-less gfortran settings. After this discussion I agree that it's not a good idea since the instructions on CRAN should be fully self-sufficient *and* we want to avoid other incompatible Fortran compilers. (I have trouble reaching the x86_64 build machine from home right now, so I'll change it on Monday). Might it be feasible and appropriate for me to try to do this on my 2014 MacBook Pro running macOS 11.7.8? I ask, because I have so far not been able to parse the instructions in the link Prof. Ripley provided above. I found a ".r" subdirectory in my default directory, but its contents seems to be only "crashpad_database". I did not see anything that looked to me like, "HOME/.R/Makevars-R_PLATFORM". ??? Thanks, Spencer Graves Thanks, Simon On 07/07/2023 00:07, Simon Urbanek wrote: On 7/07/2023, at 10:15 AM, Spencer Graves wrote: Hi, Simon: Thanks for this. I have more questions: On 7/6/23 4:52 PM, Simon Urbanek wrote: In the shell: PATH=/opt/gfortran/bin:$PATH R CMD INSTALL ... Please excuse my ignorance, but I don't understand this. I previously tried "PATH=/bin:/sbin:/user/bin:/user/sbin:/system/Library/ export PATH", recommended on a page associated with support.apple.com, as mentioned below. That did not seem to work for me. That one sets the specified fixed path and then exports it. Setting a fixed PATH by hand is typically a bad idea since it removes all existing entries - and the one you listed didn't even have gfortran on it. Exporting is another alternative if you want to set the PATH for all subsequent commands. The line I sent just prepends the /opt/gfortran/bin to the PATH for the one R CMD command, but doesn't affect anything else. I would recommend reading a basic tutorial on unix shell if you really want to know more (actually a good idea if you ever want to use the Terminal and not kill your machine). How is this different? What did I do wrong before that this would fix? [Or feel free to ignore this question: My immediate problem seems to be fixed, and I'm not eager to do more experimentation with this now ;-] in R if using install.packages() Sys.setenv(PATH=paste0("/opt/gfortran/bin:", Sys.getenv("PATH"))) If I set this in RStudio, will it affect what I do in "Terminal" on my Mac and vice versa? No, it is only valid for the current R session (and I don't know about RStudio - it's not R so sometimes R rules don't apply), that's why I said it's for the case where you run install.packages() in the R session. Note that another alternative is to simply symlink gfortran to your /usr/local/bin since that is on the PATH on macOS by default, i.e., you only need to run this in the Terminal once (requires admin access): sudo ln -sfn /opt/gfortran/bin/gfortran /usr/local/bin/gfortran Cheers, Simon This looks like a potentially similar thing to do from what I did. Is the effect of this different? If so, how? [Again, please feel free to ignore this question. I'm not eager to practice my "do-it-myself lobotomy" skills ;-] Thanks, Spencer Graves> On Jul 7, 2023, at 5:58 AM, Spencer Graves wrote: 1. I need to apologize to Simon: I failed to see his reply to the original post. Then I found the instructions and installed gfortran-12.2-universal.pkg, as indicated there, but it still didn't work. 2. I'm not finding clear instructions on how to update the path on macOS 11.7.8, which is the latest version available for my 2014 MacBook Pro with a 2.8 GHz Quad-Core Intel Core i7. I
Re: [R-SIG-Mac] gfortran: command not found
> On Jul 7, 2023, at 6:54 PM, Prof Brian Ripley wrote: > > An alternative is not to have gfortran on the path and use a personal > Makevars file, as documented at > https://cran.r-project.org/doc/manuals/r-devel/R-admin.html#macOS-packages . > > Reasons to do it that way include > > a) GCC builds have included other compilers including gcc in the same > directory as gfortran, and I have been caught in the past by badly-written > software looking for gcc as a C compiler and finding that one rather than > Apple's gcc which is a wrapper for clang. (The current gfortran distribution > only includes x86_64-apple-darwin20.0-gcc and similar.) > > b) If the gfortran you have installed differs from that used to build R, you > may need to set FLIBS, and this has happened as different CRAN distributions > have been built with different versions of gfortran. > > When I do want gfortran on the path, for example to build other software, I > do symlink it to somewhere on my path. > > I would prefer if Simon continues to give the full path as FC in > etc/Makeconf: anyone who wants a different compiler can use a personal > Makevars. (Continues at least for arm64, and I would prefer consistency.) > I agree - it wasn't entirely intentional (it's really historical), but then there was request for a PATH-less gfortran settings. After this discussion I agree that it's not a good idea since the instructions on CRAN should be fully self-sufficient *and* we want to avoid other incompatible Fortran compilers. (I have trouble reaching the x86_64 build machine from home right now, so I'll change it on Monday). Thanks, Simon > > On 07/07/2023 00:07, Simon Urbanek wrote: >>> On 7/07/2023, at 10:15 AM, Spencer Graves >>> wrote: >>> >>> Hi, Simon: >>> >>> >>> Thanks for this. I have more questions: >>> >>> >>> On 7/6/23 4:52 PM, Simon Urbanek wrote: In the shell: PATH=/opt/gfortran/bin:$PATH R CMD INSTALL ... >>> >>> >>> Please excuse my ignorance, but I don't understand this. I >>> previously tried "PATH=/bin:/sbin:/user/bin:/user/sbin:/system/Library/ >>> export PATH", recommended on a page associated with support.apple.com, as >>> mentioned below. That did not seem to work for me. >>> >> That one sets the specified fixed path and then exports it. Setting a fixed >> PATH by hand is typically a bad idea since it removes all existing entries - >> and the one you listed didn't even have gfortran on it. Exporting is another >> alternative if you want to set the PATH for all subsequent commands. >> The line I sent just prepends the /opt/gfortran/bin to the PATH for the one >> R CMD command, but doesn't affect anything else. I would recommend reading a >> basic tutorial on unix shell if you really want to know more (actually a >> good idea if you ever want to use the Terminal and not kill your machine). >>> How is this different? What did I do wrong before that this would >>> fix? [Or feel free to ignore this question: My immediate problem seems to >>> be fixed, and I'm not eager to do more experimentation with this now ;-] >>> in R if using install.packages() Sys.setenv(PATH=paste0("/opt/gfortran/bin:", Sys.getenv("PATH"))) >>> >>> >>> If I set this in RStudio, will it affect what I do in "Terminal" on >>> my Mac and vice versa? >>> >> No, it is only valid for the current R session (and I don't know about >> RStudio - it's not R so sometimes R rules don't apply), that's why I said >> it's for the case where you run install.packages() in the R session. >> Note that another alternative is to simply symlink gfortran to your >> /usr/local/bin since that is on the PATH on macOS by default, i.e., you only >> need to run this in the Terminal once (requires admin access): >> sudo ln -sfn /opt/gfortran/bin/gfortran /usr/local/bin/gfortran >> Cheers, >> Simon >>> >>> This looks like a potentially similar thing to do from what I did. Is >>> the effect of this different? If so, how? [Again, please feel free to >>> ignore this question. I'm not eager to practice my "do-it-myself lobotomy" >>> skills ;-] >>> >>> >>> Thanks, >>> Spencer Graves> > On Jul 7, 2023, at 5:58 AM, Spencer Graves > wrote: > > 1. I need to apologize to Simon: I failed to see his reply to the > original post. Then I found the instructions and installed > gfortran-12.2-universal.pkg, as indicated there, but it still didn't work. > > > 2. I'm not finding clear instructions on how to update the path on macOS > 11.7.8, which is the latest version available for my 2014 MacBook Pro > with a 2.8 GHz Quad-Core Intel Core i7. I found several pages with > differing instructions. I found one in "support.apple.com" that > recommended something that didn't work.[2] > > > Further suggestions? > > > Thanks again very much. > Spencer Graves
Re: [R-SIG-Mac] gfortran: command not found
An alternative is not to have gfortran on the path and use a personal Makevars file, as documented at https://cran.r-project.org/doc/manuals/r-devel/R-admin.html#macOS-packages . Reasons to do it that way include a) GCC builds have included other compilers including gcc in the same directory as gfortran, and I have been caught in the past by badly-written software looking for gcc as a C compiler and finding that one rather than Apple's gcc which is a wrapper for clang. (The current gfortran distribution only includes x86_64-apple-darwin20.0-gcc and similar.) b) If the gfortran you have installed differs from that used to build R, you may need to set FLIBS, and this has happened as different CRAN distributions have been built with different versions of gfortran. When I do want gfortran on the path, for example to build other software, I do symlink it to somewhere on my path. I would prefer if Simon continues to give the full path as FC in etc/Makeconf: anyone who wants a different compiler can use a personal Makevars. (Continues at least for arm64, and I would prefer consistency.) On 07/07/2023 00:07, Simon Urbanek wrote: On 7/07/2023, at 10:15 AM, Spencer Graves wrote: Hi, Simon: Thanks for this. I have more questions: On 7/6/23 4:52 PM, Simon Urbanek wrote: In the shell: PATH=/opt/gfortran/bin:$PATH R CMD INSTALL ... Please excuse my ignorance, but I don't understand this. I previously tried "PATH=/bin:/sbin:/user/bin:/user/sbin:/system/Library/ export PATH", recommended on a page associated with support.apple.com, as mentioned below. That did not seem to work for me. That one sets the specified fixed path and then exports it. Setting a fixed PATH by hand is typically a bad idea since it removes all existing entries - and the one you listed didn't even have gfortran on it. Exporting is another alternative if you want to set the PATH for all subsequent commands. The line I sent just prepends the /opt/gfortran/bin to the PATH for the one R CMD command, but doesn't affect anything else. I would recommend reading a basic tutorial on unix shell if you really want to know more (actually a good idea if you ever want to use the Terminal and not kill your machine). How is this different? What did I do wrong before that this would fix? [Or feel free to ignore this question: My immediate problem seems to be fixed, and I'm not eager to do more experimentation with this now ;-] in R if using install.packages() Sys.setenv(PATH=paste0("/opt/gfortran/bin:", Sys.getenv("PATH"))) If I set this in RStudio, will it affect what I do in "Terminal" on my Mac and vice versa? No, it is only valid for the current R session (and I don't know about RStudio - it's not R so sometimes R rules don't apply), that's why I said it's for the case where you run install.packages() in the R session. Note that another alternative is to simply symlink gfortran to your /usr/local/bin since that is on the PATH on macOS by default, i.e., you only need to run this in the Terminal once (requires admin access): sudo ln -sfn /opt/gfortran/bin/gfortran /usr/local/bin/gfortran Cheers, Simon This looks like a potentially similar thing to do from what I did. Is the effect of this different? If so, how? [Again, please feel free to ignore this question. I'm not eager to practice my "do-it-myself lobotomy" skills ;-] Thanks, Spencer Graves> On Jul 7, 2023, at 5:58 AM, Spencer Graves wrote: 1. I need to apologize to Simon: I failed to see his reply to the original post. Then I found the instructions and installed gfortran-12.2-universal.pkg, as indicated there, but it still didn't work. 2. I'm not finding clear instructions on how to update the path on macOS 11.7.8, which is the latest version available for my 2014 MacBook Pro with a 2.8 GHz Quad-Core Intel Core i7. I found several pages with differing instructions. I found one in "support.apple.com" that recommended something that didn't work.[2] Further suggestions? Thanks again very much. Spencer Graves [2] "support.apple.com" recommended "PATH=/bin:/sbin:/user/bin:/user/sbin:/system/Library/ export PATH", then "env". I did "env" to get the current path, than appended ":/opt/gfortran/bin" to that and executed the revised "PATH=...:/opt/gfortran/bin export PATH". However, when I checked with "env" again, the change was not displayed. I rebooted with the same result. https://support.apple.com/guide/terminal/use-environment-variables-apd382cc5fa-4f58-4449-b20a-41c53c006f8f/mac On 7/6/23 11:01 AM, Simon Urbanek wrote: AFACT he didn't say so, there was no response, just double-posting of the same question after is was answered. The installer says: The resulting compiler will live in /opt/gfortran and can be called with /opt/gfortran/bin/gfortran so it's advisable to have