Unable to install packages from source. LoadLibrary failure: The parameter is incorrect.

I installed R a work administered computer (I don't have admin rights). I also installed Rtools43. When I try to install packages from source, I am consistently getting the error described below.

My system info:

> sessionInfo()

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8    

time zone: Europe/London
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.3.1 tools_4.3.1   
.libPaths()
[1] "C:/Users/AdrianBlanco-Gomez/AppData/Local/R/win-library/4.3" "C:/Program Files/R/R-4.3.1/library"                  
> Sys.getenv("PATH")
[1] "C:\\rtools43\\x86_64-w64-mingw32.static.posix\\bin;C:\\rtools43\\usr\\bin;C:\\Program Files\\R\\R-4.3.1\\bin\\x64;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\Users\\AdrianBlanco-Gomez\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\RStudio\\resources\\app\\bin\\quarto\\bin;C:\\Program Files\\RStudio\\resources\\app\\bin\\postback"
> Sys.which("make")
                              make 
"C:\\rtools43\\usr\\bin\\make.exe" 

Example of error with jsonlite (I get the same error with any package installed with type = "source"

> install.packages("jsonlite", type = "source")
Installing package into ā€˜C:/Users/AdrianBlanco-Gomez/AppData/Local/R/win-library/4.3’
(as ā€˜lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/jsonlite_1.8.7.tar.gz'
Content type 'application/x-gzip' length 1053075 bytes (1.0 MB)
downloaded 1.0 MB

* installing *source* package 'jsonlite' ...
** package 'jsonlite' successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C compiler: 'gcc.exe (GCC) 12.2.0'
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c base64.c -o base64.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c collapse_array.c -o collapse_array.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c collapse_object.c -o collapse_object.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c collapse_pretty.c -o collapse_pretty.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c escape_chars.c -o escape_chars.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c integer64_to_na.c -o integer64_to_na.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c is_datelist.c -o is_datelist.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c is_recordlist.c -o is_recordlist.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c is_scalarlist.c -o is_scalarlist.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c modp_numtoa.c -o modp_numtoa.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c null_to_na.c -o null_to_na.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c num_to_char.c -o num_to_char.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c parse.c -o parse.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c prettify.c -o prettify.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c push_parser.c -o push_parser.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c r-base64.c -o r-base64.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c register.c -o register.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c row_collapse.c -o row_collapse.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c transpose_list.c -o transpose_list.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c validate.c -o validate.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl.c -o yajl/yajl.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_alloc.c -o yajl/yajl_alloc.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_buf.c -o yajl/yajl_buf.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_encode.c -o yajl/yajl_encode.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_gen.c -o yajl/yajl_gen.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_lex.c -o yajl/yajl_lex.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_parser.c -o yajl/yajl_parser.o
gcc  -I"C:/PROGRA~1/R/R-43~1.1/include" -DNDEBUG -Iyajl/api    -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include"   -D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c yajl/yajl_tree.c -o yajl/yajl_tree.o
ar rcs yajl/libstatyajl.a yajl/yajl.o yajl/yajl_alloc.o yajl/yajl_buf.o yajl/yajl_encode.o yajl/yajl_gen.o yajl/yajl_lex.o yajl/yajl_parser.o yajl/yajl_tree.o
gcc -shared -s -static-libgcc -o jsonlite.dll tmp.def base64.o collapse_array.o collapse_object.o collapse_pretty.o escape_chars.o integer64_to_na.o is_datelist.o is_recordlist.o is_scalarlist.o modp_numtoa.o null_to_na.o num_to_char.o parse.o prettify.o push_parser.o r-base64.o register.o row_collapse.o transpose_list.o validate.o -Lyajl -lstatyajl -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools43/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-43~1.1/bin/x64 -lR
installing to C:/Users/AdrianBlanco-Gomez/AppData/Local/R/win-library/4.3/00LOCK-jsonlite/00new/jsonlite/libs/x64
** R
** inst
** byte-compile and prepare package for lazy loading
in method for 'asJSON' with signature '"AsIs"': no definition for class "AsIs"
in method for 'asJSON' with signature '"ITime"': no definition for class "ITime"
in method for 'asJSON' with signature '"hms"': no definition for class "hms"
in method for 'asJSON' with signature '"json"': no definition for class "json"
in method for 'asJSON' with signature '"integer64"': no definition for class "integer64"
in method for 'asJSON' with signature '"pairlist"': no definition for class "pairlist"
in method for 'asJSON' with signature '"blob"': no definition for class "blob"
in method for 'asJSON' with signature '"scalar"': no definition for class "scalar"
in method for 'asJSON' with signature '"sf"': no definition for class "sf"
in method for 'asJSON' with signature '"sfc"': no definition for class "sfc"
in method for 'asJSON' with signature '"vctrs_vctr"': no definition for class "vctrs_vctr"
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'jsonlite' in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'C:/Users/AdrianBlanco-Gomez/AppData/Local/R/win-library/4.3/00LOCK-jsonlite/00new/jsonlite/libs/x64/jsonlite.dll':
  LoadLibrary failure:  The parameter is incorrect.

Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/AdrianBlanco-Gomez/AppData/Local/R/win-library/4.3/jsonlite'
* restoring previous 'C:/Users/AdrianBlanco-Gomez/AppData/Local/R/win-library/4.3/jsonlite'
Warning in install.packages :
  installation of package ā€˜jsonlite’ had non-zero exit status

The downloaded source packages are in
    ā€˜C:\Users\AdrianBlanco-Gomez\AppData\Local\Temp\RtmpGgX9Sq\downloaded_packages’

I have tried changing the folder where the packages are installed and the problem persists. Installing R in a different folder where I have permissions does not solve it either. I also tried older versions of R and Rtools, I do not know what else to try. Any help will be appreciated.

There is seldom a need to install from source. There is no harm in trying once, but if it doesn’t work, drop the type argument. Any user who does not routinely compile programs from their own source code shouldn’t attempt to take it beyond the first attempt. There are better ways to becoming proficient in the tool chain steps needed to do this proficiently than learning by debugging package installs like this one.

Thanks for your help and suggestion.
I don't usually install from source, but unfortunately some packages (e.g. Seurat) I use have dependencies which are failing to be installed showing this same error LoadLibrary failure: The parameter is incorrect.

I am using this install.packages("jsonlite", type = "source") as a simple example that illustrates the problem.

I am a pretty basic user, and I don't have experience or intention to compile programs.

I’ve never installed any R packages under Wintel, but I’d be extremely surprised if this doesn’t work

install.packages(ā€œjsonliteā€)

I am not entirely sure why this would happen. It is possible that it is some kind of protection that does not allow loading packages from your home directory, although then binary packages would not work, either. Can you actually use binary package as well? I.e. after

install.packages("jsonlite")

can you run

library(jsonlite)

You can try this:

install.packages("jsonlite", INSTALL_opts="--no-test-load", type = "source")

then the package will install, because the loading test after installation is skipped, but of course it still might not load if you use

library(jsonlite)

after the installation.

It does not seem like this is happening here, but a common problem in Windows is that you cannot (re)install a package that is loaded into any R process. So make sure that you are not running more R sessions, and that the package is not loaded in the current session. (Or you can try to use pak::pkg_install() which unloads the package, and optionally kills other R sessions locking it.)

install.packages(ā€œjsonliteā€)

Works fine, and loading the library with

library(jsonlite)

works too

I don't understand what is going on, but it seems that for some packages, after installing them there are conflicts to load them. I always get the same error, for different packages:

Example below for a dependency required for Seurat

 install.packages("sctransform")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/sctransform_0.3.5.zip'
Content type 'application/zip' length 892851 bytes (871 KB)
downloaded 871 KB

package ā€˜sctransform’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\AdrianBlanco-Gomez\AppData\Local\Temp\RtmpUvoyeQ\downloaded_packages
> library(sctransform)
Error: package or namespace load failed for ā€˜sctransform’ in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'C:/R/R-4.3.1/library/sctransform/libs/x64/sctransform.dll':
  LoadLibrary failure:  The parameter is incorrect.
> 

I check and the sctransform.dll is in the described folder.

Thanks for your advice

It is possible that it is some kind of protection that does not allow loading packages from your home directory? E.g. are you running a virus scanner that is scanning files as you open them?

1 Like

Thanks @Gabor . That is actually what is happening. Panda is detecting these files as threads and blocking them. Currently speaking to IT to find a workaround.
Thank you so much for pointing that out!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.