Skip to content

[R-pkg-devel] Submitting to CRAN a package depending on RGtk2

11 messages · Dirk Eddelbuettel, Lorenzo Busetto, Duncan Murdoch

#
Dear all, I am currently in the process of releasing this github
package on CRAN:

   https://github.com/lbusett/MODIStsp

   , but I am encountering some issues which I hope someone can help
me overcome. Sorry for the long message, but the problem is  difficult
to explain briefly.  Also, since this is my first CRAN release
attempt, please excuse me if I'm asking something obvious.

   The problem I'm having derives from the fact that I'm using package
`gWidgetsRGtk2` to create a GUI. However, `gWidgetsRGtk2` depends on
package `RGtk2`, which itself requires some external libraries to
work.

This leads to the following problems:

On Windows

   If I keep `gWidgetsRGtk2` in the dependency list of my package,
checking it in RStudio goes well. I get no NOTES nor WARNINGS
(provided I have all dependencies installed).
Also `build_win` passes with no problems

 However, if I then try to install the package from github, and even
if `gWidgetsRGtk2` is already installed in my library, installation
fails.  For example:

    devtools::install_github("lbusett/MODIStsp", ref =
'feature/cran_rel_candidate')

 gives me the following error:
, and I get an information window telling me that "libaptk-1.0-0.dll"
is missing.

Pressing "ok" on the message sends me in an infinite loop of attempted
installations of `RGTk2` and I have to force-close RStudio.

The only way I managed to install the package correctly from github is by:

1)  Removing the `gWidgetsRGtk2` dependency from my package, and

2)  Asking users to install `gWidgetsRGtk2` beforehand and load it at
least once. At first loading of that package,  after the
"libaptk-1.0-0.dll is missing" message, this info panel opens,
allowing me to install GTK+ libraries. After installing, continuing my
pakages' installation goes well

So, for example, this:

    install.packages("gWidgetsRGtk2")
    library("gWidgetsRGtk2")
    # wait for install of GTK+
    install_github("lbusett/MODIStsp", ref = 'devel')   # (In devel,
'gWidgetsRGtk2'is not a dependency)

works with no issues.

Asking the user to install the ""offending package beforehand is no
big deal, but I don't know if that is admissible for a CRAN package,
also because checking the package after removing the dependency gives
me the following warning:
So, in the end my question is:

Do you know if there is a way to solve this problem, or how should I
deal with it in the process of making a CRAN release ?


On Linux


  On Linux builds, the problem is related but a bit different.

 1. First of all, package "RGTk2" requires some external libraries to
be installed beforehand (Cairo >= 1.0.0, ATK >= 1.10.0, Pango >=
1.10.0, GTK+ >= 2.8.0, GLib >= 2.8.0). Also, for my package to work  I
need to have "gdal" installed on the target PC with hdf4 support.

Setting the following YAML file allows me to pass the checks on
TRAVIS-CI (https://travis-ci.org/lbusett/MODIStsp/builds/168603035):
however, what I don't know is if/how/where I should specify these kind
of dependencies for CRAN submission
. Can anyone explain this to me, or point me to some reference ?


2. The second problem is again related to `gWidgetsRGtk2` dependency.

If I keep the dependency in, the build fails with this message
(https://travis-ci.org/lbusett/MODIStsp/builds/168600394):
As in the Windows case, the problem disappears if I remove the
`gWidgetsRGtk2` dependency, ....but then I get the WARNING in
build/installation.   I don't hink however that it's the same problem:
here it seems that the fail depends on the fact that x11 is not
running on the "TRAVIS" machine (sorry if I don't make sense here, but
I am quite a TRAVIS/Linux newby..)

So, in the end, also in this case:  Can anyone suggest a way to solve
this before I start the submission process ?

Thanks in advance for any help ! (And thanks for bearing with me up to
the end of this novel.... )
#
For this subproblem:
On 19 October 2016 at 22:14, Lorenzo Busetto wrote:
|   On Linux builds, the problem is related but a bit different.
| 
|  1. First of all, package "RGTk2" requires some external libraries to

yu can just install r-cran-rgtk2 on your (Debian or Ubuntu) system and you
should be good.

Dirk
#
Hi Dirk,

thanks for the answer. Yes, I know that that does the trick. In fact,
in our  github README we have
the following intructions:

"Install the following required dependencies:

Cairo >= 1.0.0, ATK >= 1.10.0, Pango >= 1.10.0, GTK+ >= 2.8.0, GLib >=
2.8.0 (required by package RGtk2)
Curl (required by package curl)
GDAL >= 1.6.3, PROJ.4 >= 4.4.9 (required by package rgdal)

On Debian and Ubuntu-based systems, to install those packages open a
terminal and type

sudo apt-get install r-cran-cairodevice r-cran-rgtk2
libcurl4-openssl-dev libgdal-dev libproj-dev  "

One of my questions here (maybe dumb), is how/where I should  specify
those dependencies when submitting to CRAN.
Is putting intructions like these in the readme of the package
sufficient, or do I need to do something else ? That's what I was
asking as first point of the "Linux" part of the previous post (sorry
if it was not clear).

Lorenzo
On 19 October 2016 at 22:36, Dirk Eddelbuettel <edd at debian.org> wrote:
#
On 19 October 2016 at 23:24, Lorenzo Busetto wrote:
| thanks for the answer. Yes, I know that that does the trick. In fact,
| in our  github README we have
| the following intructions:
| 
| "Install the following required dependencies:
| 
| Cairo >= 1.0.0, ATK >= 1.10.0, Pango >= 1.10.0, GTK+ >= 2.8.0, GLib >=
| 2.8.0 (required by package RGtk2)
| Curl (required by package curl)
| GDAL >= 1.6.3, PROJ.4 >= 4.4.9 (required by package rgdal)
| 
| On Debian and Ubuntu-based systems, to install those packages open a
| terminal and type
| 
| sudo apt-get install r-cran-cairodevice r-cran-rgtk2
| libcurl4-openssl-dev libgdal-dev libproj-dev  "

That's pretty good for the README. And yes, you need those -dev package for gdal.
 
| One of my questions here (maybe dumb), is how/where I should  specify
| those dependencies when submitting to CRAN.
| Is putting intructions like these in the readme of the package
| sufficient, or do I need to do something else ? That's what I was
| asking as first point of the "Linux" part of the previous post (sorry
| if it was not clear).

The 'SystemRequirements:' field in DESCRIPTION is the usual spot.

You can then test in a script 'configure' (which can be a shell script) to
see if the packages are installed / useable / survive a test compilation.
Jeroen has a scheme for that in a few of his recent package; but his dislike
of autoconf makes that a little over the top.  Maybe you can just rely on
pkg-config to do most of the work for you? Ie a la

  edd at max:~$ pkg-config --exists gdal && echo "Yes"
  Yes
  edd at max:~$ pkg-config --modversion gdal
  1.11.3
  edd at max:~$


Dirk
#
On 19/10/2016 5:24 PM, Lorenzo Busetto wrote:
In your DESCRIPTION file, skip the indirect dependencies.  Your package 
just needs to say it depends on RGtk2, curl, and rgdal (unless it also 
needs to link to those libs).  It is a good idea to give detailed 
instructions in a README file in the package though.
As Dirk said, SystemRequirements:, but only for the direct dependencies. 
  List the R packages in Depends, Imports, etc.
Try to give instructions for all 3 major platforms (and maybe a few 
variations within each):  Linux, Windows, OS X. If you can, add Solaris: 
  once you're accepted onto CRAN, you'll be tested there as well.

Duncan Murdoch
#
Hi Duncan and Dirk,

1)  First of all, thanks for your replies
?:
?y?
ou put me in the right direction. Although I have to study a bit to really
get the "syntax", looking into Jeroen github pages I was able to understand
?how the "configure" file is supposed to work. In practice, it is run while
attempting package install and allows detecting if required libraries are
available and suggests to install them otherwise, right ?

 I have to say that this is the only part where Hadley Wickham's excellent
"R packages" web page failed me a bit. Also, the "Configure and cleanup"
section of CRAN's "Writing extensions" manual isn't (overly) helpful for a
newby ;-)
? ?
)
(Note that this is don't meant to criticize - just to report a possible
issue others may also encounter).

I also have a (maybe stupid) question on this: in theory, I could write
this "configuration check" also as a "R" function which sends out "system"
commands if it detects a Linux environment (configuring the commands on the
basis of the detected distro), and call it if/when a function of my package
needing that library is called so that the user is prompted to fix his/her
configuration.
Would that be a "bad practice" ?

2) On a different topic related to my original post. Yesterday, I was
?(?
?hopefully)?
 able to solve the issue regarding
?"?
gWidgetsRGtk
?"?
installation on Windows by using the "pacman" package to avoid calls to
"requireNamespace".

In practice, in my "main" function (MODIStsp.R) *where before I had*:





* # On interactive execution, load Rgtk2  if (gui) {   # "gui" is a flag
specifying if we are running an "interactive" session
requireNamespace("gWidgetsRGtk2")    options("guiToolkit" = "RGtk2")  }*

*now I have:??*




















*if (gui) { # "gui" is a flag specifying if we are running an "interactive"
session     # Use p_exists to check if gWidgetsRGtk2 is installed    if
(!pacman::p_exists("gWidgetsRGtk2", local = TRUE)) {          # If not, ask
user to install it      message("Library 'gWidgetsRgtk2' is not installed.
It is required to run MODIStsp !               Do you want to install it
now ?", type = " y/n")      inst_gw <- readline()      if (inst_gw =="y") {
# If user selects "y", use "p_load" to install the package
pacman::p_load("gWidgetsRGtk2")      } else {       # If user selects "n",
send message and exit.              stop("MODIStsp can not work withouth
gWidgetsRGtk2 ! Exiting !")      }           }    options("guiToolkit" =
"RGtk2")  }*

In this way, I can:

1)
?R?
emove
??
gWidgetsRgtk2 from my dependencies, so that I get no WARNINGS while
checking the package
2)
?A?
void the problems related to GTK+ library installation that where
preventing install_github to complete properly
? if I had ?gWidgetsRgtk2 as a dependency?
.

I checked this both on Windows and Linux, and it works.

Although I know that this is a bit of hack, could this be a "viable"
solution ?


regards,

Lorenzo

On 20 October 2016 at 00:06, Duncan Murdoch <murdoch.duncan at gmail.com>
wrote:

  
  
#
Lorenzo,

