简体   繁体   中英

Can't install any R packages anymore

I use for biological data analysis. I'm on a Mac OS Catalina 10.15.4 . I recently updated R to version 3.6.3 because I thought that would solve my inability to install a particular package: DESeq2 . Huge mistake - amongst the many I've probably made in trying to troubleshoot without really understanding what the problem is. I'm not able to install ANY packages now. I had updated my Clang version when I went down the rabbit hole of potential solutions on the internet. I was going to upgrade too, but I want to understand what the problem is really before I blindly try more.

Now I've downgraded to R 3.5.3 (I'd like to stick to this R version).

Qst: Using R 3.5.3, how do I successfully install packages from CRAN again? And also from Bioconductor like the DESeq2 package?

Error warning below:

install.packages("readr")
 Warning in install.packages : unable to access index for repository http://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5: cannot open URL 'http://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/PACKAGES' Package which is only available in source form, and may need compilation of C/C++/Fortran: 'readr' Do you want to attempt to install these from sources? (Yes/no/cancel) y installing the source package 'readr' trying URL 'http://cran.rstudio.com/src/contrib/readr_1.3.1.tar.gz' Content type 'application/x-gzip' length 268853 bytes (262 KB) ================================================== downloaded 262 KB * installing *source* package 'readr' ... ** package 'readr' successfully unpacked and MD5 sums checked ** libs clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I. -Ircon -fPIC -Wall -g -O2 -c Collector.cpp -o Collector.o clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I. -Ircon -fPIC -Wall -g -O2 -c CollectorGuess.cpp -o CollectorGuess.o clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I. -Ircon -fPIC -Wall -g -O2 -c Iconv.cpp -o Iconv.o clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I. -Ircon -fPIC -Wall -g -O2 -c LocaleInfo.cpp -o LocaleInfo.o clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I. -Ircon -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -I. -Ircon -fPIC -Wall -g -O2 -c Reader.cpp -o Reader.o In file included from Reader.cpp:1: In file included from ./Reader.h:3: In file included from ./Collector.h:5: In file included from ./DateTimeParser.h:6: In file included from ./QiParsers.h:4: In file included from ./boost.h:6: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/interprocess/file_mapping.hpp:15: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config.hpp:57: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/platform/macos.hpp:28: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:655: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/gethostuuid.h:39:17: error: unknown type name 'uuid_t' int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA); ^ In file included from Reader.cpp:1: In file included from ./Reader.h:3: In file included from ./Collector.h:5: In file included from ./DateTimeParser.h:6: In file included from ./QiParsers.h:4: In file included from ./boost.h:6: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/interprocess/file_mapping.hpp:15: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config.hpp:57: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/platform/macos.hpp:28: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:662:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'? int getsgroups_np(int *, uuid_t); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here typedef __darwin_uid_t uid_t; ^ In file included from Reader.cpp:1: In file included from ./Reader.h:3: In file included from ./Collector.h:5: In file included from ./DateTimeParser.h:6: In file included from ./QiParsers.h:4: In file included from ./boost.h:6: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/interprocess/file_mapping.hpp:15: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config.hpp:57: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/platform/macos.hpp:28: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:664:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'? int getwgroups_np(int *, uuid_t); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here typedef __darwin_uid_t uid_t; ^ In file included from Reader.cpp:1: In file included from ./Reader.h:3: In file included from ./Collector.h:5: In file included from ./DateTimeParser.h:6: In file included from ./QiParsers.h:4: In file included from ./boost.h:6: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/interprocess/file_mapping.hpp:15: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config.hpp:57: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/platform/macos.hpp:28: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:727:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'? int setsgroups_np(int, const uuid_t); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here typedef __darwin_uid_t uid_t; ^ In file included from Reader.cpp:1: In file included from ./Reader.h:3: In file included from ./Collector.h:5: In file included from ./DateTimeParser.h:6: In file included from ./QiParsers.h:4: In file included from ./boost.h:6: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/interprocess/file_mapping.hpp:15: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config.hpp:57: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/platform/macos.hpp:28: In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:729:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'? int setwgroups_np(int, const uuid_t); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here typedef __darwin_uid_t uid_t; ^ 5 errors generated. make: *** [Reader.o] Error 1 ERROR: compilation failed for package 'readr' * removing '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/readr' Warning in install.packages : installation of package 'readr' had non-zero exit status The downloaded source packages are in '/private/var/folders/49/18qlr0bn7xg_mk2pzxvrb0f80000gn/T/RtmpN5hCja/downloaded_packages'

Appreciate your help.

I've had the same problem on my Mac! I'm running Mojave. It appears there has been an issue with CRAN recently. Add the following repo argument has worked for me:

install.packages("readr", repo = 'https://mac.R-project.org')

More info: https://community.rstudio.com/t/i-can-t-install-packages-on-r-studio-non-zero-exit-status/52135

I think the problem is the type uuid_t is not defined at anywhere. So the declaration at line 662 in the file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h will cause error for example.

In the first attempt, I tried to add one line into that unistd.h file: #include at line 83 . But it doesn't help.

Because I don't want to go deeper to edit many system file, I add another line into unistd.h to manually define the type of uuid_t, based on the definition in _uuid_t.h. typedef __darwin_uuid_t uuid_t; at line 661 , after "#endif" .

Then it worked.

I am not sure if this is an error in the source code of MacOSX.10.15.sdk or not. But if you want to fix it in this way, please make sure you have the root permission when editing those files.

I relied on these 2 posts to solve my issue:

https://www.nistara.net/post/compile-issues-r/

https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

Thanks to the Coatless Professor and Nistara Randhawa

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM