Re: [R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Keshav, Krishna
Hi,

This works. I think this is also an implementation of what Berry and Duncan 
suggested earlier. Thanks.

Best Regards,
Krishna Keshav

From: Iris Simmons 
Date: Monday, October 9, 2023 at 7:37 PM
To: Keshav, Krishna 
Cc: r-package-devel@r-project.org 
Subject: Re: [R-pkg-devel] Error: [writeRaster] cannot write file
[External Email]
You wrote

# create the plots directory if it does not exist

but then created a directory named outdir/plots/typ_Sys.time.tif

You need to rewrite the code like:

plotsdir <- file.path(outdir, "plots")
fp <- file.path(plotsdir,  paste(typ, "_",
stringr::str_replace_all(Sys.time(), "[^a-zA-Z0-9]", ""),
".tif", sep = ""))
# Create the "plots" directory if it doesn't exist
  if (!dir.exists(plotsdir)) {
dir.create(plotsdir, recursive = TRUE)
  }

On Mon, Oct 9, 2023, 15:49 Keshav, Krishna 
mailto:kkes...@ufl.edu>> wrote:
Hi,

I am developing an R package where I need to save Raster file with .tif 
extension to the tempdir(). I am using terra::writeRaster for the same. While 
it works through R CMD check in mac, it is failing in R hub builder.
Snippet �V
.saverast <- function(typ, rast, outdir) {

  if (is.null(outdir) || length(outdir) == 0) {
outdir <- tempdir()
  }

  # Save the plot as a raster file
  fp <- file.path(outdir, paste("plots", "/",
typ, "_",
stringr::str_replace_all(Sys.time(), 
"[^a-zA-Z0-9]", ""),
".tif", sep = ""))
# Create the "plots" directory if it doesn't exist
  if (!dir.exists(fp)) {
dir.create(fp, recursive = TRUE)
  }

  terra::writeRaster(rast, overwrite = TRUE,
 filename = fp,
 gdal = c("COMPRESS=NONE"))
  message(paste("raster created", fp, sep = ": "), "\n")
}

Error �V

  Error: [writeRaster] cannot write file
   12. �|�wgeohabnet:::.saverast(typ, rast, outdir)
   13.   �u�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, 
gdal = c("COMPRESS=NONE"))
   14.   �|�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, 
gdal = c("COMPRESS=NONE"))
   15. �|�wterra (local) .local(x, filename, ...)
   16.   �|�wterra:::messages(x, "writeRaster")
   17. �|�wterra:::error(f, x@pnt$getError())



Best Regards,
Krishna Keshav

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Iris Simmons
You wrote

# create the plots directory if it does not exist

but then created a directory named outdir/plots/typ_Sys.time.tif

You need to rewrite the code like:

plotsdir <- file.path(outdir, "plots")
fp <- file.path(plotsdir,  paste(typ, "_",
stringr::str_replace_all(Sys.time(), "[^a-zA-Z0-9]", ""),
".tif", sep = ""))
# Create the "plots" directory if it doesn't exist
  if (!dir.exists(plotsdir)) {
dir.create(plotsdir, recursive = TRUE)
  }

On Mon, Oct 9, 2023, 15:49 Keshav, Krishna  wrote:

> Hi,
>
> I am developing an R package where I need to save Raster file with .tif
> extension to the tempdir(). I am using terra::writeRaster for the same.
> While it works through R CMD check in mac, it is failing in R hub builder.
> Snippet ¡V
> .saverast <- function(typ, rast, outdir) {
>
>   if (is.null(outdir) || length(outdir) == 0) {
> outdir <- tempdir()
>   }
>
>   # Save the plot as a raster file
>   fp <- file.path(outdir, paste("plots", "/",
> typ, "_",
> stringr::str_replace_all(Sys.time(),
> "[^a-zA-Z0-9]", ""),
> ".tif", sep = ""))
> # Create the "plots" directory if it doesn't exist
>   if (!dir.exists(fp)) {
> dir.create(fp, recursive = TRUE)
>   }
>
>   terra::writeRaster(rast, overwrite = TRUE,
>  filename = fp,
>  gdal = c("COMPRESS=NONE"))
>   message(paste("raster created", fp, sep = ": "), "\n")
> }
>
> Error ¡V
>
>   Error: [writeRaster] cannot write file
>12. ¢|¢wgeohabnet:::.saverast(typ, rast, outdir)
>13.   ¢u¢wterra::writeRaster(rast, overwrite = TRUE, filename =
> fp, gdal = c("COMPRESS=NONE"))
>14.   ¢|¢wterra::writeRaster(rast, overwrite = TRUE, filename =
> fp, gdal = c("COMPRESS=NONE"))
>15. ¢|¢wterra (local) .local(x, filename, ...)
>16.   ¢|¢wterra:::messages(x, "writeRaster")
>17. ¢|¢wterra:::error(f, x@pnt$getError())
>
>
>
> Best Regards,
> Krishna Keshav
>
> [[alternative HTML version deleted]]
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Duncan Murdoch

On 09/10/2023 6:56 p.m., Keshav, Krishna wrote:
Outdir is either a directory like getwd(), tempdir() etc or empty/null. 
If it is empty/null, then I set it to tempdir().


That doesn't answer the question, and the link you provided doesn't 
answer it either, as far as I can see.  In the test and the vignette 
that generated the errors, something specific was passed as outdir.  But 
what? If it was getwd(), that's bound to fail -- you don't have 
permission to write there.  tempdir() should have worked, but Berry 
pointed out some other things that might be problems.


Duncan Murdoch



/if (is.null(outdir) || length(outdir) == 0) {
     outdir <- tempdir()/

/}///

I am not sure how to debug when running it in Rbuilder. But you can look 
at results here - 
https://builder.r-hub.io/status/geohabnet_1.0.0.tar.gz-a2eaa40ccf1d026bbebf5077bfb482d5 


Best Regards,

Krishna Keshav

*From: *Duncan Murdoch 
*Date: *Monday, October 9, 2023 at 4:08 PM
*To: *Keshav, Krishna , r-package-devel@r-project.org 


*Subject: *Re: [R-pkg-devel] Error: [writeRaster] cannot write file

[External Email]

What were you using as "outdir"?


On 09/10/2023 2:59 p.m., Keshav, Krishna wrote:

Hi,

I am developing an R package where I need to save Raster file with .tif 
extension to the tempdir(). I am using terra::writeRaster for the same. While 
it works through R CMD check in mac, it is failing in R hub builder.
Snippet �V
.saverast <- function(typ, rast, outdir) {

    if (is.null(outdir) || length(outdir) == 0) {
  outdir <- tempdir()
    }

    # Save the plot as a raster file
    fp <- file.path(outdir, paste("plots", "/",
  typ, "_",
  stringr::str_replace_all(Sys.time(), "[^a-zA-Z0-9]", 
""),
  ".tif", sep = ""))
  # Create the "plots" directory if it doesn't exist
    if (!dir.exists(fp)) {
  dir.create(fp, recursive = TRUE)
    }

    terra::writeRaster(rast, overwrite = TRUE,
   filename = fp,
   gdal = c("COMPRESS=NONE"))
    message(paste("raster created", fp, sep = ": "), "\n")
}

Error �V

    Error: [writeRaster] cannot write file
 12. �|�wgeohabnet:::.saverast(typ, rast, outdir)
 13.   �u�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, gdal = 
c("COMPRESS=NONE"))
 14.   �|�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, gdal = 
c("COMPRESS=NONE"))
 15. �|�wterra (local) .local(x, filename, ...)
 16.   �|�wterra:::messages(x, "writeRaster")
 17. �|�wterra:::error(f, x@pnt$getError())



Best Regards,
Krishna Keshav

   [[alternative HTML version deleted]]


__
R-package-devel@r-project.org mailing list
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel=05%7C01%7Ckkeshav%40ufl.edu%7Cddd83781762040d664dc08dbc9038ec7%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638324789348072931%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=mBzV%2BSJoOTTnSpRzu0EvLT8sZ2NJ1OlhSGXqNCvGWB4%3D=0
 




__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Keshav, Krishna
Outdir is either a directory like getwd(), tempdir() etc or empty/null. If it 
is empty/null, then I set it to tempdir().

if (is.null(outdir) || length(outdir) == 0) {
outdir <- tempdir()
}
I am not sure how to debug when running it in Rbuilder. But you can look at 
results here - 
https://builder.r-hub.io/status/geohabnet_1.0.0.tar.gz-a2eaa40ccf1d026bbebf5077bfb482d5

Best Regards,
Krishna Keshav

From: Duncan Murdoch 
Date: Monday, October 9, 2023 at 4:08 PM
To: Keshav, Krishna , r-package-devel@r-project.org 

Subject: Re: [R-pkg-devel] Error: [writeRaster] cannot write file
[External Email]

What were you using as "outdir"?


On 09/10/2023 2:59 p.m., Keshav, Krishna wrote:
> Hi,
>
> I am developing an R package where I need to save Raster file with .tif 
> extension to the tempdir(). I am using terra::writeRaster for the same. While 
> it works through R CMD check in mac, it is failing in R hub builder.
> Snippet �V
> .saverast <- function(typ, rast, outdir) {
>
>if (is.null(outdir) || length(outdir) == 0) {
>  outdir <- tempdir()
>}
>
># Save the plot as a raster file
>fp <- file.path(outdir, paste("plots", "/",
>  typ, "_",
>  stringr::str_replace_all(Sys.time(), 
> "[^a-zA-Z0-9]", ""),
>  ".tif", sep = ""))
>  # Create the "plots" directory if it doesn't exist
>if (!dir.exists(fp)) {
>  dir.create(fp, recursive = TRUE)
>}
>
>terra::writeRaster(rast, overwrite = TRUE,
>   filename = fp,
>   gdal = c("COMPRESS=NONE"))
>message(paste("raster created", fp, sep = ": "), "\n")
> }
>
> Error �V
>
>Error: [writeRaster] cannot write file
> 12. �|�wgeohabnet:::.saverast(typ, rast, outdir)
> 13.   �u�wterra::writeRaster(rast, overwrite = TRUE, filename = 
> fp, gdal = c("COMPRESS=NONE"))
> 14.   �|�wterra::writeRaster(rast, overwrite = TRUE, filename = 
> fp, gdal = c("COMPRESS=NONE"))
> 15. �|�wterra (local) .local(x, filename, ...)
> 16.   �|�wterra:::messages(x, "writeRaster")
> 17. �|�wterra:::error(f, x@pnt$getError())
>
>
>
> Best Regards,
> Krishna Keshav
>
>   [[alternative HTML version deleted]]
>
>
> __
> R-package-devel@r-project.org mailing list
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-package-devel=05%7C01%7Ckkeshav%40ufl.edu%7Cddd83781762040d664dc08dbc9038ec7%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638324789348072931%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=mBzV%2BSJoOTTnSpRzu0EvLT8sZ2NJ1OlhSGXqNCvGWB4%3D=0

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Berry Boessenkool

Are you intentionally running dir.exists on _file_names?
dir.exists("existing_folder/imaginary.file") shows FALSE, somwhat 
counterintuitively.
You might want to wrap the filenames in dirname...

Regards,
Berry

From: R-package-devel  on behalf of 
Keshav, Krishna 
Sent: Monday, October 9, 2023 20:59
To: r-package-devel@r-project.org 
Subject: [R-pkg-devel] Error: [writeRaster] cannot write file

Hi,

I am developing an R package where I need to save Raster file with .tif 
extension to the tempdir(). I am using terra::writeRaster for the same. While 
it works through R CMD check in mac, it is failing in R hub builder.
Snippet �V
.saverast <- function(typ, rast, outdir) {

  if (is.null(outdir) || length(outdir) == 0) {
outdir <- tempdir()
  }

  # Save the plot as a raster file
  fp <- file.path(outdir, paste("plots", "/",
typ, "_",
stringr::str_replace_all(Sys.time(), 
"[^a-zA-Z0-9]", ""),
".tif", sep = ""))
# Create the "plots" directory if it doesn't exist
  if (!dir.exists(fp)) {
dir.create(fp, recursive = TRUE)
  }

  terra::writeRaster(rast, overwrite = TRUE,
 filename = fp,
 gdal = c("COMPRESS=NONE"))
  message(paste("raster created", fp, sep = ": "), "\n")
}

Error �V

  Error: [writeRaster] cannot write file
   12. �|�wgeohabnet:::.saverast(typ, rast, outdir)
   13.   �u�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, 
gdal = c("COMPRESS=NONE"))
   14.   �|�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, 
gdal = c("COMPRESS=NONE"))
   15. �|�wterra (local) .local(x, filename, ...)
   16.   �|�wterra:::messages(x, "writeRaster")
   17. �|�wterra:::error(f, x@pnt$getError())



Best Regards,
Krishna Keshav

[[alternative HTML version deleted]]


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Duncan Murdoch

What were you using as "outdir"?


On 09/10/2023 2:59 p.m., Keshav, Krishna wrote:

Hi,

I am developing an R package where I need to save Raster file with .tif 
extension to the tempdir(). I am using terra::writeRaster for the same. While 
it works through R CMD check in mac, it is failing in R hub builder.
Snippet �V
.saverast <- function(typ, rast, outdir) {

   if (is.null(outdir) || length(outdir) == 0) {
 outdir <- tempdir()
   }

   # Save the plot as a raster file
   fp <- file.path(outdir, paste("plots", "/",
 typ, "_",
 stringr::str_replace_all(Sys.time(), "[^a-zA-Z0-9]", 
""),
 ".tif", sep = ""))
 # Create the "plots" directory if it doesn't exist
   if (!dir.exists(fp)) {
 dir.create(fp, recursive = TRUE)
   }

   terra::writeRaster(rast, overwrite = TRUE,
  filename = fp,
  gdal = c("COMPRESS=NONE"))
   message(paste("raster created", fp, sep = ": "), "\n")
}

Error �V

   Error: [writeRaster] cannot write file
12. �|�wgeohabnet:::.saverast(typ, rast, outdir)
13.   �u�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, gdal = 
c("COMPRESS=NONE"))
14.   �|�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, gdal = 
c("COMPRESS=NONE"))
15. �|�wterra (local) .local(x, filename, ...)
16.   �|�wterra:::messages(x, "writeRaster")
17. �|�wterra:::error(f, x@pnt$getError())



Best Regards,
Krishna Keshav

[[alternative HTML version deleted]]


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Error: [writeRaster] cannot write file

2023-10-09 Thread Keshav, Krishna
Hi,

I am developing an R package where I need to save Raster file with .tif 
extension to the tempdir(). I am using terra::writeRaster for the same. While 
it works through R CMD check in mac, it is failing in R hub builder.
Snippet �V
.saverast <- function(typ, rast, outdir) {

  if (is.null(outdir) || length(outdir) == 0) {
outdir <- tempdir()
  }

  # Save the plot as a raster file
  fp <- file.path(outdir, paste("plots", "/",
typ, "_",
stringr::str_replace_all(Sys.time(), 
"[^a-zA-Z0-9]", ""),
".tif", sep = ""))
# Create the "plots" directory if it doesn't exist
  if (!dir.exists(fp)) {
dir.create(fp, recursive = TRUE)
  }

  terra::writeRaster(rast, overwrite = TRUE,
 filename = fp,
 gdal = c("COMPRESS=NONE"))
  message(paste("raster created", fp, sep = ": "), "\n")
}

Error �V

  Error: [writeRaster] cannot write file
   12. �|�wgeohabnet:::.saverast(typ, rast, outdir)
   13.   �u�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, 
gdal = c("COMPRESS=NONE"))
   14.   �|�wterra::writeRaster(rast, overwrite = TRUE, filename = fp, 
gdal = c("COMPRESS=NONE"))
   15. �|�wterra (local) .local(x, filename, ...)
   16.   �|�wterra:::messages(x, "writeRaster")
   17. �|�wterra:::error(f, x@pnt$getError())



Best Regards,
Krishna Keshav

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Problem persists, was Re: Problem compressing vignettes for CRAN

2023-10-09 Thread Jeff Newmiller via R-package-devel
R could care less about what is in PATH... there is however a difference 
between Windows parsing PATH and how CMD lets you quote things interactively.

The whole point of PATH is to let you or R provide simple program names like 
qpdf without knowing where they are... Windows takes over and looks up where 
the program actually is based on the contents of PATH. How you get things into 
that environment variable can vary depending on which software you are using 
(CMD and R are two possible options), but the actual content is handled by the 
operating system (which is why PATH on Linux is formatted differently than PATH 
on Windows).

On October 9, 2023 8:22:17 AM PDT, Michael Dewey  
wrote:
>Dear Ivan (and list)
>
>Using Ivan's advice I traced the problem to a difference of opinio between 
>Microsoft and R about paht names. I had mistakenly enclosed parts of the names 
>in "" which was fine for MS but not R. Sys.which() was my saviour here.
>
>Many thanks to Ivan for broadening my knowledge of useful functions like 
>Sys.which().
>
>Michael
>
>On 09/10/2023 08:51, Ivan Krylov wrote:
>> On Sun, 8 Oct 2023 16:47:41 +0100
>> Michael Dewey  wrote:
>> 
>>> Following on from Ivan's advice I have now installed qpdf and
>>> Ghostview. I have checked that they are both on my path by typing
>>> their name at the command line and verifying they open.
>> 
>>> I then built the package with the --compress-vignettes=both and then
>>> checked it with --as-cran I still get a complaint that it needs qpdf
>>> to check compression.
>> 
>> While running R, does Sys.which('qpdf') return the path to qpdf.exe?
>> Does Sys.getenv('PATH') match your expectations?
>> 
>>> I notice that in the Writing R Extensions manual in section 1.6.1 it
>>> states "The full path to the qpdf command can be supplied as
>>> environment variable R_QPDF ..."
>>> 
>>> Is that a typo for "must be supplied"?
>> 
>> Well, R tries to resolve the path to qpdf.exe using Sys.which(), so it
>> must work if it's on the %PATH%, but if all else fails, setting this
>> environment variable should help.
>> 
>>> If it is where can I find the answers to questions about how R
>>> accepts Windows paths? Do I need to enclose parts of names containing
>>> spaces in "" signs?
>> 
>> It always depends on how the final command line is built by a
>> particular function, but it should work by taking plain file paths
>> without any escaping and quotation. The directory separators shouldn't
>> matter either.
>> 
>> (tools::compactPDF uses system2(), so it quotes the path to the
>> executable by itself.)
>> 
>>> Does it mean the path up to, in this case, bin or must I include
>>> qpdf.exe after it?
>> 
>> It must be the full path to the executable, including the final
>> qpdf.exe.
>> 
>>> I assume I do not need to do anything special to get it to find
>>> Ghostscript?
>> 
>> tools::compactPDF() expects gswin64c.exe or gswin32c.exe on the PATH.
>> If it's not there, R_GSCMD must be set to the full path to the
>> executable. Judging by the NOTE you've received, it's Ghostscript that
>> performed most of the compaction in your case.
>> 
>

-- 
Sent from my phone. Please excuse my brevity.

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Problem persists, was Re: Problem compressing vignettes for CRAN

2023-10-09 Thread Michael Dewey

Dear Ivan (and list)

Using Ivan's advice I traced the problem to a difference of opinio 
between Microsoft and R about paht names. I had mistakenly enclosed 
parts of the names in "" which was fine for MS but not R. Sys.which() 
was my saviour here.


Many thanks to Ivan for broadening my knowledge of useful functions like 
Sys.which().


Michael

On 09/10/2023 08:51, Ivan Krylov wrote:

On Sun, 8 Oct 2023 16:47:41 +0100
Michael Dewey  wrote:


Following on from Ivan's advice I have now installed qpdf and
Ghostview. I have checked that they are both on my path by typing
their name at the command line and verifying they open.



I then built the package with the --compress-vignettes=both and then
checked it with --as-cran I still get a complaint that it needs qpdf
to check compression.


While running R, does Sys.which('qpdf') return the path to qpdf.exe?
Does Sys.getenv('PATH') match your expectations?


I notice that in the Writing R Extensions manual in section 1.6.1 it
states "The full path to the qpdf command can be supplied as
environment variable R_QPDF ..."

Is that a typo for "must be supplied"?


Well, R tries to resolve the path to qpdf.exe using Sys.which(), so it
must work if it's on the %PATH%, but if all else fails, setting this
environment variable should help.


If it is where can I find the answers to questions about how R
accepts Windows paths? Do I need to enclose parts of names containing
spaces in "" signs?


It always depends on how the final command line is built by a
particular function, but it should work by taking plain file paths
without any escaping and quotation. The directory separators shouldn't
matter either.

(tools::compactPDF uses system2(), so it quotes the path to the
executable by itself.)


Does it mean the path up to, in this case, bin or must I include
qpdf.exe after it?


It must be the full path to the executable, including the final
qpdf.exe.


I assume I do not need to do anything special to get it to find
Ghostscript?


tools::compactPDF() expects gswin64c.exe or gswin32c.exe on the PATH.
If it's not there, R_GSCMD must be set to the full path to the
executable. Judging by the NOTE you've received, it's Ghostscript that
performed most of the compaction in your case.



--
Michael

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Note: no function found corresponding to methods exports for show

2023-10-09 Thread Mikael Jagan




On 2023-10-08 5:43 pm, Mikael Jagan wrote:

Hi,

I recently submitted my first R package to CRAN, and I encountered a NOTE
during the checking process. The NOTE looks like this:

=
Flavor: r-devel-linux-x86_64-debian-gcc, r-devel-windows-x86_64
Check: whether the namespace can be loaded with stated dependencies,
Result: NOTE
Warning: no function found corresponding to methods exports from 'hmsr'
for: 'show'

A namespace must be able to be loaded with just the base namespace
loaded: otherwise if the namespace gets loaded by a saved object, the
session will be unable to start.

Probably some imports need to be declared in the NAMESPACE file.


Sounds like your NAMESPACE is missing importFrom(methods, show) ... ?
I'm not sure why you could not reproduce the problem locally, given that
check uses _R_CHECK_CODE_USAGE_WITH_ONLY_BASE_ATTACHED_=true by default.


Reading tools:::.check_packages I see that this environment variable is
not relevant to this particular test.  Still, do import generic functions
for which you define methods, from all packages != "base".

Mikael


But it is hard to say anything without a link to the package sources ...

Mikael


=

I'm seeking help to understand and address this issue. show is defined like
this:

#' Show method for class "hms".#'#' @param object - hms s4 object#'#'
@return It returns the names of the slots and the classes associated
with the#' slots in the "hms" class. It prints call details.#'#'
@export#'#' @examples
#' f <- function(x) x
#' result <- hms(fitness = f, lower = -5, upper = 5)
#' show(result)
setMethod("show", "hms", function(object) {
cat("An object of class \"hms\"\n")
cat("\nCall:\n", deparse(object@call), "\n\n", sep = "")
cat("Available slots:\n")
print(methods::slotNames(object))})

And in the NAMESPACE there is a line that looks like this:

exportMethods(show)

I was investigating if the show is defined correctly and the GA package has
a very similar method:

setMethod("show", "ga",function(object)
   { cat("An object of class \"ga\"\n")
 cat("\nCall:\n", deparse(object@call), "\n\n",sep="")
 cat("Available slots:\n")
 print(slotNames(object))})

I could not reproduce this NOTE on my personal machine with Windows.
On Mac OS I have never experienced this NOTE.


Best regards

Wojciech Achtelik


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Problem persists, was Re: Problem compressing vignettes for CRAN

2023-10-09 Thread Ivan Krylov
On Sun, 8 Oct 2023 16:47:41 +0100
Michael Dewey  wrote:

> Following on from Ivan's advice I have now installed qpdf and
> Ghostview. I have checked that they are both on my path by typing
> their name at the command line and verifying they open.

> I then built the package with the --compress-vignettes=both and then
> checked it with --as-cran I still get a complaint that it needs qpdf
> to check compression.

While running R, does Sys.which('qpdf') return the path to qpdf.exe?
Does Sys.getenv('PATH') match your expectations?

> I notice that in the Writing R Extensions manual in section 1.6.1 it
> states "The full path to the qpdf command can be supplied as
> environment variable R_QPDF ..."
> 
> Is that a typo for "must be supplied"?

Well, R tries to resolve the path to qpdf.exe using Sys.which(), so it
must work if it's on the %PATH%, but if all else fails, setting this
environment variable should help.

> If it is where can I find the answers to questions about how R
> accepts Windows paths? Do I need to enclose parts of names containing
> spaces in "" signs?

It always depends on how the final command line is built by a
particular function, but it should work by taking plain file paths
without any escaping and quotation. The directory separators shouldn't
matter either.

(tools::compactPDF uses system2(), so it quotes the path to the
executable by itself.)

> Does it mean the path up to, in this case, bin or must I include
> qpdf.exe after it?

It must be the full path to the executable, including the final
qpdf.exe.

> I assume I do not need to do anything special to get it to find
> Ghostscript?

tools::compactPDF() expects gswin64c.exe or gswin32c.exe on the PATH.
If it's not there, R_GSCMD must be set to the full path to the
executable. Judging by the NOTE you've received, it's Ghostscript that
performed most of the compaction in your case.

-- 
Best regards,
Ivan

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] CXX_VISIBILITY on macOS

2023-10-09 Thread Matthias Gondan
You found the problem, thanks!



Matthias,

this has nothing to do with R, but rather your code. You have the wrong order 
of headers: the SWI headers mess up visibility macros, so you have to include 
them *after* Rcpp.h.

Cheers,
Simon


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel