Unable to load Rcpp package - r

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.

Related

Unable to load any packages in R after installing rtools because "package 'stats' does not have a namespace"

Earlier today I was trying to install a package from github using the library_github command from the devtools package. However, I received an error that devtools could not be used because rtools was not installed. I tried to install rtools using the notation described directly by https://cran.r-project.org/ to install rtools for Windows 10 device. However, this never worked. I went down a rabbit hole of trying to google how to setup rtools with R that led me to uninstall, redownload R, R-Studio, and R-Tools several times. I don't remember all that I tried, but I do remember the 2 main things which I will list below.
1.
The computer I am using is a Windows PC that is less than 4 months old, so much of my work up to this point has been automatically saved by Microsoft on their free Onedrive trial. I never paid much mind to it and didn't even realize all of my work and Internet downloads including my original setup of R and R-Studio had been saved on
OneDrive. This hadn't been an issue until recently when my free trial space on Microsoft OneDrive ran out. As a part of this process I went and tried to move everything off of OneDrive onto my computer's hard drive. A part of this included routing my packages that I would install in R onto a folder on my hard drive as is illustrated in this link: https://medium.com/#ValidScience/how-to-fix-rstudios-package-installation-on-windows-10-c1e602bf3a1f. So while I don't think that my current installation of R is tied at all to OneDrive, I have linked my installations in R to another folder on my hard drive called RFolder.
2.
When initially trying to install Rtools onto R I copied pretty much everything that this user illustrated in this video: https://www.youtube.com/watch?v=njZBf34Akgo After I completed the steps in this video, I first began to see issues with R-Studio being unable to access the stats file in R. I also began to get this error code every time that I opened R:
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-4.1.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
[Workspace loaded from ~/.RData]
When I googled this issue of LoadLibrary failure I was led to this thread https://community.rstudio.com/t/stat-package-will-not-load-after-installing-rtools/63265/11 where a user specifies a solution about deleting a hidden "./Renviron" file. I don't understand this at all and can't seem to find this file anywhere on my computer.
I have tried the simple solution of just deleting R, R-Studio, and RTools from the computer several times. However, even when I only redownload R and R-Studio and try to and try to get them to work, I am met with this same error. As it stands, I can no longer do anything in R because I cannot load any packages. I am able to install packages, but every time I try to use them with the library command I get this error:
Error: package or namespace load failed for ‘tidyverse’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-4.1.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
Any ideas on how to fix these issues would be greatly appreciated.

Error: package or namespace load failed for 'ggplot2': package 'ggplot2' was installed before R 4.0.0: please re-install it Execution halted

I'm really stuck and need some help.
After installing R 4.0.2, I'm getting this error message on R visualizations in Power BI Desktop which were previously working
"Error: package or namespace load failed for 'ggplot2':
package 'ggplot2' was installed before R 4.0.0: please re-install it.
Execution halted"
I already tried to:
reinstall R 4.0.2
reinstall RStudio
reinstall ggplot2
reinstall all packages
reinstall Power BI Desktop. My version is August-2020
Still it does not work.
Considerations:
My visualizations were working well before I installed R 4.0.2
My visualizations are working well on other PCs
When I run the code on RStudio I don't get any error
Any thoughts?
You probably need to go here: https://powerbi.microsoft.com/en-us/support/, but some guesses:
When you did the reinstall, you didn't clean up the old one, so you now have a mix of old and new versions of things. If you can run R code, run
system.file(package="ggplot2")
That's where it is finding the bad version of ggplot2. Get rid of it, and reinstall. If that's not enough, run
.libPaths()
in the broken copy of R. Completely eradicate every directory mentioned there, and reinstall R and all of your contributed packages. (I don't use Power BI, so this might also require you to wipe out some part of it: do so, and reinstall it.)
After all of this, run
packageDescription("ggplot2")
In the last line (or close to it) of what gets printed, you should see something like this:
Built: R 4.0.2; ; 2020-07-16 22:49:23 UTC; unix
If you see that it was built before 4.0.2, then either you missed deleting something, or you (or Microsoft) reinstalled some old version. Then it's probably time to contact that URL above.

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).

R-Studio on OSX can't load mosaic package

I am running OSX 10.10, R-Studio Version 0.99.484, and R version 3.2.2.
I just made a fresh install of R and R-Studio using the installers from their respective websites. I use install.packages to install "mosaic" and then I try loading it using library, but it gives me the following error:
library("mosaic", lib.loc="/Library/Frameworks/R.framework/Versions/3.2/Resources/library")
Error : object ‘dendro_data.hclust’ is not exported by 'namespace:ggdendro'
Error: package or namespace load failed for ‘mosaic’
I tried reinstalling ggdendro but nothing. Does anyone have any advice on how to deal with this issue?
I encountered this same error and seem to have somewhere along the way resolved it. Steps taken include:
cleaned out my libraries (local and System)
used Disk Utility to repair any odd permissions
reinstalled R
opened RStudio and imported package with dependencies from the repository:
> install.packages("mosaic", lib="/Library/Frameworks/R.framework/Versions/3.2/Resources/library")
console prompted me to choose the older precompiled package or the newer, I chose older
Do you want to install from sources the package which needs compilation?
y/n: n
mosaic loaded happily
> library("mosaic", lib.loc="/Library/Frameworks/R.framework/Versions/3.2/Resources/library")

JavaGD fails to load

Could someone please help.
I had Deducer working with R 2.14 but now that I have updated to 2.15.1 I can't get JGR to load. I have loaded JGR and Deducer.
This is the message I get when installing
Loading required package: JavaGD
Error : .onLoad failed in loadNamespace() for 'JavaGD', details:
call: .Call("RegGetStrValue", c(key, "CurrentVersion"), PACKAGE = "JavaGD")
error: C symbol name "RegGetStrValue" not in DLL for package "JavaGD"
Error: package ‘JavaGD’ could not be loaded
I have removed all old versions of R and Ver 2.15.1 - reinstalled R and still get this message.
Is it possible that this is a Registry problem and if so where should I look.
I have searched and although there seem to be simiar reported issues, none are exactly the same from the ones that I have seen. I certainly dont seem to have m,ultiple versions of JavaGD in my library and the Namesake file is in the folder JavaGD.
I am running Win 7 32 bit ver on fairly current Dell Laptop.
R seems to work fine and I am using R-Studio most of the time and that works fine as well.
Any help would be appreciated
7 years on form the OP's original issue choosing the right Java Download is critical for 64-bit machines which most of our RStudio environments are synced to work with. For whatever reason, downloading the 64-bit JRE is difficult. To avoid the same error presented by Deducer more recently be sure to download the 64-bit Java JRE from https://www.java.com/en/download/manual.jsp. Note, the 64-bit version must be downloaded offline as instructed (usually bottom of Windows downloads). Check that the installation path is c:\Program Files\Java and not c:\Program Files(x86)\Java. That plus the JDK should fix this problem going forward.

Resources