I’ve put a file named test.sql containing nothing in inst/sql/sql_server and built the package, and when I run devtools::test() there are two warnings followed by a error message:
file(“”) only supports open = “w+” and open = “w+b”: using the former
text connection used with readChar(), results may be incorrect
invalid ‘nchars’ argument
It believe it’s the nchars argument in the line “readChar(pathToSql, file.info(pathToSql)$size)” that causes the error. If the test is run line-by-line in my console, everything works fine.
It looks like it can’t find the file “test.sql” in the inst/sql/sql_server folder of your package with name ‘SomePackageName’. Can you verify the file is there? Did you build your package before running this function?
It seems like it is actually something weird with the devtools test command? The test passes when you run R check, and the function also works without problem if you just call
It works fine in the console, but I’m afraid “R check” (CTRL - SHIFT - E / devtools::check()) does not pass on my computer. It’s related to some Java 32-bit issue which we know of but plan to live with as long as we have 64-bit working. But I guess it would be good to know if others with functioning Java 32 bit have the same issue with devtools, just to rule that out.
I have seen this issue on our environments several times. Try configuring RStudio Build > Project Options > Build Tools to use the --no-multiarch option.
Thanks for pointing that out. I had included no-multiarch on the build at some point, but not on the check. Now it’s just the nchar-thing from readChar that fails.
I updated R, Rtools, devtools and noticed an error message about the length of the filepath to the file not found.
“Tarballs are only required to store paths of up to 100 bytes and cannot store those of more than 256 bytes, with restrictions including to 100 bytes for the final component.”
Changing the name to a shorter one fixed the error. Thanks a lot!