I echo this. Relying on something undocumented and platform-specific, like the location of a random installation file, is just asking for problems. Instead, make a small image of your own and distribute it with your package.
-----Original Message----- From: R-package-devel <r-package-devel-boun...@r-project.org> On Behalf Of Ben Bolker Sent: Tuesday, 4 February 2020 7:16 AM To: r-package-devel@r-project.org Subject: [EXTERNAL] Re: [R-pkg-devel] finding "logo.jpg" [was: "try" malfunctions on Ubuntu Linux 16.04 LTS, R-release, GCC] Maybe include your own version of logo.jpg in inst/ ? On 2020-02-03 2:30 p.m., Spencer Graves wrote: > Thanks to Iñaki Ucar for identifying a second error that explained > why I still got an error after wrapping one in "try". > > > That still leaves a question of how to find a file like "logo.jpg" > in a platform independant way. > > > The following had worked for several years and now broke on rhub > "Ubuntu Linux 16.04 LTS, R-release, GCC" but not on several other > computers I tried: > > > logo.jpg <- paste(R.home(), "doc", "html", "logo.jpg", sep = > .Platform$file.sep) > > > On that Ubuntu platform, "readJPEG(logo.jpg)" stopped with "Error > in readJPEG(logo.jpg) : unable to open /usr/lib/R/doc/html/logo.jpg". > > > I replaced the above "paste" with the following: > > > RdocDir <- dir(R.home(), pattern='^doc$', full.names = TRUE) > RhtmlDir <- dir(RdocDir, pattern='^html$', full.names=TRUE) > JPGs <- dir(RhtmlDir, pattern='\\\\.jpg$', full.names=TRUE) > if(length(JPGs)>1){ > logoJPG <- paste0(.Platform$file.sep, 'logo.jpg$') > logo.jpg <- grep(logoJPG, JPGs, value=TRUE) > if(length(logo.jpg)>1)logo.jpg <- logo.jpg[1] > if(length(logo.jpg)<1)logo.jpg <- JPGs[1] > } else logo.jpg <- JPGs > if(length(logo.jpg)<1){ > cat('logo.jpg not found.\n') > print(R.home()) > print(dir(RdocDir)) > print(dir(RhtmlDir)) > if(!fda::CRAN())stop('logo.jpg not found') > } else { > # length(logo.jpg)==1 so continue: > if(require(jpeg)){ > ## > ## 1. Shrink as required > ## > Rlogo <- readJPEG(logo.jpg) > > ... > > > This gave me no error message, which I believe means that either > length(logo.jpg) == 1 or fda::CRAN() returns TRUE. Sadly, I could not > find the standard test file to see which of these is the case. > > > I should proceed to submit the current Ecfun package to CRAN. Then > I might modify this test sequence to force an error, so I can see more > what is happening. > > > Suggestions? > Thanks, > Spencer > > > On 2020-02-03 03:06, Iñaki Ucar wrote: >> On Mon, 3 Feb 2020 at 03:16, Spencer Graves >> <spencer.gra...@effectivedefense.org> wrote: >>> Hello, All: >>> >>> >>> devtools::check_rhub failed to trap an error wrapped in "try", >>> per the email below. This came from running >>> devtools::check_rhub(Ecfun_dir), where Ecfun_dir = the path to a copy of >>> "https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsbgraves237%2FEcfun&data=02%7C01%7Chongooi%40microsoft.com%7C757daa698b0a4830eaa908d7a8e5e496%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637163577651198242&sdata=NW7oju2vYnhaaYnNnP8q%2F5yG1Vqusa21CMnTQtUwPAs%3D&reserved=0". >> That's improbable. >> >>> This is the development version of Ecfun, which I want to submit >>> to CRAN as soon as I can do so without offending the sensibilities of >>> the overworked CRAN maintainers. >>> >>> >>> Suggestions? >>> Thanks, >>> Spencer Graves >>> >>> >>> -------- Forwarded Message -------- >>> Subject: Ecfun 0.2-2: ERROR >>> Date: Sun, 02 Feb 2020 23:27:10 +0000 >>> From: R-hub builder <supp...@rhub.io> >>> To: spencer.gra...@effectivedefense.org >>> >> <snip> >> >>>> ## 2.9. A more complicated example with elements to eval >>>> ## >>>> logo.jpg <- paste(R.home(), "doc", "html", "logo.jpg", >>> + sep = .Platform$file.sep) >>>> if(require(jpeg)){ >>> + Rlogo <- try(readJPEG(logo.jpg)) >>> + if(!inherits(Rlogo, 'try-error')){ >>> + # argument list for a call to rasterImage or rasterImageAdj >>> + RlogoLoc <- list(image=Rlogo, >>> + xleft.0 = c(NZ=176.5,CH=172,US=171, >>> + CN=177,RU= 9.5,UK= 8), >>> + xleft.1 = c(NZ=176.5,CH= 9,US=-73.5, >>> + CN=125,RU= 37, UK= 2), >>> + ybottom.0=c(NZ=-37, CH=-34,US=-34, >>> + CN=-33,RU= 48, UK=47), >>> + ybottom.1=c(NZ=-37, CH= 47,US= 46, >>> + CN= 32,RU=55.6,UK=55), >>> + xright=quote(xleft+xinch(0.6)), >>> + ytop = quote(ybottom+yinch(0.6)), >>> + angle.0 =0, >>> + angle.1 =c(NZ=0,CH=3*360,US=5*360, >>> + CN=2*360,RU=360,UK=360) >>> + ) >>> + >>> + RlogoInterp <- interpPairs(RlogoLoc, >>> + .proportion=rep(c(0, -1), c(2, 4)) ) >>> + # check >>> + ## Don't show: >>> + stopifnot( >>> + ## End(Don't show) >>> + all.equal(names(RlogoInterp), >>> + c('image', 'xright', 'ytop', 'xleft', 'ybottom', 'angle')) >>> + ## Don't show: >>> + ) >>> + ## End(Don't show) >>> + } >>> + # NOTE: 'xleft', and 'ybottom' were created in interpPairs, >>> + # and therefore come after 'xright' and 'ytop', which were >>> + # already there. >>> + >>> + ## >>> + ## 2.10. using envir >>> + ## >>> + RlogoDiag <- list(x0=quote(Rlogo.$xleft), >>> + y0=quote(Rlogo.$ybottom), >>> + x1=quote(Rlogo.$xright), >>> + y1=quote(Rlogo.$ytop) ) >>> + >>> + RlogoD <- interpPairs(RlogoDiag, .p=1, >>> + envir=list(Rlogo.=RlogoInterp) ) >>> + ## Don't show: >>> + stopifnot( >>> + ## End(Don't show) >>> + all.equal(RlogoD, RlogoDiag) >>> + ## Don't show: >>> + ) >>> + ## End(Don't show) >>> + } >>> Loading required package: jpeg >>> Error in readJPEG(logo.jpg) : unable to open >>> /usr/lib/R/doc/html/logo.jpg >>> Error in interpPairs.list(RlogoDiag, .p = 1, envir = list(Rlogo. = >>> RlogoInterp)) : >>> object 'RlogoInterp' not found >>> Calls: interpPairs -> interpPairs.list >>> Execution halted >> There it is: "Error in interpPairs.list [...] 'RlogoInterp' not >> found". That's the error, not the "try". You see the error message >> because you didn't specify "quiet=TRUE", but that doesn't mean that R >> is failing to catch the error. So the second error is the one that >> fails. >> >> Iñaki > > ______________________________________________ > R-package-devel@r-project.org mailing list > https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel&data=02%7C01%7Chongooi%40microsoft.com%7C757daa698b0a4830eaa908d7a8e5e496%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637163577651198242&sdata=5IKP0vP4WLPd55s1x9HXf8daWZa7YipossPTq4N9ht0%3D&reserved=0 ______________________________________________ R-package-devel@r-project.org mailing list https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel&data=02%7C01%7Chongooi%40microsoft.com%7C757daa698b0a4830eaa908d7a8e5e496%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637163577651198242&sdata=5IKP0vP4WLPd55s1x9HXf8daWZa7YipossPTq4N9ht0%3D&reserved=0 ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel