The specified module could not be found in R - r

I am developing a package using Rcpp and another third party C++ library. When I tried to install the package, I got
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Users/Admin/Documents/R/win-library/2.15/packagename/libs/i386/package.dll':
LoadLibrary failure: The specified module could not be found.
In 32-bit Windows OS, following an advice from my colleague, I fixed the problem by adding location of following dlls from MingW to system path.
libgcc_s_dw2-1.dll
But 64-bit Windows, I get the same error even with the dll although I am using 32-bit R.
So my question:
Is there any way to know why The specified module could not be found error occurs? I mean I would like to know which module is missing. Maybe verbose option some where?

There is not an easy way in R to get more information from the error I mentioned. But I found free software to find which dependency the dill is missing by following web site: http://www.dependencywalker.com/
Using the software I was able to find following dlls are needed to be in system path.
GPSVC.dll
IESHIMS.dll
SYSNIFY.dll

As hinted by the post Win 7, 64 bit, dll problems, the output of dependencywalker may be misleading. In my case, the path to "Microsoft SQL Server" was missing in my system %PATH% environment variable (deliberately removed, because it seemed unnecessary). After that the LoadLibrary error vanished and the library loaded.

I belive you can Run you R software as Administrator you can solve your problem...
You may check: Unable to load any package in R (unable to load shared object)

I ran into this same problem and the issue turned out to be that Windows was not looking in the right place for jvm.dll. Solution was to add location of this dll to Windows PATH variable.
Found solution here: Using the rJava package on Win7 64 bit with R
Instructions on how to edit PATH variable here: https://www.java.com/en/download/help/path.xml

I was also facing the error
"Warning in install.packages :
installation of package ‘rlang’ had non-zero exit status".
I followed the following steps
restart the RStudio,
install.packages("tidyverse")
removed the folder C:/Users/CHILIKA/Documents/R/win-library/3.5/00LOCK-rlang
and again
install.packages("rlang")
then rlang sucessfully installed.

Related

Is there a workaround for this package load error?

