harrelfe / Hmisc

Harrell Miscellaneous
Other
204 stars 81 forks source link

Hmisc Package unable to install on M1 Mac #145

Open jz-stat opened 2 years ago

jz-stat commented 2 years ago

Please advise how to fix this or let me know if you need any other info. Thanks!

> install.packages("Hmisc")

  There is a binary version available but the source version is later:
      binary source needs_compilation
Hmisc  4.5-0  4.6-0              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘Hmisc’

trying URL 'https://cran.rstudio.com/src/contrib/Hmisc_4.6-0.tar.gz'
Content type 'application/x-gzip' length 784633 bytes (766 KB)
==================================================
downloaded 766 KB

* installing *source* package ‘Hmisc’ ...
** package ‘Hmisc’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c Hmisc.c -o Hmisc.o
/opt/R/arm64/bin/gfortran -mtune=native -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c cidxcn.f -o cidxcn.o
make: /opt/R/arm64/bin/gfortran: No such file or directory
make: *** [cidxcn.o] Error 1
ERROR: compilation failed for package ‘Hmisc’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Hmisc’
Warning in install.packages :
  installation of package ‘Hmisc’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/j3/bmhzpkjx5s9chbrjt7wf0rlm0000gn/T/RtmpZPTRpj/downloaded_packages’
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/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     

loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1   
couthcommander commented 2 years ago

The easiest solution is to install again, and answer "no" to install from source. This will install the binary version of Hmisc for macOS, which is indeed an older version. If you need the newest version of Hmisc, you will have to compile it (which is what happens when you answer "yes"). In order to compile R packages, you will likely need gcc and gfortran. For reference, see https://mac.r-project.org/tools/.

gcc

You can install the Command Line Tools package by running the xcode-select --install command. (https://developer.apple.com/library/archive/technotes/tn2339/_index.html)

gfortran

This needs to be downloaded and installed - you can probably use https://mac.r-project.org/tools/gfortran-8.2-Mojave.dmg

dalewsteele commented 2 years ago

I was able to compile on M1 mac after following the directions for Apple silicon Macs at: to unpack the tarball below. https://mac.r-project.org/tools/gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz

Eku1009 commented 2 years ago

La solution la plus simple consiste à réinstaller et à répondre "non" pour installer à partir des sources. Cela installera la version binaire de Hmisc pour macOS, qui est en effet une version plus ancienne. Si vous avez besoin de la dernière version de Hmisc, vous devrez la compiler (c'est ce qui se passe lorsque vous répondez "oui"). Pour compiler les packages R, vous aurez probablement besoin de gcc et de gfortran. Pour référence, voir https://mac.r-project.org/tools/ .

gcc

Vous pouvez installer le package Outils de ligne de commande en exécutant la xcode-select --installcommande. ( https://developer.apple.com/library/archive/technotes/tn2339/_index.html )

gfortran

Cela doit être téléchargé et installé - vous pouvez probablement utiliser https://mac.r-project.org/tools/gfortran-8.2-Mojave.dmg

Thanks! it worked for me