Skip to content

Conversation

@pawelru
Copy link
Contributor

@pawelru pawelru commented Jun 17, 2025

  • use pak for downloading and installing
    • unfortunately pak gives ambiguous download results - sometimes it gives .tar.gz, sometimes compressed files etc. A lot of code in this PR is to handle this.
  • add error condition if fails on install - basically we succeed only if everything (!) is checked and everything (!) is ok

@pawelru pawelru marked this pull request as ready for review June 25, 2025 09:48
@pawelru pawelru changed the title init refactor - use pak for downloading and installing Jun 25, 2025
@pawelru pawelru added the core label Jun 25, 2025
@pawelru
Copy link
Contributor Author

pawelru commented Jun 25, 2025

I have read the CLA Document and I hereby sign the CLA

Copy link

@llrs-roche llrs-roche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review is mostly from reading the code. Are there any conditions you wanted to check it works better now? (I see lots of commits with "test" as the message)

It seems like the script itself starts on line 224, but it is not documented with a comment. It will be probably easier for future readers.

I tested locally on the teal repository and it didn't finish (but command did finish from an interactively R session):

cd ../teal
Rscript.exe ../r-revdepcheck-action/script.R ../r-revdepcheck-action/repo 2 1200
Installing required packages...
✔ Loading metadata database ... done

ℹ No downloads are needed
✔ 7 pkgs + 75 deps: kept 81 [10.7s]

── Configuration ─────────────────────────────────────────────
Missing `.revdeprefs.yaml` file.fig file...
This indicates all reverse dependencies from CRAN.
✔ Reading `.revdeprefs.yaml` config file... [368ms]
References used:

── Initiate pre-requisites ───────────────────────────────────
[1] "C:/Users/sanchosl/AppData/Local/Temp/Rtmpu2k72q/file581836218a3/src/contrib/rlang_1.1.6.tar.gz"
✔ Initiating `miniCRAN`... [4s]
Error in read.dcf("DESCRIPTION") : cannot open the connection
In addition: Warning message:
In read.dcf("DESCRIPTION") :
  cannot open compressed file 'DESCRIPTION', probable reason 'No such file or directory'
Execution halted

Comment on lines +86 to +92
get_tar_gz_from_file <- function(pkg, version, path) {
path
}
get_tar_gz_from_fulltarget <- function(pkg, version, path) {
get_tar_gz_from_file(pkg, version, path)
}
get_tar_gz_from_fulltarget_tree <- function(pkg, version, path) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three functions could be reduced to one using missing() to control the behavior

Comment on lines +116 to +117
temp_dir <- tempfile()
dir.create(temp_dir)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temp_dir is a file. Given that pkbuild::build says that dest_path: " If it is an existing file, then it will be overwritten." It could create a temporary file on the beginning of the function and reuse that instead of creating one for each branch.

Comment on lines +56 to +61
tempdir <- tempfile()
dir.create(tempdir)
on.exit(unlink(tempdir, recursive = TRUE), add = TRUE)

new_file_name <- sprintf("%s_%s.tar.gz", pkg, version)
file.copy(tar_gz_path, file.path(tempdir, new_file_name))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier to use dirname(tar_gz_path) instead of copying the file to a temporary folder for miniCRAN to copy to the repository folder?

miniCRAN::addLocalPackage(pkg, dirnames(tar_gz_path), minicran_path)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would and I really wanted to make it like this but miniCRAN::addLocalPackage complained if the parent dir contains more than the binary file for a given package which is very typical for things like cache dir - it does contain multiple files.
Just because of that - I created this helper add_to_minicran function to: (i) create empty temp dir, (ii) move from cache into that dir and finally (iii) add to miniCRAN. This function is meant exactly to address that comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, please document a bit the function as I missed it all the reasons. (sorry for getting back to you after so late)

}

args <- commandArgs(trailingOnly = TRUE)
setwd(normalizePath(file.path(args[1])))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document here too that the first arguments is the repository path. Also it is not checked that the directory exists.

@llrs-roche llrs-roche self-assigned this Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants