Hi
I downloaded R and Rstudio last week using homebrew. I am able to install some packages, but when I try
install.packages("faraway")
I get the following
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘minqa’, ‘lme4’
trying URL 'https://cran.rstudio.com/src/contrib/minqa_1.2.4.tar.gz'
Content type 'application/x-gzip' length 53548 bytes (52 KB)
==================================================
downloaded 52 KB
trying URL 'https://cran.rstudio.com/src/contrib/lme4_1.1-27.1.tar.gz'
Content type 'application/x-gzip' length 3311365 bytes (3.2 MB)
==================================================
downloaded 3.2 MB
trying URL 'https://cran.rstudio.com/src/contrib/faraway_1.0.7.tar.gz'
Content type 'application/x-gzip' length 450183 bytes (439 KB)
==================================================
downloaded 439 KB
* installing *source* package ‘minqa’ ...
** package ‘minqa’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran -fno-optimize-sibling-calls -fPIC -g -O2 -c altmov.f -o altmov.o
make: gfortran: No such file or directory
make: *** [altmov.o] Error 1
ERROR: compilation failed for package ‘minqa’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/minqa’
Warning in install.packages :
installation of package ‘minqa’ had non-zero exit status
ERROR: dependency ‘minqa’ is not available for package ‘lme4’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/lme4’
Warning in install.packages :
installation of package ‘lme4’ had non-zero exit status
ERROR: dependency ‘lme4’ is not available for package ‘faraway’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/faraway’
Warning in install.packages :
installation of package ‘faraway’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/wp/g4z3sz4d2tvd5sx0s5r796xw0000gn/T/Rtmp5Oew8O/downloaded_packages’
I tried to install "minqa" separately as it appear to be the root of the problem, but then I got a similar error. The packages are stored as zip files in the folder shown in the last line of the R output. I would like to have the packages installed as expected in the correct folder and have the problem eradicated. Is a short-term workaround to move the zip files to the correct folder and open them there, or can this be "dangerous" in some way?
> R.version
_
platform aarch64-apple-darwin20.6.0
arch aarch64
os darwin20.6.0
system aarch64, darwin20.6.0
status
major 4
minor 1.2
year 2021
month 11
day 01
svn rev 81115
language R
version.string R version 4.1.2 (2021-11-01)
nickname Bird Hippie
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20.6.0 (64-bit)
Running under: macOS Monterey 12.0.1
Matrix products: default
LAPACK: /opt/homebrew/Cellar/r/4.1.2/lib/R/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tree_1.0-41
loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2
the compilation fails because gfortran system utility is absent, as a homebrew user I believe you can
brew install gcc
then go back to R and try installing minqa again
Thank you! I tried doing what you said, but quickly found this:
(gfortran support for R on macOS - cynkra)
explaining how there is an issue with gfortran for mac, but also indicate that there is not a proper solution actually
Do you know of a proper solution to the problem?
Thanks
Thanks again!
I am out on thin ice talking about this stuff so could you please explain what are binaries and what is "the other thing"?
How do I download these? Is there a way of downloading them using R or the terminal, making it efficient?
I'm not a mac user so I can only advise you so far and can't test anything out...
Here is the FAQ R for macOS FAQ (r-project.org)
on the other hand this suggests that
Unlike on other Unix systems, CRAN R for macOS installs binary packages by default
so not sure why you are getting source by default on your machine. I believe install.packages can accept "mac.binary" as an input for its type parameter
Thank you yet again!
Passing "mac.binary" to the type worked for loading the packages, but when I run
> library("faraway")
I get
Error: package or namespace load failed for ‘faraway’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/homebrew/lib/R/4.1/site-library/minqa/libs/minqa.so':
dlopen(/opt/homebrew/lib/R/4.1/site-library/minqa/libs/minqa.so, 0x0006): tried: '/opt/homebrew/lib/R/4.1/site-library/minqa/libs/minqa.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/minqa.so' (no such file)
So for me, it appears like things have been loaded, but that homebrew can't utilise the binary file or something?
It appears to be an issue with how the Monterey OS reads binary files because in the errors it says:
> mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/minqa.so' (no such file)
so I might need to turn the package into 'arm64e' or change the reading of the file to 'x86_64', but on that part, I am completely lost.
Do you understand what is wrong and how to fix it?
Thanks a lot.
Actually, after updating R and Rstudio, I copy the whole R4.1 library to the R4.3 library.
And now I cannot load any packages, for example:
library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/glue/libs/glue.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/glue/libs/glue.so, 0x0006): tried: '/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/glue/libs/glue.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
A gentle man suggests me that I reinstall my R and R studio because of the Mac M1 reasons. I am doing the back-ups and plan to reinstall. Is there any other advice?
You cannot do that, packages installed for R version 4.1.x will often not work at all for R 4.3.x, even if they are the same architecture.
From your error it also seems that you are mixing architectures and you are trying to use packages installed in x86_64 R in arm64 R.
RStudio has nothing to do with this, so reinstalling it will not help. Reinstalling R will also not help, because the issue is with the packages and not R itself.
What you could do is remove the packages from your user library if you have a separate library, and then install them with the R version that you really want to use.