0

Consider the scenario below. Adding package 'RMySQL' in R2.14.0

> install.packages('RMySQL',type='source')


* installing *source* package 'RMySQL' ...
** package 'RMySQL' successfully unpacked and MD5 sums checked
**checking for $MYSQL_HOME... C:/wampp/mysql/**

gcc  -I"G:/PROGRA~1/R/R-214~1.0/include" -I"C:/wampp/mysql/"/include    -I"d:/RCompile/CRANpkg/extralibs/local/include"     -O3 -Wall  -std=gnu99 -mtune=core2 -c RS-DBI.c -o RS-DBI.o
gcc  -I"G:/PROGRA~1/R/R-214~1.0/include" -I"C:/wampp/mysql/"/include    -I"d:/RCompile/CRANpkg/extralibs/local/include"     -O3 -Wall  -std=gnu99 -mtune=core2 -c RS-MySQL.c -o RS-MySQL.o
gcc -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o -Ld:/RCompile/CRANpkg/extralibs/local/lib C:/wampp/mysql//lib/opt/libmysql.lib -LG:/PROGRA~1/R/R-214~1.0/bin/i386 -lR
installing to G:/Program Files/R/R-2.14.0/library/RMySQL/libs/i386
** R
** inst
** preparing package for lazy loading
Creating a generic function for 'format' from package 'base' in package 'RMySQL'
Creating a generic function for 'print' from package 'base' in package 'RMySQL'
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'RMySQL', details:
  call: i$Location
  error: $ operator is invalid for atomic vectors
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'G:/Program Files/R/R-2.14.0/library/RMySQL'

Any ideas or explanation for the failed installation? Platform details:

  1. Win XP
  2. R2.14.0
  3. RMySQL_0.9-3.tar.gz
  4. MySQL from latest xampp installation with lib and header files in respective directories under mysql_home directory.
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
useR
  • 23
  • 5
  • In the [documentation page](http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL) it says that "you may want to re-run the install to ensure that you also installed client header and library files. Note that *Xampp doesn't include these*." Have you checked if you have the header and library files? – nograpes Jul 19 '12 at 14:03
  • Thanks @nograpes. I have indeed checked the c:/wampp/mysql installation. The latest Xampp installation includes the header and library files in the respective directories. – useR Jul 19 '12 at 15:36

1 Answers1

1

There is a mismatch between the nature of the registry for the latest version of MySQL and the code in the package.

Within the tar.gz file, there is an R file "\RMySQL_0.9-3.tar\RMySQL\R\zzz.R" which contains the following code:

# check registry
if (!dir.exists(mysql)) {
    reg <- utils::readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2)
    for (i in reg){
    mysql <- i$Location
    if (dir.exists(mysql)) {
        if (verbose) cat(mysql, "found in registry\n")
        break
    }
    }
}

It used to be the case that each element of "reg" was a list, but the first element is now a vector. This means that the "mysql <- i$Location" statement will fail, creating the error message you observe.

I modified the statement to skip the first element of the registry by changing the line

for (i in reg){

to

for (i in reg[-1]){

and installed by running install.packages on the locally modified tarball.

Leo N
  • 11
  • 1