I am trying to manually load a package in R using a binary file, as I am in a virtual environment without internet connection.
The install seems to be going fine, but when I try to load the library into an RStudio session, I get the following error:
Error: package or namespace load failed for 'cli' in inDL(x,
as.logical(local), as.logical(now),...): unable to load share object
'C:/Users//cli.dll' : LoadLibrary failure: The specified
procedure could not be found.
This process has worked several times for other packages, but cli seems to be the only one that I've had this issue with thus far. I believe all dependencies have been installed with their most recent versions. Anyone come across this before?
Whenever you come across issues with .dll files there are a couple of possible solutions:
Ensure that your security/firewall policies have not quarantined the .dll file as this is quite common, especially on work machines.
Delete the package folder in your .libPaths()[1] directory and re-install the package from a vanilla R session (i.e. R --vanilla)
Lastly, ensure your machine has latest version of rtools installed and it is on your PATH environment variable (includes the necessary compilers for C++ like make, etc. You can test this by running Sys.which("make") which should point to your rtools path usr/bin/make.exe

error installing xlsx package with object not loaded [duplicate]

While loading rJava package, I receive this error:
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
In addition: Warning message:
package ‘rJava’ was built under R version 3.2.3
Error: package or namespace load failed for ‘rJava’
I referred various posts on StackOverflow and tried to make changes accordingly, but nothing worked. These are the various steps I followed to resolve the issue:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This didn't work.
Then I tried this:
options(java.home="C:\\Program Files\\Java\\jre1.8.0_91\\")
library(rJava)
This didn't work either.
My jvm.dll is at this location in my Windows 7 64 bit OS - C:\Program Files (x86)\Java\jre1.8.0_91\bin\client
I also added C:\Program Files (x86)\Java\jre1.8.0_91\bin\client to my PATH variable in my Environment variables and restarted RStudio and tried to install and load rJava again. That also didn't work.
I would really appreciate if someone could please help me resolve this issue.
Thanks guys!
This worked for me -
This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.
Note that it is necessary to ‘manually download and install’ the 64 bit version of JAVA. By default, the download page gives a 32 bit version .
You can pick the exact version of Java you wish to install from this link. If you might (for some reason) work on both versions of R, you can install both version of Java (Installing the “Java Runtime Environment” is probably good enough for your needs).
(Source: Uwe Ligges)
Other possible solutions is trying to re-install rJava.
If that doesn’t work, you could also manually set the directory of your Java location by setting it before loading the library:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre7') # for 32-bit version
library(rJava)
Refer this link - http://www.r-bloggers.com/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
I encountered the same problem. Be sure to check the file path for Java. To solve the error I needed to download 64bit Java version. However the following code in R did not work as the folder was incorrect for the latest version for Java:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Instead I changed the name to:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_144')
Hope that helps
I have noticed in different fresh installations of R, RStudio and rJava in WIndows, that what fixes the error is:
Uninstall R
Reinstall R but only selecting one architecture. Example, x64, or x86, but not both. That tends to confuse R or RStudio when they are compiling.
In my case, I fixed the message
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Following steps 1 and 2 above.
I tried what the other have said to not avail. For me the solution was to eliminate the old folders and shortcuts of R version 32 bit on my computer that remained there even after uninstalling.
This happened to me when Java was updated to a 32-bit, but R required a 64-bit version.
The solution:
Simply download the 64-bit version of Java
install it.
Restart RStudio
Everything should work
Where to download 64-bit java:
I guess your OS architecture and R architecture are not matching. If they are matching, the following might be the problem
It worked for me after i added the R library path to the environment variables list on my windows 7.
So,
Add 'C:/Users/Rohan-PC/Documents/R/win-library/3.1' this path to the Path variables list under System variables list(not to be confused with the PATH variable under User variables). Restart R and try loading the library. It works!!!!!
If you have both 64-bit R and 32-bit R versions installed, try from each one.
For me it worked on R 64bits but not R 32bits.
But of course that depends on your java version (64-bit Java vs 32-bit Java).

Unable to load Rcpp package

Due to my company's firewall I am manually installing packages from local. No errors when building the package from terminal, but I get an error when I load the package using library function
unable to load shared object 'C:/Program Files/R/R-3.6.1/library/Rcpp/libs/x64/Rcpp.dll':
LoadLibrary failure: The specified procedure could not be found.
And it also throws a prompt
Any help is appreciated thanks!
Tried:
Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object
https://github.com/r-lib/rlang/issues/306
None of the above seemed to work
I had this issue. I was using R 4.0.0 in RStudio (1.2.5042). I had been using R just fine all morning and continually had this issue all afternoon. I restarted my computer, updated my packages, and confirmed everything worked well on another computer. Finally I updated to R 4.0.2 and my issue resolved.
My binary package was correctly pathed to 4.0/Rcpp. I still don't know what caused the issue, but since this seemed to fix it hope it will for any future folk with this issue!
There has been a significant change in the build tools used for binary R packages on Windows:
Starting with R 4.0.0 (released April 2020), R for Windows uses a brand new toolchain bundle called rtools40.
https://cran.r-project.org/bin/windows/Rtools/
This means one has to be extra careful to get the correct file when downloading binary packages from CRAN, since packages for build with incompatible build tools will not work. At the time of writing this means:
Use the ones for r-oldrel for R 3.6
Use the ones for r-release for R 4.0
When this question was asked, R 4.0 was still r-devel.
You do not have to think about this things when using the build in install.packages() instead of manually downloading files from CRAN.

R - Error : .onLoad failed in loadNamespace() for 'rJava'

While loading rJava package, I receive this error:
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
In addition: Warning message:
package ‘rJava’ was built under R version 3.2.3
Error: package or namespace load failed for ‘rJava’
I referred various posts on StackOverflow and tried to make changes accordingly, but nothing worked. These are the various steps I followed to resolve the issue:
if (Sys.getenv("JAVA_HOME")!="")
Sys.setenv(JAVA_HOME="")
library(rJava)
This didn't work.
Then I tried this:
options(java.home="C:\\Program Files\\Java\\jre1.8.0_91\\")
library(rJava)
This didn't work either.
My jvm.dll is at this location in my Windows 7 64 bit OS - C:\Program Files (x86)\Java\jre1.8.0_91\bin\client
I also added C:\Program Files (x86)\Java\jre1.8.0_91\bin\client to my PATH variable in my Environment variables and restarted RStudio and tried to install and load rJava again. That also didn't work.
I would really appreciate if someone could please help me resolve this issue.
Thanks guys!
This worked for me -
This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.
Note that it is necessary to ‘manually download and install’ the 64 bit version of JAVA. By default, the download page gives a 32 bit version .
You can pick the exact version of Java you wish to install from this link. If you might (for some reason) work on both versions of R, you can install both version of Java (Installing the “Java Runtime Environment” is probably good enough for your needs).
(Source: Uwe Ligges)
Other possible solutions is trying to re-install rJava.
If that doesn’t work, you could also manually set the directory of your Java location by setting it before loading the library:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre7') # for 32-bit version
library(rJava)
Refer this link - http://www.r-bloggers.com/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/
I encountered the same problem. Be sure to check the file path for Java. To solve the error I needed to download 64bit Java version. However the following code in R did not work as the folder was incorrect for the latest version for Java:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7') # for 64-bit version
Instead I changed the name to:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_144')
Hope that helps
I have noticed in different fresh installations of R, RStudio and rJava in WIndows, that what fixes the error is:
Uninstall R
Reinstall R but only selecting one architecture. Example, x64, or x86, but not both. That tends to confuse R or RStudio when they are compiling.
In my case, I fixed the message
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/ankitagarwal5/Documents/R/win-library/3.2/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Following steps 1 and 2 above.
I tried what the other have said to not avail. For me the solution was to eliminate the old folders and shortcuts of R version 32 bit on my computer that remained there even after uninstalling.
This happened to me when Java was updated to a 32-bit, but R required a 64-bit version.
The solution:
Simply download the 64-bit version of Java
install it.
Restart RStudio
Everything should work
Where to download 64-bit java:
I guess your OS architecture and R architecture are not matching. If they are matching, the following might be the problem
It worked for me after i added the R library path to the environment variables list on my windows 7.
So,
Add 'C:/Users/Rohan-PC/Documents/R/win-library/3.1' this path to the Path variables list under System variables list(not to be confused with the PATH variable under User variables). Restart R and try loading the library. It works!!!!!
If you have both 64-bit R and 32-bit R versions installed, try from each one.
For me it worked on R 64bits but not R 32bits.
But of course that depends on your java version (64-bit Java vs 32-bit Java).

Unable to load rJava on R

I wish to load rJava in R x64 3.1.2.
OS- Windows 8.1 64 bit
Though installation seems to work fine:
> install.packages("rJava")
Installing package into ‘C:/Users/sony/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.utstat.utoronto.ca/bin/windows/contrib/3.1/rJava_0.9-6.zip'
Content type 'application/zip' length 758898 bytes (741 Kb)
opened URL
downloaded 741 Kb
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\sony\AppData\Local\Temp\RtmpamYUH7\downloaded_packages
I get an error while loading the package:
library(rJava)
Error in get(Info[i, 1], envir = env) :
lazy-load database 'C:/Users/sony/Documents/R/win-library/3.1/rJava/R/rJava.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
Error: package or namespace load failed for ‘rJava’
I know that I am working on R-64 bit and at same time the environment variable Path is set to:
C:\Program Files\Java\jdk1.7.0_51\bin;C:\Program Files\Java\jre7\bin\server;
also, so the Java version is 64 bit too. I don't understand the reason behind the error.
On manually setting through R:
options(java.home="C:\\Program Files\\Java\\jdk1.7.0_51\\bin")
library(rJava)
I get this error:
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/sony/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
Error: package or namespace load failed for ‘rJava’
Any advice? The error seems to have cropped up after I uninstalled some old version of Java.
OTHERS:
Also just to add, I do not set JAVA_HOME as a environment variable.
Uninstalling and Reinstalling R also doesn't seem to fix the problem.
Removing older java versions is too of no help.
Use:
Sys.setenv(JAVA_HOME='...path to JRE...')
e.g.
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jdk1.7.0_51\\jre')
Your environment variable is wrong.
I got a similar error:
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/program files/R/R-3.1.2/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
My JAVA_HOME was pointing to JDK, rather than JRE.
> Sys.getenv("JAVA_HOME")
[1] "c:\\java\\jdk1.7.0_55"
> Sys.setenv(JAVA_HOME="c:\\java\\jdk1.7.0_55\\jre")
I could now load rJava and xlsx in R.
I've met a similar problem and spent an entire day to get it fixed.
Although my computer, windows7, and Rstudio are 64 bit, but my Java is 32 bit(!) Once I realized that, I download a 64 bit Java. I have to manually download, the automatic download will lead to the 32 bit version because my chrome browser is 32 bit. 64 bit Java will be automatically installed in
C:\Program Files\Java, however, 32 bit Java will be automatically
installed in C:\Program Files (x86) \Java.
This is an important indicator telling me my Java is 64 bit or 32 bit.
After installing the 64 bit Java, everything works perfect!
Faced similar error message.
Tried a few steps listed here.
Set Env. Variable, JAVA_HOME. => Didn't work.
Tried to install rJava +> Didn't work
Steps 3,4,5 worked..
Updated my Java 64 bit version 8.xx (latest available)
install.packages(rJava) ==> Success
install.packages(RWeka) ==> Success
I get this error every time Java sneaks an update onto my PC. When I go:
Sys.getenv("Path")
I find something in the output which looks like
C:\\Program Files \\Java\\jre1.8.0_112\\bin\\server\\
where the last few digits of the jre subfolder are outdated.
To fix this everywhere, you might want to edit the Windows environment variable. Do this by going WINDOWS + X key, selecting Command Prompt (Admin) from the menu, and typing
rundll32.exe sysdm.cpl,EditEnvironmentVariables
in the command box. This will call up this dialog box with edit rights for the PATH variable (and other system variables):
The Windows interface for editing long environment variables is a bit unwieldy, so after I click Edit... I like to copy-paste the resulting mess of paths to Notepad.exe, do the work there, and copy-paste back.
Had the same issue:
I was running 64-bit R you can check which version by closing and re-openning RStudio. It should be at the top.
I had 32-bit java installed i.e. Java folder was within C:\Program Files (x86).
I simply went on to Java.com and downloaded the 64-bit Java and added it's location at the end of the PATH in System variables and I can load rJava now. (The installation asked me to get rid of the old version which I did)
It is probably the issue with the setting with the JAVA_HOME pointer. In case you do not have JDK but JRE, here is you might have to do:
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_161')
Remember to change the numbers after "jre" based on what you have on your computer. Here is a link that explains the difference between JDK and JRE.
Try downloading the RStudio daily build: http://dailies.rstudio.com
It worked for me on the second try after I tried everything else (updated R, Rstudio, Java, reinstalled rJava a million times, and followed all the stackoverflow advice).
The tip came from the RStudio support forums:
RStudio is indeed failing to read some of the start-up information normally provided by R here...
We have a potential fix for this in the latest daily builds of
RStudio -- if you're willing, you can try downloading and testing from
http://dailies.rstudio.com
I tried the above alternatives but it didnt work for me.
I found the solution here. Simply setting the JAVA_HOME allowed the rJava library to be loading fine.
Sys.getenv("JAVA_HOME")
Sys.setenv(JAVA_HOME="")
library(rJava)

Resources