Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headers not considered in function renv_bootstrap_download_cran_latest_find when retrieving package database #1942

Closed
siri16100 opened this issue Jul 5, 2024 · 7 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@siri16100
Copy link

Hi @kevinushey as mentioned in #1084 I use renv together with artifactory and have problems when bootstrapping. I debugged into renv\activate.R and found the potential problem in function renv_bootstrap_download_cran_latest_find. The function tries to retrieve the package database:

utils::available.packages(type = type, repos = repos),

this is (e.g. when using artifactory) not possible, as no headers are provided in function available.packages. Experimentally, I changed the line into:

utils::available.packages(type = type, repos = repos, headers = renv_bootstrap_download_custom_headers(repos))

and all worked fine.

Maybe you have the chance to look into this?

@kevinushey
Copy link
Collaborator

Thanks! Should be fixed up via 0f0ad9d.

@kevinushey kevinushey added the bug an unexpected problem or unintended behavior label Jul 9, 2024
@bruceskarin
Copy link

Greetings, We're having some issues around this as well, thanks for fixing it! Any chance you can get it out in a release? We unfortunately can't install dev versions.

@kevinushey
Copy link
Collaborator

Thanks for the nudge -- I can look into preparing a release soon.

@siri16100
Copy link
Author

siri16100 commented Oct 9, 2024

Hi @kevinushey I just had the chance to test this but still having trouble to get this running. Problem imho is function renv_bootstrap_download_cran_latest_find which calls renv_bootstrap_download_custom_headers(url) but function argument url is not yet defined in the function. The changes below helped me to get the bootstrapping running:

renv_bootstrap_download_cran_latest <- function(version) {
    repos =  renv_bootstrap_repos()
    type = "binary"
    
    baseurl <- utils::contrib.url(repos = repos, type = type)
    ext <- if (identical(type, "source"))
      ".tar.gz"
    else if (Sys.info()[["sysname"]] == "Windows")
      ".zip"
    else
      ".tgz"
    name <- sprintf("renv_%s%s", version, ext)
    url <- paste(baseurl, name, sep = "/")
    
    spec <- renv_bootstrap_download_cran_latest_find(version, url)
    type  <- spec$type
    repos <- spec$repos 
    
    destfile <- file.path(tempdir(), name)
    status <- tryCatch(
      renv_bootstrap_download_impl(url, destfile),
      condition = identity
    )
  
    if (inherits(status, "condition"))
      return(FALSE)
  
    # report success and return
    destfile
  
  }

@kevinushey
Copy link
Collaborator

Thanks -- I think 5725cde should also fix the issue; I chose to pass the repository URL when retrieving custom headers in this case.

@siri16100
Copy link
Author

@kevinushey thanks for fixing this, as far as I was able to test den dev version it does work now. Any chance you can get it out in a release?

@kevinushey
Copy link
Collaborator

Thanks for testing! I'll try to get a patch release out soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants