rocker-org / rocker

R configurations for Docker
https://rocker-project.org
GNU General Public License v2.0
1.46k stars 271 forks source link

ERROR: R_HOME ('/usr/lib/R') not found #482

Closed jubilee2 closed 2 years ago

jubilee2 commented 2 years ago

HI guys here is an example to reproduce the error

#Docker file example
FROM r-base:4.1.1

RUN apt-get update && \
    apt-get install -y \
        npm \
        openssh-client \
        git \
    && rm -rf /var/lib/apt/lists/*

when i try to build image the test R then get error

docker build . -t test
docker run -it --rm test R
ERROR: R_HOME ('/usr/lib/R') not found

here is no sense to me is anyone have same issue?

Thanks for help

eddelbuettel commented 2 years ago

That ... seems odd. I (and many others) build and use derivatives of the base R container all day long. Maybe it is as simple as your name test being a little ... odd. I often use local-* so that I know what is temporary and be nuked.

Also, works here:

edd@rob:/tmp/rocker-issue-482$ docker build -t local-issue-482 .
[.... lot omitted ...]
edd@rob:/tmp/rocker-issue-482$ docker run -ti --rm local-issue-482 R -q
> cat("Hello, world\n")
Hello, world
> q()
Save workspace image? [y/n/c]: n
edd@rob:/tmp/rocker-issue-482$ 

The only (immaterial) change I made was to rely on latest for r-base.

edd@rob:/tmp/rocker-issue-482$ cat Dockerfile 
#Docker file example
FROM r-base

RUN apt-get update && \
    apt-get install -y \
                npm \
                openssh-client \
                git \
        && rm -rf /var/lib/apt/lists/*
edd@rob:/tmp/rocker-issue-482$ 
jubilee2 commented 2 years ago

Thanks for response

Here was I tried to build from latest image then get more error

Sending build context to Docker daemon  6.144kB
Step 1/2 : FROM r-base
latest: Pulling from library/r-base
Digest: sha256:8ff05d8714f96cdcff173c6f0aa78c081a21a23d28d2e06914d0a34edb83604a
Status: Downloaded newer image for r-base:latest
 ---> 4b361dfebd4f
Step 2/2 : RUN apt-get update &&     apt-get install -y                 npm             openssh-client          git     && rm -rf /var/lib/apt/lists/*
 ---> Running in 77d896e8ca8f
Ign:1 https://eddelbuettel.github.io/ppaR400 ./ InRelease
Get:3 https://eddelbuettel.github.io/ppaR400 ./ Release [1,204 B]
Ign:4 https://eddelbuettel.github.io/ppaR400 ./ Release.gpg
Get:5 https://eddelbuettel.github.io/ppaR400 ./ Packages [26.4 kB]
Get:6 http://deb.debian.org/debian testing InRelease [129 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian sid InRelease [165 kB]
Get:7 http://deb.debian.org/debian experimental InRelease [75.4 kB]
Err:6 http://deb.debian.org/debian testing InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
Err:2 http://cdn-fastly.deb.debian.org/debian sid InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
Err:7 http://deb.debian.org/debian experimental InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
Reading package lists...
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/testing/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://deb.debian.org/debian testing InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
E: The repository 'http://deb.debian.org/debian testing InRelease' is not signed.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://http.debian.net/debian/dists/sid/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://cdn-fastly.deb.debian.org/debian sid InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
E: The repository 'http://http.debian.net/debian sid InRelease' is not signed.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-bullseye-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-buster-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-security-automatic.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/experimental/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/debian-archive-stretch-stable.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: http://deb.debian.org/debian experimental InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
E: The repository 'http://deb.debian.org/debian experimental InRelease' is not signed.
The command '/bin/sh -c apt-get update &&     apt-get install -y                npm             openssh-client          git     && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100
eddelbuettel commented 2 years ago

Not reproducible. I have by now deleted the image but as you insist on long logs here is mine.

edd@rob:/tmp/rocker-issue-482$ docker build -t local-issue-482 .                                                                                                                                                   
Sending build context to Docker daemon  2.048kB                                                          
Step 1/2 : FROM r-base                                                                                   
 ---> 13f75f489d67                                                                                       
Step 2/2 : RUN apt-get update &&     apt-get install -y                 npm             openssh-client          git     && rm -rf /var/lib/apt/lists/*
 ---> Running in 917d64191c08                                                                            
Get:1 http://deb.debian.org/debian testing InRelease [129 kB]                                            
Get:2 http://deb.debian.org/debian experimental InRelease [75.4 kB]                                                                                                                                                
Ign:3 https://eddelbuettel.github.io/ppaR400 ./ InRelease                                                                                                                                                          
Get:4 http://deb.debian.org/debian testing/main amd64 Packages [8,242 kB]                                                                                                                                          
Get:5 https://eddelbuettel.github.io/ppaR400 ./ Release [1,204 B]                                                                                                                                                  
Ign:6 https://eddelbuettel.github.io/ppaR400 ./ Release.gpg                                              
Get:7 https://eddelbuettel.github.io/ppaR400 ./ Packages [26.4 kB]                                                                                                                                                 
Get:8 http://deb.debian.org/debian experimental/main amd64 Packages [411 kB]                             
Get:9 http://cdn-fastly.deb.debian.org/debian sid InRelease [165 kB]                                   
Get:10 http://cdn-fastly.deb.debian.org/debian sid/main amd64 Packages [8,889 kB]                        
Fetched 17.9 MB in 2s (9,485 kB/s)                                                                       
Reading package lists...                                                                                                                                                                                           
Reading package lists...                                                                                 
Building dependency tree...                                                                                                                                                                                        
Reading state information...                                                                             
The following additional packages will be installed:                                                     
  git-man gyp libc-ares2 libcbor0.8 libcurl3-gnutls libedit2 liberror-perl                               
  libfido2-1 libjs-events libjs-inherits libjs-is-typedarray                                                                                                                                                       
  libjs-typedarray-to-buffer libmpdec3 libnode-dev libnode72 libpython3-stdlib                           
  libpython3.9-minimal libpython3.9-stdlib libsqlite3-0 libssl-dev libssl1.1                             
  libuv1 libuv1-dev media-types node-abbrev node-agent-base node-ansi-regex  
[.... lots more deleted....]

Maybe your keyring package is behind. I have no idea. But it is highly likely that it is a local issue at your end.

Maybe google the keyring error message. I may have updated my keys here -- I don't recall details right now.

But there is nothing fundamentally broken.

eddelbuettel commented 2 years ago

To iterate more quickly, remove the npm installation. Install just git or openssh-client (with few depends) and/or just update apt.

jubilee2 commented 2 years ago

thank you for followup I will found another server to test it

eddelbuettel commented 2 years ago

Also, as suggested, try to deal with the keys. Here is one post that just came up as the top hit in a search on the error message for me: https://chrisjean.com/fix-apt-get-update-the-following-signatures-couldnt-be-verified-because-the-public-key-is-not-available/

jubilee2 commented 2 years ago

Thanks, everyone I test on another server with same code not has this issue. Thanks @eddelbuettel help

eddelbuettel commented 2 years ago

Good to know you're all set now!

dansmith01 commented 2 years ago

@jubilee2, I had the same error and found that updating docker was the trick.

vst commented 2 years ago

@jubilee2, I had the same error and found that updating docker was the trick.

I am confident that this will solve my problem, too, but I can not do an upgrade at the moment.

I know that it is silly, but the line /usr/bin/R script, when changed from:

if test -x "${R_HOME}"; then

... to:

if test -d "${R_HOME}"; then

... it works. And yes, the directory permission is indeed OK as far as I understand:

$ stat /usr/lib/R
  File: /usr/lib/R
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 100017h/1048599d        Inode: 459839      Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-04-12 15:36:07.532564855 +0000
Modify: 2022-03-29 18:12:01.000000000 +0000
Change: 2022-04-12 15:36:07.516564577 +0000
 Birth: 2022-04-12 15:36:05.664532396 +0000

I never experienced something like this before, so I can not comment further.

eddelbuettel commented 2 years ago
  1. If this were a problem in general you should report it upstream because that is where /usr/bin/R comes from. The bugzilla for the R Projects is here: https://bugs.r-project.org/

  2. I very strongly suspect something is wrong or off at your end because R has used R_HOME internally for 25+ on various shells and shell implementations.

  3. What does R RHOME say on your end (yes; no space there, 'RHOME' as an argument to R)

PS Per svn blame that lines is from commit 21742 -- made on October 30, 2002. Yes. Twenty years ago. I hasn't needed changing since. I doubt it does now. Something else is happening here.

vst commented 2 years ago

Agreed, and I did not intend to re-open the issue. It would be mad to blame /usr/bin/R or test.

I suspect that the issue is related to Docker runtime (maybe volume drivers) for a specific Docker version. The problem happens on servers with Docker v19.03.8, but I can not reproduce the problem on others (Docker v20.10.12, v20.10.14), for example.

For completeness, R RHOME says /usr/lib/R.

eddelbuettel commented 2 years ago

And the test -d (for directory) versus test -x (for executable file) should not matter. And I agree that this seems to point at Docker for providing the file. It's good to have it documented here, but there is (as well all seem to agree) likely no issue in R or Rocker.

jubilee2 commented 2 years ago

i think it's an issue of docker, and fixed in last docker version.

preciserobot commented 2 years ago

I ran into exactly the same issue. Image built with Docker 19 worked everywhere. Same Image built with Docker 20.10.14 didn't work on older Docker hosts with the same error (yet it worked on the machine that built it).

eitsupi commented 2 years ago

See also https://github.com/rocker-org/rocker/issues/489#issuecomment-1091668187

sqvdusers commented 2 years ago

That finally makes sense! Thanks @eitsupi for pointing it out. I thought I was losing my mind!