Skip to content

R pkg install should fail for unsuccessful DLL copy on windows?

5 messages · Jan Gorecki, Hervé Pagès, Toby Hocking

#
Hi all,

I am having an issue related to installing packages on windows with
R-3.6.0. When installing a package that is in use, I expected R to stop
with an error. However I am getting a warning that the DLL copy was not
successful, but the overall package installation IS successful. This is
quite dangerous because the old DLL and the new R code could be
incompatible.

I am definitely not the first person to have this issue.
* Matt Dowle reported
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478 which was never
addressed.
* Jim Hester reported
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17453 which was
apparently addressed in R-3.5.1, via
https://github.com/wch/r-source/commit/828a04f9c428403e476620b1905a1d8ca41d0bcd

But I am now having the same issue in R-3.6.0 -- is this a regression in R?
or is there another fix that I can use?

Below is the minimal R code that I used to reproduce the issue. Essentially,
* I start R with --vanilla and set options repos=cloud and warn=2 (which I
expect should convert warnings to errors).
* I do library(penaltyLearning) and then install the package from source,
which results in the
  warnings. I expected there should be an error.

th798 at cmp2986 MINGW64 ~/R
$ R --vanilla -e "options(repos='https://cloud.r-project.org',
warn=2);library(penaltyLearning);install.packages('penaltyLearning',
type='source');getOption('warn');sessionInfo()"

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
warn=2);library(penaltyLearning);install.packages('penaltyLearning',
type='source');getOption('warn');sessionInfo()
Loading required package: data.table
Registered S3 methods overwritten by 'ggplot2':
  method         from
  [.quosures     rlang
  c.quosures     rlang
  print.quosures rlang
trying URL '
https://cloud.r-project.org/src/contrib/penaltyLearning_2018.09.04.tar.gz'
Content type 'application/x-gzip' length 2837289 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package 'penaltyLearning' ...
** package 'penaltyLearning' successfully unpacked and MD5 sums checked
** using staged installation
** libs
c:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include"
-DNDEBUG          -O2 -Wall  -mtune=generic -c interface.cpp -o interface.o
c:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include"
-DNDEBUG          -O2 -Wall  -mtune=generic -c largestContinuousMinimum.cpp
-o largestContinuousMinimum.o
largestContinuousMinimum.cpp: In function 'int
largestContinuousMinimum(int, double*, double*, int*)':
largestContinuousMinimum.cpp:38:27: warning: 'start' may be used
uninitialized in this function [-Wmaybe-uninitialized]
       index_vec[0] = start;
                           ^
c:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include"
-DNDEBUG          -O2 -Wall  -mtune=generic -c modelSelection.cpp -o
modelSelection.o
/usr/bin/sed: -e expression #1, char 1: unknown command: `C'
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o penaltyLearning.dll
tmp.def interface.o largestContinuousMinimum.o modelSelection.o
-LC:/PROGRA~1/R/R-36~1.0/bin/x64 -lR
installing to C:/Program
Files/R/R-3.6.0/library/00LOCK-penaltyLearning/00new/penaltyLearning/libs/x64
** R
** data
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'penaltyLearning'
    finding HTML links ... done
    GeomTallRect                            html
    IntervalRegressionCV                    html
    IntervalRegressionCVmargin              html
    IntervalRegressionInternal              html
    IntervalRegressionRegularized           html
    IntervalRegressionUnregularized         html
    ROChange                                html
    change.colors                           html
    change.labels                           html
    changeLabel                             html
    check_features_targets                  html
    check_target_pred                       html
    coef.IntervalRegression                 html
    demo8                                   html
    featureMatrix                           html
    featureVector                           html
    geom_tallrect                           html
    labelError                              html
    largestContinuousMinimumC               html
    largestContinuousMinimumR               html
    modelSelection                          html
    modelSelectionC                         html
    modelSelectionR                         html
    neuroblastomaProcessed                  html
    oneSkip                                 html
    plot.IntervalRegression                 html
    predict.IntervalRegression              html
    print.IntervalRegression                html
    squared.hinge                           html
    targetIntervalROC                       html
    targetIntervalResidual                  html
    targetIntervals                         html
    theme_no_space                          html
** building package indices
** testing if installed package can be loaded from temporary location
WARNING: moving package to final location failed, copying instead
Warning in file.copy(instdir, dirname(final_instdir), recursive = TRUE,  :
  problem copying C:\Program
Files\R\R-3.6.0\library\00LOCK-penaltyLearning\00new\penaltyLearning\libs\x64\penaltyLearning.dll
to C:\Program
Files\R\R-3.6.0\library\penaltyLearning\libs\x64\penaltyLearning.dll:
Permission denied
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation
path
* DONE (penaltyLearning)

The downloaded source packages are in
'C:\Users\th798\AppData\Local\Temp\RtmpUrOoFE\downloaded_packages'
[1] 2
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] penaltyLearning_2018.09.04 data.table_1.12.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       assertthat_0.2.1 dplyr_0.8.1      crayon_1.3.4
 [5] R6_2.4.0         grid_3.6.0       plyr_1.8.4       magic_1.5-9
 [9] gtable_0.3.0     magrittr_1.5     scales_1.0.0     ggplot2_3.1.1
[13] pillar_1.4.0     rlang_0.3.4      lazyeval_0.2.2   geometry_0.4.1
[17] tools_3.6.0      glue_1.3.1       purrr_0.3.2      munsell_0.5.0
[21] abind_1.4-7      compiler_3.6.0   pkgconfig_2.0.2  colorspace_1.4-1
[25] tidyselect_0.2.5 tibble_2.1.1
]0;MINGW64:/c/Users/th798/R
th798 at cmp2986 MINGW64 ~/R
$

related blog post: https://tdhock.github.io/blog/2019/windows-dll/
#
Hi Toby,
AFAIK it has not been addressed in R. You can handle the problem on
your package side, see
https://github.com/Rdatatable/data.table/pull/3237
Regards,
Jan
On Thu, May 30, 2019 at 4:46 AM Toby Hocking <tdhock5 at gmail.com> wrote:
#
thanks for the tip Jan.

However it would be nice if I didn't have to handle this myself for all of
my packages. (and teach my students how to do that)

BTW I tried to disable staged installation, and the issue still happens:

th798 at cmp2986 MINGW64 ~/projects/max-generalized-auc (master)
$ R_INSTALL_STAGED=FALSE R --vanilla -e
".libPaths('~/R/library');.libPaths();options(repos='
https://cloud.r-project.org',
warn=2);library(penaltyLearning);install.packages('penaltyLearning',
type='source');getOption('warn');sessionInfo()"

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
https://cloud.r-project.org',
warn=2);library(penaltyLearning);install.packages('penaltyLearning',
type='source');getOption('warn');sessionInfo()
[1] "C:/Users/th798/R/library"           "C:/Program
Files/R/R-3.6.0/library"
Loading required package: data.table
Registered S3 methods overwritten by 'ggplot2':
  method         from
  [.quosures     rlang
  c.quosures     rlang
  print.quosures rlang
Installing package into 'C:/Users/th798/R/library'
(as 'lib' is unspecified)
trying URL '
https://cloud.r-project.org/src/contrib/penaltyLearning_2018.09.04.tar.gz'
Content type 'application/x-gzip' length 2837289 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package 'penaltyLearning' ...
** package 'penaltyLearning' successfully unpacked and MD5 sums checked
** using non-staged installation
** libs
c:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include"
-DNDEBUG          -O2 -Wall  -mtune=generic -c interface.cpp -o interface.o
c:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include"
-DNDEBUG          -O2 -Wall  -mtune=generic -c largestContinuousMinimum.cpp
-o largestContinuousMinimum.o
largestContinuousMinimum.cpp: In function 'int
largestContinuousMinimum(int, double*, double*, int*)':
largestContinuousMinimum.cpp:38:27: warning: 'start' may be used
uninitialized in this function [-Wmaybe-uninitialized]
       index_vec[0] = start;
                           ^
c:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.0/include"
-DNDEBUG          -O2 -Wall  -mtune=generic -c modelSelection.cpp -o
modelSelection.o
/usr/bin/sed: -e expression #1, char 1: unknown command: `C'
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o penaltyLearning.dll
tmp.def interface.o largestContinuousMinimum.o modelSelection.o
-LC:/PROGRA~1/R/R-36~1.0/bin/x64 -lR
installing to C:/Users/th798/R/library/penaltyLearning/libs/x64
Warning in file.copy(files, dest, overwrite = TRUE) :
  problem copying .\penaltyLearning.dll to
C:\Users\th798\R\library\penaltyLearning\libs\x64\penaltyLearning.dll:
Permission denied
** R
** data
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'penaltyLearning'
    finding HTML links ... done
    GeomTallRect                            html
    IntervalRegressionCV                    html
    IntervalRegressionCVmargin              html
    IntervalRegressionInternal              html
    IntervalRegressionRegularized           html
    IntervalRegressionUnregularized         html
    ROChange                                html
    change.colors                           html
    change.labels                           html
    changeLabel                             html
    check_features_targets                  html
    check_target_pred                       html
    coef.IntervalRegression                 html
    demo8                                   html
    featureMatrix                           html
    featureVector                           html
    geom_tallrect                           html
    labelError                              html
    largestContinuousMinimumC               html
    largestContinuousMinimumR               html
    modelSelection                          html
    modelSelectionC                         html
    modelSelectionR                         html
    neuroblastomaProcessed                  html
    oneSkip                                 html
    plot.IntervalRegression                 html
    predict.IntervalRegression              html
    print.IntervalRegression                html
    squared.hinge                           html
    targetIntervalROC                       html
    targetIntervalResidual                  html
    targetIntervals                         html
    theme_no_space                          html
** building package indices
** testing if installed package can be loaded
* DONE (penaltyLearning)

The downloaded source packages are in
'C:\Users\th798\AppData\Local\Temp\RtmpkVV0sH\downloaded_packages'
[1] 2
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] penaltyLearning_2018.09.04 data.table_1.12.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       assertthat_0.2.1 dplyr_0.8.1      crayon_1.3.4
 [5] R6_2.4.0         grid_3.6.0       plyr_1.8.4       magic_1.5-9
 [9] gtable_0.3.0     magrittr_1.5     scales_1.0.0     ggplot2_3.1.1
[13] pillar_1.4.0     rlang_0.3.4      lazyeval_0.2.2   geometry_0.4.1
[17] tools_3.6.0      glue_1.3.1       purrr_0.3.2      munsell_0.5.0
[21] abind_1.4-7      compiler_3.6.0   pkgconfig_2.0.2  colorspace_1.4-1
[25] tidyselect_0.2.5 tibble_2.1.1
]0;MINGW64:/c/Users/th798/projects/max-generalized-auc
th798 at cmp2986 MINGW64 ~/projects/max-generalized-auc (master)
$
On Wed, May 29, 2019 at 8:15 PM Jan Gorecki <j.gorecki at wit.edu.pl> wrote:

            

  
  
#
Also note that this can lead to people not being able to load the
package if the set of .Call entry points has changed between the old
and new versions of the package. We strongly suspect that this is what
happened to this Bioconductor user:

   https://support.bioconductor.org/p/121228/

Note that she's installing the binary and in this case no warning
is issued. All we see is:

   package ?S4Vectors? successfully unpacked and MD5 sums checked

but the old DLL apparently didn't get replaced with the new one.
Hence the

   error: "make_RAW_from_NA_LLINT" not available for .Call() for package 
"S4Vectors"

later on when trying to load the package.

Cheers,
H.
On 5/30/19 16:31, Toby Hocking wrote:

  
    
#
thanks for your input Herv?. Glad to hear I'm not the only one still having
this issue.

In my opinion install.packages should stop with an error (instead of a
warning) if this happens.

However even if you want to keep the warning, at least make it so that
users can set options(warn=2) to get an error if they want one. I tried
setting options(warn=2) but for some reason I still get a warning.

I believe that is a bug in install.packages -- if I specify options(warn=2)
it should convert that warning to an error (but it currently does not).

Toby
On Thu, May 30, 2019 at 4:50 PM Pages, Herve <hpages at fredhutch.org> wrote: