zhanghao-njmu / SCP

An end-to-end Single-Cell Pipeline designed to facilitate comprehensive analysis and exploration of single-cell data.
https://zhanghao-njmu.github.io/SCP/
GNU General Public License v3.0
351 stars 79 forks source link

Cannot install package on Mac M1 for v0.5.1 #163

Closed Streisenberg closed 11 months ago

Streisenberg commented 11 months ago

Dear Hao,

Thank you for this amazing tool again.

I've been trying to install the latest version of the package since its release. However, I consistently encounter the following error:

✔  checking for file ‘/private/var/folders/nb/f7r_tjtx3nsbg1tlnpfbzsmcndrz1b/T/RtmpyWDVBF/remotes3fe55d377b13/zhanghao-njmu-SCP-458ce17/DESCRIPTION’ ...
─  preparing ‘SCP’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘SCP_0.5.1.tar.gz’
   Warning: invalid uid value replaced by that for user 'nobody'
   Warning: invalid gid value replaced by that for user 'nobody'

* installing *source* package ‘SCP’ ...
** using staged installation
** libs
using C++ compiler: ‘g++ (GCC) 12.1.0’
using SDK: ‘’
/usr/local/gfortran/bin/g++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -stdlib=libc++ -c RcppExports.cpp -o RcppExports.o
g++: error: unrecognized command-line option ‘-stdlib=libc++’
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘SCP’
* removing ‘/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/SCP’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/nb/f7r_tjtx3nsbg1tlnpfbzsmcndrz1b/T//RtmpyWDVBF/file3fe565714c34/SCP_0.5.1.tar.gz’ had non-zero exit status

Machine info: Platform : aarch64-apple-darwin20 R.version : 4.3.1 RStudio.Version : 2023.6.0.421 MacOS : Monterey (12.6.5) Chip : Apple M1 Max

To troubleshoot the issue, I have:

  1. Manually installed dependencies like "RcppArmadillo", "Rcpp", etc.
  2. Reinstalled Xcode command line tools
  3. Removed and reinstalled both Anaconda and Miniconda for M1 chip
  4. Reinstalled "gfortran"
  5. Deleted the "Makevars" file to use the default settings.

Despite these efforts, the problem persists. Any assistance or guidance on resolving this issue would be greatly appreciated.

Thank you!

zhanghao-njmu commented 11 months ago

Hi, I am not sure how to solve the problem.

However, I have successfully install SCP 0.5.1 on the Mac Studio, with some variations in the software:

Chip : Apple M1 Max MacOS : Monterey (12.6.5) Kernel Version: Darwin Kernel Version 22.6.0 GCC version: Apple clang version 14.0.3 (clang-1403.0.22.14.1) SDK: MacOSX13.3.sdk

Here are the installation messages for SCP:

── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/private/var/folders/h9/w5r4hfpj3vz5l3dp3gncdy2w0000gn/T/RtmpHUgUDw/remotes4ce3da4f414/zhanghao-njmu-SCP-458ce17/DESCRIPTION’ ...
─  preparing ‘SCP’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘SCP_0.5.1.tar.gz’

* installing *source* package ‘SCP’ ...
** using staged installation
** libs
using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using SDK: ‘MacOSX13.3.sdk’
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -arch x86_64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c asMatrix.cpp -o asMatrix.o
clang++ -arch x86_64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o SCP.so RcppExports.o asMatrix.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/00LOCK-SCP/00new/SCP/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (SCP)

I hope this information is helpful to you.

Streisenberg commented 11 months ago

Hi Hao,

Thank you for your prompt reply.

Resolving the issue took some effort, but I wanted to document the solution here in case anyone else encounters the same problem.

Note: Before following the steps below, try downloading the package using R in your terminal. Sometimes the issue may originate from RStudio. In my case, even after following the solution provided, I still couldn't download the package through RStudio. However, the method outlined below allowed me to download it via the terminal.

1. Initially, to start fresh, I deleted Xcode and CommandLineTools. To do this, navigate to the Applications folder and drag the Xcode app to the Trash bin. 2. Next, to identify the latest Xcode version compatible with my macOS model (macOS Monterey v12.6.5), I checked here to learn information about releases. I downloaded the latest update for me, Xcode 14.2, from Apple’s developer site. I also downloaded CommandLineTools for version 14.2. 3. I then moved the downloaded application to the /Applications folder because having it in the /Downloads folder can lead to various issues. 4. To reinstall, I completely removed gfortran with the following commands:

sudo rm -r /usr/local/gfortran /usr/local/bin/gfortran
sudo pkgutil --forget com.gnu.gfortran

5. I downloaded the gfortran version compatible with my macOS from here. 6. I modified the ~/.R/Makevars file as follows:

LOC=/usr/local/gfortran
CC=$(LOC)/bin/gcc -fopenmp
CXX=$(LOC)/bin/g++ -fopenmp
CXX11 = $(LOC)/bin/g++ -fopenmp

CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L$(LOC)/lib -Wl,-rpath,$(LOC)/lib,-L/usr/local/lib
CPPFLAGS=-I$(LOC)/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/local/include

FLIBS=-L/usr/local/gfortran/lib/gcc/aarch64-apple-darwin21/12.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX1X=/usr/local/gfortran/bin/g++
CXX98=/usr/local/gfortran/bin/g++
CXX11=/usr/local/gfortran/bin/g++
CXX14=/usr/local/gfortran/bin/g++
CXX17=/usr/local/gfortran/bin/g++

7. I removed the llvm package with the command:

brew remove llvm

8. I uninstalled RStudio and then reinstalled it using homebrew:

brew install --cask rstudio

9. Despite all these efforts, I couldn't install the package through the RStudio interface. Instead, I was able to install the package from the R environment within the terminal.

Thank you once again!

zhanghao-njmu commented 11 months ago

Thank you for providing such valuable information! Indeed, RStudio loads many components upon startup, which can potentially cause installation failures. I will include a suggestion to install them in the R console.