jeroenjanssens / data-science-at-the-command-line

Data Science at the Command Line
https://datascienceatthecommandline.com
Other
3.77k stars 766 forks source link

R_HOME not found in Docker container #117

Open yonicd opened 3 years ago

yonicd commented 3 years ago

Thanks for writing this book, it is very enjoyable to read and learn from it.

In chapter 5 where rush is introduced I am trying to run the examples to create figure 5.1 and am getting an error

$rush plot -x value -y count --geom col --height 2 fb.csv > fb.png
ERROR: R_HOME ('/usr/lib/R') not found

after figuring out that {rush} is an R package I tried loading R directly and got the same error

$R
ERROR: R_HOME ('/usr/lib/R') not found
$which R
/usr/bin/R

$/usr/bin/R
ERROR: R_HOME ('/usr/lib/R') not found

I tried adding the path to $PATH, that didnt help either

$ echo $PATH
/usr/lib/R:/usr/local/lib/R/site-library/rush/exec:/usr/bin/dsutils:/home/dst/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Last i tried to reinstall via apt-get R itself, that didnt help either.

Any suggestions on getting past this little problem?

jeroenjanssens commented 3 years ago

Thank you for your kind words and for taking the time to report this issue.

I have had one other person report the same issue, but I'm afraid that I'm unable to reproduce this myself. Could you please let me know:

  1. Your OS
  2. The exact command that you used to start the Docker container
  3. The output of "cat /tag" from within the container (this file contains the date on which the container was built)

For myself:

  1. macOS 11.2.3 (on MacBook Pro M1)
  2. docker run -it --rm datasciencetoolbox/dsatcl2e:latest
  3. 20210628

Thank you,

Jeroen

yonicd commented 3 years ago
  1. MacOS 11.4 (MacBook Pro)
  2. docker run --rm -it -v "$(pwd)":/data datasciencetoolbox/dsatcl2e (from book instructions setup)
  3. 20210628

FWIW I tried this on a WinOS 10 w WSL 2 and got the same error msg.

jeroenjanssens commented 3 years ago

Thank you. I also tested it on an older MacBook (not M1) and on Windows. Both cases worked. Very curious.

I found this answer on Stack Overflow. Would you mind running the following in the Docker container:

$ export R_HOME=/usr/lib/R
$ R

I have no idea if this works, but if it does, then I'll change the Docker image to set this variable. Thanks for your help.

yonicd commented 3 years ago

I have tried this in the past (added to the PATH in original post), it doesn't seem to work.

$ export R_HOME=/usr/lib/R                                                                         
$ R
ERROR: R_HOME ('/usr/lib/R') not found
qxliang2014 commented 3 months ago

I were involved in the same error when I ran R --version in the datasciencetoolbox/dsatcl2e container and export R_HOME=/usr/lib/R didn't work,then I commented out lines 263-267 of the executable files /usr/lib/R/bin/R and /usr/bin/R with nano and it works for me.