Your mails are too long (at least for my attention span, and available time)
and very poorly formatted. Many of us read email in text-only terminals.
On 20 October 2016 at 11:05, Lorenzo Busetto wrote:
| I also have a (maybe stupid) question on this: in theory, I could write
| this "configuration check" also as a "R" function which sends out "system"
| commands if it detects a Linux environment (configuring the commands on the

No, just use

   Sys.info()[["sysname"]]

and see `help(Sys.info()`.  R can tell you a lot about the environment.

Dirk
#
Ok. Duly noted. I'll  be more concise and avoid even simple formatting
(seems italics broke my last post to pieces). I'll try again.

My main problem is that, if I have "gWidgetRGtk2" as an imported package,
installation on Windows from github crashes RStudio while trying to install
GTK+ libraries (although I have no ERRORS nor WARNINGS in R CMD check).

If I remove the dependency and ask users to install  "gWidgetsRGtk2"
beforehand (which doesn't crash) I obviously get this WARNING:
'requireNamespace' call not declared from: ?gWidgetsRGtk2?

I found out I can avoid both problems  using the "pacman" package in my
Main:
{pacman::p_load("gWidgetsRGtk2")}

In this way,  ?gWidgetsRGtk2? is  installed only at first execution of my
Main, and I'm up and running.

Is this a viable solution (clearly, provided I ask permission to the user
before installing with p_load)   ?

Thanks in advance,

Lorenzo

PS: better ?
On 20 October 2016 at 15:34, Dirk Eddelbuettel <edd at debian.org> wrote:

            

  
  
#
On 20/10/2016 4:14 PM, Lorenzo Busetto wrote:
No, it wouldn't be acceptable on CRAN.  You need to declare your 
dependencies.

It sounds as though there's a bug somewhere, in R, RStudio, 
gWidgetRGtk2, or Windows.  You're in the unenviable position of having 
to find and fix it.  (CRAN won't care if this only affects RStudio, and 
you might get away with an install that doesn't support Windows.)

Duncan Murdoch
#
On 20 October 2016 at 18:59, Duncan Murdoch wrote:
| No, it wouldn't be acceptable on CRAN.  You need to declare your 
| dependencies.
| 
| It sounds as though there's a bug somewhere, in R, RStudio, 
| gWidgetRGtk2, or Windows.  You're in the unenviable position of having 
| to find and fix it.  (CRAN won't care if this only affects RStudio, and 
| you might get away with an install that doesn't support Windows.)

I usually suspect threading, which is tricky / impossible to fix.  RStudio
needs it (as it is a GUI), and so does RGtk2.  IIRC we have had similar
issues with tcltk as well as with some of task parallelizers.

Dirk
1 day later
#
After digging some more: the problem is related to installation of RGtk2,
and in particular on failing to load RGtk2.ddl . Looking at build logs, I
get this error (which is repeated N times until install crashes):
'C:/Users/LB_laptop/AppData/Local/Temp/RtmpO6FfXa/RLIBS_d981e3e76b6/RGtk2/libs/i386/RGtk2.dll':
http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip
and that it is on your PATH environment variable
'C:/Users/LB_laptop/AppData/Local/Temp/RtmpO6FfXa/RLIBS_d981e3e76b6/RGtk2/libs/i386/RGtk2.dll':
The baffling thing is that I have this error if I do the check on my
machine or from github, while sending to CRAN with build_win succeds (see
log at the bottom). My understanding is that on CRAN testing machines GTK+
is already present/configured, so that the library doesn't need to be
installed/found ( However,  trying to install GTK+ beforehand and setting
the PATH variable as suggested in the error message doesn't change anything)

Looking at other packages with the same dependencies shows that this is  a
common issue: for example, package "fit4NM" installs correctly from CRAN,
but if I download it on my machine and check from RStudio,  R CMD check
fails in the same way.

A workaround I found looking at other packages and allows me to keep both
RStudio and build_win  working is to keep gWidgetsRGtk2 as a "Suggested"
package instead than as an Import, and ask users to install at first
"interactive" execution.

So, if I may ask, would you have any suggestions in this case ?

Lorenzo


------ build_win LOG follows () -------

* using log directory 'd:/RCompile/CRANguest/R-devel/MODIStsp.Rcheck'
* using R Under development (unstable) (2016-10-22 r71558)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'MODIStsp/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'MODIStsp' version '1.2.2'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Lorenzo Busetto <busetto.l at irea.cnr.it>'

New submission

Possibly mis-spelled words in DESCRIPTION:
  HDF (14:27)
  MODIS (3:19, 10:84, 12:19, 14:21, 15:64, 20:64)
  Preprocessing (2:48)
  Reflectance (16:21)
  mosaicking (11:73)
  preprocessing (11:35)
  rasters (10:63)
  reflectance (16:103)
  reprojection (11:85)
  resize (12:9)

Found the following (possibly) invalid URLs:
  URL: http://cran.r-project.org
    From: README.md
    Status: 200
    Message: OK
    CRAN URL not in canonical form
  A canonical CRAN URL starts with https://CRAN.R-project.org/

The Date field is over a month old.
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for hidden files and directories ... NOTE
Found the following hidden files and directories:
  .json
These were most likely included in error. See section 'Package
structure' in the 'Writing R Extensions' manual.

CRAN-pack does not know about
  .json
* checking for portable file names ... OK
* checking whether package 'MODIStsp' can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking 'build' directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... NOTE
Non-standard file/directory found at top level:
  'try_configure_'
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* loading checks for arch 'i386'
** checking whether the package can be loaded ... OK
** checking whether the package can be loaded with stated dependencies ... OK
** checking whether the package can be unloaded cleanly ... OK
** checking whether the namespace can be loaded with stated dependencies ... OK
** checking whether the namespace can be unloaded cleanly ... OK
** checking loading without being on the library search path ... OK
** checking use of S3 registration ... OK
* loading checks for arch 'x64'
** checking whether the package can be loaded ... OK
** checking whether the package can be loaded with stated dependencies ... OK
** checking whether the package can be unloaded cleanly ... OK
** checking whether the namespace can be loaded with stated dependencies ... OK
** checking whether the namespace can be unloaded cleanly ... OK
** checking loading without being on the library search path ... OK
** checking use of S3 registration ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking sizes of PDF files under 'inst/doc' ... WARNING
  'gs+qpdf' made some significant size reductions:
     compacted 'MODIStsp.pdf' from 690Kb to 366Kb
  consider running tools::compactPDF(gs_quality = "ebook") on these files
* checking installed files from 'inst/doc' ... OK
* checking files in 'vignettes' ... OK
* checking examples ...
** running examples for arch 'i386' ... [3s] OK
** running examples for arch 'x64' ... [3s] OK
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in 'inst/doc' ... OK
* checking re-building of vignette outputs ... [26s] OK
* checking PDF version of manual ... OK
* DONE
Status: 1 WARNING, 3 NOTEs
On 21 October 2016 at 02:22, Dirk Eddelbuettel <edd at debian.org> wrote: