Open lehnert-b opened 4 years ago
Any chance you can write a diff with this function? I'll gladly accept it to the package.
Sorry, I do not understand what a diff is in this case or from what function I should provide a diff. Within my limited abilities I am glad to help but will need more detailed instruction.
Hey, You'll need to write a function similar to the one here: https://github.com/talgalili/installr/blob/master/R/install.R#L678 Edit that page (top right corner of the page), to add your new function, and I can take a look at it.
Cheers, T
On Sun, Jun 7, 2020 at 7:10 PM lehnert-b notifications@github.com wrote:
Sorry, I do not understand what a diff is in this case or from what function I should provide a diff. Within my limited abilities I am glad to help but will need more detailed instruction.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/talgalili/installr/issues/149#issuecomment-640241617, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHOJBXT7EPLZEGZMVDI4ODRVO3WBANCNFSM4M2JW45Q .
The annoying thing is that install.URL("https://sourceforge.net/projects/qpdf/files/latest/download")
doesn't work, because it downloads a zip and not an exe, otherwise, it would be super easy to add :(
Did you ever add a program like this before @talgalili?
What we can do is take a look at tinytex, they install to %appdata%
and "tweak" the PATH
(https://github.com/yihui/tinytex/blob/master/R/install.R#L138)
Quick and dirty code which works:
install.qpdf <- function() {
dir <- win_app_dir('qpdf')
temp_file <- tempfile(fileext = ".zip")
# Need to use curl, and easy link unfortunately doesn't work
# download.file("https://sourceforge.net/projects/qpdf/files/latest/download", destfile = temp_file)
curl::curl_download("https://sourceforge.net/projects/qpdf/files/qpdf/10.1.0/qpdf-10.1.0-bin-mingw64.zip/download", destfile = temp_file)
unzip(temp_file, exdir = dir)
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste(old_path, file.path(dir, "qpdf-10.1.0", "bin"), sep = ";"))
}
win_app_dir = function(..., error = TRUE) {
d = Sys.getenv('APPDATA')
if (d == '') {
if (error) stop('Environment variable "APPDATA" not set.')
return(d)
}
file.path(d, ...)
}
You can check with Sys.which('qpdf')
.
Sooo, if you use a browser you can go to ''https://sourceforge.net/projects/qpdf/files/latest/download" and you will get the latest zip, but if you try that in R it doesn't know what you want, and you get the source ".tar.gz" :( (see this for official "reason").
The code above also doesn't check the path if qpdf is already present, but that adds quite a bit of PATH management code :/
In summary: will take quite a bit of work to determine the correct URL, and will take quite a bit of work to add proper PATH management :(
EDIT: this only changes the PATH for the current session, so user should be instructed to add qpdf to PATH him/herself
Bummer, Not sure what to propose here. But if you manage to solve it - please suggest a pull request and I'll gladly let it in.
T
On Tue, Jan 12, 2021 at 11:39 PM Gerhard Burger notifications@github.com wrote:
Quick and dirty code which works:
install.qpdf <- function() { dir <- win_app_dir('qpdf') temp_file <- tempfile(fileext = ".zip")
Need to use curl, and easy link unfortunately doesn't work
download.file("https://sourceforge.net/projects/qpdf/files/latest/download", destfile = temp_file)
curl::curl_download("https://sourceforge.net/projects/qpdf/files/qpdf/10.1.0/qpdf-10.1.0-bin-mingw64.zip/download", destfile = temp_file) unzip(temp_file, exdir = dir) old_path <- Sys.getenv("PATH") Sys.setenv(PATH = paste(old_path, file.path(dir, "qpdf-10.1.0", "bin"), sep = ";")) }
win_app_dir = function(..., error = TRUE) { d = Sys.getenv('APPDATA') if (d == '') { if (error) stop('Environment variable "APPDATA" not set.') return(d) } file.path(d, ...) }
You can check with Sys.which('qpdf').
Sooo, if you use a browser you can go to '' https://sourceforge.net/projects/qpdf/files/latest/download" and you will get the latest zip, but if you try that in R it doesn't know what you want, and you get the source ".tar.gz" :( (see this https://sourceforge.net/p/forge/documentation/Downloading%20files%20via%20the%20command%20line/#bonus-round for official "reason").
The code above also doesn't check the path if qpdf is already present, but that adds quite a bit of PATH management code :/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/talgalili/installr/issues/149#issuecomment-759039703, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHOJBV4WCOXXQWMV45HEU3SZS6QFANCNFSM4M2JW45Q .
When writing R packages one important step is to test the package thoroughly. Upload to CRAN is advised only for error-, warning- and issue-free packages. My checks (started via the respective RStudio-Buttons) produce the following warning:
So qpdf is R related software and as it does not come with an installer and users are instead advised to unzip and change their windows PATH manually. I naturally checked, if that could be done by installr just to find out, it is not yet implemented.
qpdf lives on sourceforge at http://qpdf.sourceforge.net/
May I suggest adding qpdf to the program list downloadable via installr?
BTW: Thank you for the great package! Cheers, Bernhard