joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
325 stars 102 forks source link

ERROR: package or namespace load failed for 'TTR' in dyn.load(file, DLLpath = DLLpath, ...): #115

Closed naanunaane closed 3 years ago

naanunaane commented 3 years ago

Description

Trying to run an R script in a docker container that utilizes the TTR package. While installation of the package happens without any issues, the runtime faces an issue while loading the library.

I'm using multi-stage docker build where I am installing the R packages in the first base stage, copy the /usr/local/ path from the first stage to the final stage where I then re-install some dependencies like --

libreadline-dev gcc-7 g++-7 gfortran-7 libicu60 libhiredis-dev libcurl4-openssl-dev

This was done as some of the packages were having issues with these system dependencies. The error log I see is

Error: package or namespace load failed for 'TTR' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/library/curl/libs/curl.so':
  libcurl.so.4: cannot open shared object file: No such file or directory
Execution halted

However, by using dive, I check the file structure inside the docker image. I see that the /usr/local/lib/R/library/curl/libs/curl.so actually does exist.

Screenshot from 2021-06-21 17-23-19

You can see from the screenshot above that the curl.so file exists (see right side file structure).

Why is it not able to load the file?

Expected behavior

Running library(TTR) shouldn't have caused any issues in the R session.

Session Info

Running in Docker.

The first few lines of the logs include:

[1] "In Setup"
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Attaching package: 'dplyr'

The following objects are masked from 'package:xts':

    first, last

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Error: package or namespace load failed for 'TTR' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/library/curl/libs/curl.so':
  libcurl.so.4: cannot open shared object file: No such file or directory
Execution halted
joshuaulrich commented 3 years ago

It can't load curl.so because it can't find libcurl.so.4

unable to load shared object '/usr/local/lib/R/library/curl/libs/curl.so': libcurl.so.4: cannot open shared object file: No such file or directory

You have the header files (*-dev), but do you have the actual library installed too? For example, here's what I have installed on my Ubuntu laptop:

$ dpkg -S libcurl.so
libcurl4:amd64: /usr/lib/x86_64-linux-gnu/libcurl.so.4.6.0
libcurl4-openssl-dev:amd64: /usr/lib/x86_64-linux-gnu/libcurl.so
libcurl4:amd64: /usr/lib/x86_64-linux-gnu/libcurl.so.4

I'm closing this because it's highly unlikely this is an issue specific to TTR. But I'm happy to help troubleshoot, if I can.