[英]R devtools::install_github() error in download: unauthorized
[英]R function devtools::install_github in a Dockerfile returns a 404 error
我正在写一个Dockerfile来创建一个基于rocker / verse:3.6.1。的docker镜像。 我需要安装Github上可用的R软件包,并且需要通过特定的提交安装每个软件包。 我正在使用具有以下内容的Dockerfile:
FROM rocker/verse:3.6.1
LABEL maintainer='Unknown'
RUN R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"
在shell提示符docker build .
键入后,我看到下面的输出docker build .
在包含此Dockerfile的目录中。
docker build .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM rocker/verse:3.6.1
---> 8a978a45abab
Step 2/3 : LABEL maintainer='Unknown'
---> Using cache
---> d054ca33baac
Step 3/3 : RUN R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"
---> Running in dea49b1bb351
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')
Error: Failed to install 'unknown package' from GitHub:
HTTP error 404.
No commit found for the ref 1584b7fccb49c2bd502ea4bdf3b7de27b0243561
Did you spell the repo owner (`rstudio`) and repo name (`renv`) correctly?
- If spelling is correct, check that you have the required permissions to access the repo.
Execution halted
The command '/bin/sh -c R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"' returned a non-zero code: 1
在不使用docker的情况下,通过输入shell,我已经成功安装了所需的软件包(处于所需的提交)
R -e "devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')"
我还可以使用以下Dockerfile成功构建docker映像:
FROM rocker/verse:3.6.1
LABEL maintainer='Unknown'
RUN R -e "devtools::install_github('rstudio/renv')"
在这里,我省略了对参数ref
的明确包含。 但是,我仍在努力构建所需的图像。
我感谢这些观察结果的任何解决方案和解释。
PS-这是我用来识别提交哈希的R代码:
github_lookup_commit_sha_and_date <- function(remote_pkg, date, limit = 1000){
commits_list <- gh::gh(paste0("/repos/", remote_pkg, "/commits"), .limit = limit)
commit_dates <- purrr::map(.x = commits_list, .f = function(x) lubridate::as_datetime(x$commit$author$date))
commit_shas <- purrr::map_chr(.x = commits_list, .f = function(x)x$commit$tree$sha)
tibble::tibble(commit_date = lubridate::as_datetime(unlist(commit_dates)), sha = commit_shas) %>%
dplyr::filter(commit_date < as_datetime(date)) %>%
dplyr::mutate(datetime_diff = abs(commit_date - as_datetime(date)), remote_package = remote_pkg) %>%
dplyr::filter(datetime_diff == min(datetime_diff))
}
github_lookup_commit_sha_and_date("rstudio/renv", lubridate::as_date("2019-01-01"))
rstudio/renv
这是我在rstudio/renv
外部安装rstudio/renv
时看到的输出。
> devtools::install_github('rstudio/renv', ref = '1584b7fccb49c2bd502ea4bdf3b7de27b0243561')
Downloading GitHub repo rstudio/renv@1584b7fccb49c2bd502ea4bdf3b7de27b0243561
✔ checking for file ‘/private/var/folders/wd/lxmyvz590xb81c5z1j88b3800000gn/T/RtmpNW1W3J/remotesc63521cc2a5d/rstudio-renv-1584b7f/DESCRIPTION’ ...
─ preparing ‘renv’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘renv_0.0.1-42.tar.gz’
* installing *source* package ‘renv’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (renv)
我的猜测是您的哈希规范是错误的。 请检查提交哈希。
使用有效的哈希安装就可以了。
> remotes::install_github('rstudio/renv', ref = '810b0da975840f408f0f9d61348cc797ff06eac8')
Downloading GitHub repo rstudio/renv@810b0da975840f408f0f9d61348cc797ff06eac8
✔ checking for file ‘/tmp/Rtmp6AVyuj/remotes765d1d4957b2/rstudio-renv-810b0da/DESCRIPTION’ ...
─ preparing ‘renv’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘renv_0.6.0-118.tar.gz’
Installing package into ‘/home/romunov/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package ‘renv’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (renv)
也可以在Docker中使用
$ docker build -t testcase .
Sending build context to Docker daemon 3.628MB
Step 1/3 : FROM rocker/verse:3.6.1
---> 802df297107c
Step 2/3 : LABEL maintainer='Unknown'
---> Running in 098c39a9ec93
Removing intermediate container 098c39a9ec93
---> 09ead2a80379
Step 3/3 : RUN R -e "remotes::install_github('rstudio/renv', ref = '810b0da975840f408f0f9d61348cc797ff06eac8')"
---> Running in 1ed4f5a3aea8
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> remotes::install_github('rstudio/renv', ref = '810b0da975840f408f0f9d61348cc797ff06eac8')
Downloading GitHub repo rstudio/renv@810b0da975840f408f0f9d61348cc797ff06eac8
✔ checking for file ‘/tmp/RtmpDBKP3J/remotes63de88040/rstudio-renv-810b0da/DESCRIPTION’ ...
─ preparing ‘renv’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘renv_0.6.0-118.tar.gz’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘renv’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (renv)
>
>
Removing intermediate container 1ed4f5a3aea8
---> 41166e3420e9
Successfully built 41166e3420e9
Successfully tagged testcase:latest
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.