Each time I run pkgload::load_all()
, I get the message below.
> pkgload::load_all()
ℹ Loading my_package
ℹ The packages "dm" and "sf" are required.
✖ Would you like to install them?
1: Yes
2: No
After each restart of RStudio, I need to reinstall "dm" and "sf" using "renv" by inserting 1
in the console. And then "sf" will be installed from source.
How could I solve this?
I ran devtools::install_dev_deps()
. Now I only have the message, but nothing will be installed if I choose the option 1: Yes.
> pkgload::load_all()
ℹ Loading my_package
ℹ The packages "dm" and "sf" are required.
✖ Would you like to install them?
1: Yes
2: No
Selection: 1
>
> devtools::load_all()
ℹ Loading my_package
ℹ The packages "dm" and "sf" are required.
✖ Would you like to install them?
1: Yes
2: No
Selection: 1
> renv::restore()
* The library is already synchronized with the lockfile.
> renv::install('dm')
Installing dm [1.0.4] ...
OK [linked cache]
> devtools::load_all()
ℹ Loading my_package
ℹ The packages "dm" and "sf" are required.
✖ Would you like to install them?
1: Yes
2: No
Selection: 1
>
I get the following error when I load the dm or sf packages:
> library(dm)
Error: package or namespace load failed for ‘dm’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/user_name/Library/Application Support/renv/cache/v5/R-4.3/x86_64-apple-darwin20/igraph/1.4.1/a7ef0d811cb66d8be9da0d7b5ab80ded/igraph/libs/igraph.so':
dlopen(/Users/user_name/Library/Application Support/renv/cache/v5/R-4.3/x86_64-apple-darwin20/igraph/1.4.1/a7ef0d811cb66d8be9da0d7b5ab80ded/igraph/libs/igraph.so, 0x0006): Library not loaded: /osxcross/bin/../x86_64-apple-darwin22/lib/libgfortran.5.dylib
Reason: tried: '/osxcross/bin/../x86_64-apple-darwin22/lib/libgfortran.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/osxcross/bin/../x86_64-apple-darwin22/lib/libgfortran.5.dylib' (no such file), '/osxcross/bin/../x86_64-
> library(sf)
Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/user_name/Library/Application Support/renv/cache/v5/R-4.3/x86_64-apple-darwin20/KernSmooth/2.23-20/8dcfa99b14c296bc9f1fd64d52fd3ce7/KernSmooth/libs/KernSmooth.so':
dlopen(/Users/user_name/Library/Application Support/renv/cache/v5/R-4.3/x86_64-apple-darwin20/KernSmooth/2.23-20/8dcfa99b14c296bc9f1fd64d52fd3ce7/KernSmooth/libs/KernSmooth.so, 0x0006): Library not loaded: /osxcross/bin/../x86_64-apple-darwin22/lib/libgfortran.5.dylib
Reason: tried: '/osxcross/bin/../x86_64-apple-darwin22/lib/libgfortran.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/osxcross/bin/../x86_64-apple-darwin22/lib/libgfortran.5.dylib'
I had to deal with the error messages returned by library(dm)
and library(sf)
.
Here is the process of how I solved the problem. I needed to create a symbolic link for libgfortran.5.dylib
and libquadmath.0.dylib
in /usr/local/lib/
(see https://www.kombitz.com/2022/07/28/error-message-usr-local-lib-libgfortran-3-dylib-no-such-file-on-intel-mac-solved/).
# Solution for dm ----
devtools::install_github("igraph/rigraph")
renv::install("cynkra/dm")
devtools::load_all()
# After that, I only get
> devtools::load_all()
* The project may be out of sync -- use `renv::status()` for more details.
ℹ Loading my_package
ℹ The package "sf" is required.
✖ Would you like to install it?
1: Yes
2: No
# For sf ----
brew install pkg-config
brew install gdal
install.packages("rgdal", type = "source", configure.args = c("--with-proj-lib=$(brew --prefix)/lib/", "--with-proj-include=$(brew --prefix)/include/"))
# https://github.com/fxcoudert/gfortran-for-macOS/releases
# https://brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gcc
# cf. https://www.kombitz.com/2022/07/28/error-message-usr-local-lib-libgfortran-3-dylib-no-such-file-on-intel-mac-solved/
sudo ln -s /usr/local/Cellar/gcc/13.1.0/lib/gcc/13/libgfortran.5.dylib /usr/local/lib/libgfortran.5.dylib
install.packages("rgdal", type = "source", configure.args = c("--with-proj-lib=$(brew --prefix)/lib/", "--with-proj-include=$(brew --prefix)/include/"))
renv::install("rgdal", type = "source", configure.args = c("--with-proj-lib=$(brew --prefix)/lib/", "--with-proj-include=$(brew --prefix)/include/"))
# next error
# libquadmath.0.dylib' (no such file)
# sudo find / -name libquadmath.0.dylib
# Password:
#/usr/local/gfortran/lib/i386/libquadmath.0.dylib
# /usr/local/gfortran/lib/libquadmath.0.dylib
# /usr/local/Cellar/gcc/13.1.0/lib/gcc/current/libquadmath.0.dylib
# /usr/local/Cellar/gcc/13.1.0/lib/gcc/13/libquadmath.0.dylib
sudo ln -s /usr/local/Cellar/gcc/13.1.0/lib/gcc/13/libquadmath.0.dylib /usr/local/lib/libquadmath.0.dylib
Restarting R session...
devtools::load_all()
> pkgload::load_all()
ℹ Loading my_package