Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load packages #243

Closed
psobolewskiPhD opened this issue Jan 2, 2021 · 13 comments
Closed

Unable to load packages #243

psobolewskiPhD opened this issue Jan 2, 2021 · 13 comments

Comments

@psobolewskiPhD
Copy link

I'm on Apple Silicon M1, Big Sur 11.1.
Native R is installed via homebrew.
radian was installed using the default (native) python3 & pip3, but I needed to set:
PYTHONDONTWRITEBYTECODE=1
and install with --user

Radian runs fine and looks great, but I can't seem to load any libraries, which load just fine in default R.

.libPath() is the same for both and R was compiled with --enable-R-shlib.
Below is the error.

r$> library(tidyverse)                                                          
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so':
  dlopen(/opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so, 6): Library not loaded: /opt/homebrew/opt/r/lib/R/lib/libR.dylib
  Referenced from: /opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so
  Reason: image not found
@randy3k
Copy link
Owner

randy3k commented Jan 2, 2021

what is the value of R.home() in R? could you also report radian --version

@psobolewskiPhD
Copy link
Author

r$> R.home()                                                                    
[1] "/opt/homebrew/lib/R"

radian version: 0.5.9
r executable: /opt/homebrew/lib/R/bin/R
r version: WARNING: ignoring environment value of R_HOME
4.0.3
python executable: /Library/Developer/CommandLineTools/usr/bin/python3
python version: 3.8.2

@randy3k
Copy link
Owner

randy3k commented Jan 2, 2021

I guess there may be multiple copies of R in your system and they are not compatible. Could you check what libraries is vctrs.so linking to? Something like,

otool -l /opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so

@psobolewskiPhD
Copy link
Author

I did go through a lot of different R compiles, playing around with BLAS libraries.
But, at the moment should just have only one R install.
otool output is really long
otool-vctrs-out.txt
I think these are the libraries:
name /opt/homebrew/opt/r/lib/R/lib/libR.dylib (offset 24)
name /opt/homebrew/opt/gettext/lib/libintl.8.dylib (offset 24)
name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24)
name /usr/lib/libSystem.B.dylib (offset 24)

@psobolewskiPhD
Copy link
Author

For what it's worth, different packages error on different .so files. Here's ggplot2:

r$> library(ggplot2)                                                            
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/homebrew/lib/R/4.0/site-library/colorspace/libs/colorspace.so':
  dlopen(/opt/homebrew/lib/R/4.0/site-library/colorspace/libs/colorspace.so, 6): Library not loaded: /opt/homebrew/opt/r/lib/R/lib/libR.dylib
  Referenced from: /opt/homebrew/lib/R/4.0/site-library/colorspace/libs/colorspace.so
  Reason: image not found

and here is .libPaths()

r$> .libPaths()                                                                 
[1] "/opt/homebrew/lib/R/4.0/site-library"
[2] "/opt/homebrew/lib/R/library"         

and colorspace.so (likewise vctrs.so) are actually located in those locations...

@randy3k
Copy link
Owner

randy3k commented Jan 2, 2021

I beleive the error is actually from loading /opt/homebrew/opt/r/lib/R/lib/libR.dylib.
Did you specify R_HOME manually? The warning WARNING: ignoring environment value of R_HOME is bugging me.

@psobolewskiPhD
Copy link
Author

Honestly, I'm not sure?
I may have set it manually while trying to get VS Code to work?
I tried unsetting it:

>./radian --version  
radian version: 0.5.9
r executable: /opt/homebrew/Cellar/r-blas/4.0.3_1/lib/R/bin/R
r version: 4.0.3
python executable: /Library/Developer/CommandLineTools/usr/bin/python3
python version: 3.8.2

Alas, same error:

r$> library(tidyverse)                                                          
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so':
  dlopen(/opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so, 6): Library not loaded: /opt/homebrew/opt/r/lib/R/lib/libR.dylib
  Referenced from: /opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so
  Reason: image not found

Wait, I see what you mean.
/opt/homebrew/opt/r/lib/R/lib/libR.dylib
Is wrong, it should be:
/opt/homebrew/lib/R/lib/libR.dylib

I guess I need to try to reinstall?
Odd that it works in regular R...

@psobolewskiPhD
Copy link
Author

Ah! More clarity. I'm using a custom brew formula, named r-blas.
I had the regular R formula, but switched.
/opt/homebrew/opt/ doesn't have a R dir (symlink), instead it has R-blas
I'll try duplicating the symlink...

@randy3k
Copy link
Owner

randy3k commented Jan 2, 2021

my bad, it should be

otool -L /opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so

could you try again?

Does the file /opt/homebrew/opt/r/lib/R/lib/libR.dylib exist at all?

The error is raised when vctrs.so loads libR.dylib and for some reason, it cannot be loaded.

@psobolewskiPhD
Copy link
Author

Success!

r$> library(tidyverse)                                                          
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.2     ✔ purrr   0.3.4
✔ tibble  3.0.4     ✔ dplyr   1.0.2
✔ tidyr   1.1.2     ✔ stringr 1.4.0
✔ readr   1.4.0     ✔ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()


@psobolewskiPhD
Copy link
Author

For
otool -L /opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so
I get

/opt/homebrew/lib/R/4.0/site-library/vctrs/libs/vctrs.so:
	vctrs.so (compatibility version 0.0.0, current version 0.0.0)
	/opt/homebrew/opt/r/lib/R/lib/libR.dylib (compatibility version 4.0.0, current version 4.0.3)
	/opt/homebrew/opt/gettext/lib/libintl.8.dylib (compatibility version 11.0.0, current version 11.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

@randy3k
Copy link
Owner

randy3k commented Jan 2, 2021

I'm glad that you figure it out. Homebrew has a mechanism to fix this rpath issue for the official R formula, I guess your custom formula didn't fix it.

Success!

r$> library(tidyverse)                                                          
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.2     ✔ purrr   0.3.4
✔ tibble  3.0.4     ✔ dplyr   1.0.2
✔ tidyr   1.1.2     ✔ stringr 1.4.0
✔ readr   1.4.0     ✔ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()

@psobolewskiPhD
Copy link
Author

Thank you for your time and patience.
If there is anything you'd like tested on Apple Silicon M1 MacOS Big Sur, please let me know.
Now I get to play with configuration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants