0

I did have R up and running perfectly on my Conda env up until a few days ago when I messed around with the packages and had to delete the environment. Now that I am trying to recreate my environment things aren't just working anymore.

Things to know:

OS: MacOS BigSur

Conda environment contains: Python 3.8 and R 3.6.1

> version
               _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          6.1                         
year           2019                        
month          07                          
day            05                          
svn rev        76782                       
language       R                           
version.string R version 3.6.1 (2019-07-05)
nickname       Action of the Toes   

which R command shows path to be thegeorgejoseph/anaconda/envs/protonaml/bin/R

the .libPaths() shows it to be thegeorgejoseph/anaconda/envs/protonaml/lib/R/library

Why are they different? could it be the cause of the problem?

When I try to install rattle, it runs a couple of times are then fails saying tibble, rlang and a couple of other packages couldn't be installed. When I run the install.packages(rlang) command on R I get the following traceback. Any help is appreciated, what could be going wrong?

 install.packages('rlang')
trying URL 'https://cloud.r-project.org/src/contrib/rlang_0.4.10.tar.gz'
Content type 'application/x-gzip' length 915685 bytes (894 KB)
==================================================
downloaded 894 KB

* installing *source* package ‘rlang’ ...
** package ‘rlang’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
x86_64-apple-darwin13.4.0-clang -I"/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/include" -DNDEBUG -I./lib/  -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9  -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include  -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include -fdebug-prefix-map=/opt/concourse/worker/volumes/live/59b7f007-fada-42cf-7435-5bbd0518eaa4/volume/r-base_1570124919999/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml=/usr/local/src/conda-prefix  -c capture.c -o capture.o
x86_64-apple-darwin13.4.0-clang -I"/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/include" -DNDEBUG -I./lib/  -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9  -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include  -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include -fdebug-prefix-map=/opt/concourse/worker/volumes/live/59b7f007-fada-42cf-7435-5bbd0518eaa4/volume/r-base_1570124919999/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml=/usr/local/src/conda-prefix  -c export.c -o export.o
x86_64-apple-darwin13.4.0-clang -I"/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/include" -DNDEBUG -I./lib/  -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9  -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include  -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include -fdebug-prefix-map=/opt/concourse/worker/volumes/live/59b7f007-fada-42cf-7435-5bbd0518eaa4/volume/r-base_1570124919999/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml=/usr/local/src/conda-prefix  -c internal.c -o internal.o
x86_64-apple-darwin13.4.0-clang -I"/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/include" -DNDEBUG -I./lib/  -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9  -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include  -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include -fdebug-prefix-map=/opt/concourse/worker/volumes/live/59b7f007-fada-42cf-7435-5bbd0518eaa4/volume/r-base_1570124919999/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml=/usr/local/src/conda-prefix  -c lib.c -o lib.o
x86_64-apple-darwin13.4.0-clang -I"/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/include" -DNDEBUG -I./lib/  -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9  -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include  -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/include -fdebug-prefix-map=/opt/concourse/worker/volumes/live/59b7f007-fada-42cf-7435-5bbd0518eaa4/volume/r-base_1570124919999/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml=/usr/local/src/conda-prefix  -c version.c -o version.o
x86_64-apple-darwin13.4.0-clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/lib -Wl,-dead_strip_dylibs -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib -L/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib -o rlang.dylib capture.o export.o internal.o lib.o version.o -L/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/lib -lR -Wl,-framework -Wl,CoreFoundation
ld: warning: -pie being ignored. It is only used when linking a main executable
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd' for architecture x86_64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/share/make/shlib.mk:6: rlang.dylib] Error 1
ERROR: compilation failed for package ‘rlang’
* removing ‘/Users/thegeorgejoseph/opt/anaconda3/envs/protonaml/lib/R/library/rlang’

PS: I also tried installing Rstudio onto the environment but I was getting the same error using the install.packages() command. However, on creating a new environment and installing every package that I require using R channels from Anaconda the installation is successful and doesn't throw any errors but I still am unable to load the libraries in the script using library(rattle).

serotonin
  • 33
  • 5
  • 1
    Don't install Rstudio through Conda - there are only old versions, plus you don't want to install a huge IDE in every environment. Install RStudio on the system or user level and [launch it with the environment activated](https://stackoverflow.com/a/62737170/570918). – merv Mar 05 '21 at 23:45

1 Answers1

1

There is no problem with the which R and .libPaths() - that is exactly what they should be, with the former pointing to the binary and the latter pointing to where R packages are installed.

As for the error, one should prefer to use conda install rather than R's install.packages to manage packages when using R from a Conda environment. Otherwise, dynamic library linking can be problematic. In this case, try

conda install -n protonaml -c conda-forge r-rattle

This is less of an issue for non-compiled R packages, analogous to how using pip in a Conda environment is usually fine for pure Python packages. Nevertheless, I would generally recommend sticking to conda install to avoid these issues. Note that the conda-forge channel has many CRAN packages.

merv
  • 67,214
  • 13
  • 180
  • 245
  • I have mentioned as a P.S in the post how installing packages using `conda install rattle` allows me to download the packages, however, I still am unable to load them into an rscript using `library(rattle)` – serotonin Mar 07 '21 at 09:18
  • 1
    @serotonin how are you running the Rscript? From the activated environment, or using `conda run`, or something else? – merv Mar 07 '21 at 22:04
  • 1
    yes, I activate the environment using `conda activate protonaml` and then I execute the command `R` to bring up the interpreter & see if I can import the libraries using `library(rattle)` command in the terminal – serotonin Mar 09 '21 at 12:08
  • @serotonin what error does it give when then doing `library(rattle)`? e.g., package not found or something about dylibs? – merv Mar 09 '21 at 17:56
  • `Error in library(rattle) : there is no package called ‘rattle’` – serotonin Mar 10 '21 at 18:10