R TCLTK not loading on windows - r

I have installed R on countless windows machines and never had a problem with the tcltk package until now.
I have freshly installed R 3.3.2 onto Windows 10 Pro v1607 and can't load tcltk. I used the windows install binaries from CRAN, so no custom builds.
capabilities("tcltk")
returns TRUE. When I try to load tcltk:
library("tcltk")
I get:
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Program Files/R/R-3.3.2/library/tcltk/libs/x64/tcltk.dll':
LoadLibrary failure: The specified module could not be found.
Error: package or namespace load failed for ‘tcltk’
Navigating to the location of the DLL confirms that it is there. This fails when calling both x64 and i386 versions of R. I have tried running as admin and same thing. I also tried rolling back to version 3.3.1 and had the same issues.
This PC has an AMD FX-8120 processor.
I couldn't find much on R tcltk problems on Windows. Any ideas would be great.
Cheers
EDIT: added info:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.3.2

To fix the problem do the following tests:
Test the Tcl/Tk installation of R:
Find and start wish85.exe which is contained in one of the sub folders of the R installation ("85" is the version number and my differ depending on your R version).
An empty Tk window must pop up and a tcl/tk console must open.
If not the installation is damaged or parts have been deleted
(reinstall it)
Check if R is using the right Tcl/Tk version:
Check the value of the environment variable MY_TCLTK
If it is defined: Does the path point to the bin folder of Tcl/Tk?
If not: Fix it.
If it is not defined: It should work out of the box but you could
set the value to the bin folder.
Source:
https://mirrors.dotsrc.org/cran/bin/windows/base/rw-FAQ.html#Package-TclTk-does-not-work_002e

MY_TCLTK was defined as "Yes" in my environment variables. I changed it to the location of the tcl exe that was installed with R and it works now.

Related

install_github(): "system error 267, The directory name is invalid"

I am trying to install package performance development version with devtools but am getting this error:
> devtools::install_github("easystats/performance")
Downloading GitHub repo easystats/performance#HEAD
Error: Failed to install 'performance' from GitHub:
create process 'C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe' (system error 267, The directory name is invalid.
) #win/processx.c:1040 (processx_exec)
Same thing with alternative remotes command:
> remotes::install_github("easystats/performance")
Downloading GitHub repo easystats/performance#HEAD
Error: Failed to install 'performance' from GitHub:
create process 'C:/PROGRA~1/R/R-40~1.3/bin/x64/Rcmd.exe' (system error 267, The directory name is invalid.
) #win/processx.c:1040 (processx_exec)
Edit: Note that I am getting the same error no matter what package I've tried to install through devtools (e.g., cardiomoon/processR or r-lib/crayon). This started to happen suddenly a few weeks ago yet never had this issue before. So it seems not related to the package but to something else.
So I tried changing my default library to the simplest ever location that doesn't have any special characters or require any admin rights, with those instructions. I can confirm that C:/Rpackages is now indeed my default library path, and that it is first (on the left):
> .libPaths()
[1] "C:/Rpackages" "C:/Program Files/R/R-4.0.3/library"
However, I am still getting the same error. The weird thing is that the error still seems to refer to the second library path rather than the first one, which seems off to me. From the help documentation, I don't see how to specify the library location explicitly for neither devtools nor remotes. Also interesting, notice that the error seems to mention R-40~1.3 instead of R-4.0.3 as it should(?). Might this be the issue? Then how to fix?
I also tried reinstalling devtools and remotes, to no avail.
Yet, it works if I install the regular CRAN version:
> install.packages("performance")
Installing package into ‘C:/Rpackages’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/performance_0.7.2.zip'
Content type 'application/zip' length 2487172 bytes (2.4 MB)
downloaded 2.4 MB
package ‘performance’ successfully unpacked and MD5 sums checked
Here my session info if useful:
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3 yaml_2.2.1
The issue was with the processx package and the development version has since received a fix (in version v3.5.3). Please see the following discussion for more info: https://github.com/r-lib/processx/issues/313

Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object

I have uploaded the version of R to 4.0.2 (2020-06-22).
After installing the gmm package when I require it I got the message below. I have also taken this message for the other packages like TropFishR. I have Xcode 10.3 . I reinstalled R studio and R several times. thank you very much for your time.
Error message:
Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so, 6): Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/libs/gmm.so
Reason: image not found
session info:
version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] sandwich_2.5-1
loaded via a namespace (and not attached):
[1] zoo_1.8-8 compiler_4.0.2
[3] tools_4.0.2 grid_4.0.2
[5] lattice_0.20-41
The problem is caused because Library not loaded: /usr/local/gfortran/lib/libgomp.1.dylib is missed.
To solve it, I went to this Github release page, downloaded gfortran-10.2-Catalina.dmg, and installed it. Then I can finally load gmm package in R.
On MacOS 13, download this file, and build a hard link to /usr/local/gfortran/lib/libgomp.1.dylib in /opt/R/arm64/gfortran/lib, e.g., using the following command:
sudo ln libgomp.1.dylib /opt/R/arm64/gfortran/lib/libgomp.1.dylib
maybe the directory /gfortran/lib is required to be built manually. Hope helpful~
Using this answer I found a (temporary) way to fix this issue without messing around with installations.
Finding the file
It seems that the program can't find libgomp.1.dylib, however, your system may already have this file installed. Using:
locate libgomp.1.dylib
you get a list of places where this library has been found. If you are running this command for the first time, you may have to run another command first to create the index.
For me, this was:
/usr/local/Cellar/gcc/12.1.0/lib/gcc/current/libgomp.1.dylib
However, it might be different on your system.
If nothing is returned, you may need to install gfortran on your system, e.g. using brew install gcc.
Linking the file
My error message showed me some places where it tried to look for the file, one of which was in my user directory:
/Users/overground/lib
So, using ln, create a link from this directory to the file you have found in the previous step. First, ensure that the lib folder exists in your user directory. Then, link the files with:
ln /usr/local/Cellar/gcc/12.1.0/lib/gcc/current/libgomp.1.dylib /Users/overground/lib
Replace the first file path with the file path you have found in the first step, and the username in the second path. Now, you should be able to see the file in the lib directory.
This would sound crazy, but I had the same problem running a bash script (say masterPipeline.sh) that I wrote. When I wrote that script it was working fine, however a couple of days ago I got this error:
Error: package or namespace load failed for ‘stats’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/hemiptero/lib/R/library/stats/libs/stats.so':
The issue came after masterPipeline.sh invoke R to make a subroutine (R < ./scripts/measure2sd.r --no-save) but when I type that command by myself in the terminal I don't get the error.
So, I don't know how but I get with the idea of running my script as superuser.
sudo masterPipeline.sh
It works!
So maybe running R as superuser would works for those working on linux

R: Internet routines cannot be loaded after update to R4.0

I have an issue that is stumping me and am looking for some help. I just upgraded to R 4.0 and am trying to reinstall packages. This produces the following warning messages:
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file 'C:/PROGRA~1/R/R-40~1.0/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cran.uni-muenster.de/src/contrib:
internet routines cannot be loaded
Warning: unable to access index for repository https://cran.uni-muenster.de/bin/windows/contrib/4.0:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object 'C:/PROGRA~1/R/R-40~1.0/modules/x64/internet.dll':
LoadLibrary failure: Access is denied.
2: package ‘dplyr’ is not available (for R version 4.0.)
Note, the LoadLibrary failure is not always present. Additionally, when I look for help on a function (e.g. ?download.file), I get the following error message:
starting httpd help server ...Error in startDynamicHelp(TRUE) : internet routines cannot be loaded
So, it seems like there is a general issue with R connecting to the internet, but I'm not sure how to go about fixing this. This happens in both RStudio (which is fully updated) and in the base RGui; additionally, I do have access and permissions to read/write in the C:/PROGRA~1/R/R-40~1.0/modules/x64/ folder. Any help here would be much appreciated!
Edit:
Posting my sessionInfo() in case that is helpful:
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.0 tools_4.0.0
Edit 2: I have done some more digging and the 32-bit version of R works just fine, while the 64-bit does not.
i had the same issue when updated to R 4.0.2 64-bit and ran in RStudio 1.4.xxx which reported internet routine not loaded. my work cylance protect antivirus quarantined internet.dll file under modules\x64\internet.dll. I reported to my IT today. they said that this dll file is asking which antivirus installed in my machine. so, my IT was concerned. my IT will ask cylance.
My IT advised me not to download R 402 from cran where it was infected.
i copied that dll from my another pc where R 363 installed and put there.
but cylance antivirus quarantined again.
so i bring my covid analysis file home and am doing with my home R 402.
I checked downloaded R 402 and internet.dll with my windows defender = all clean
the most probable cause = my IT security perceived threat from internet.dll
wondering what others are thinking about it.
I also discussed with my IT director for having r package mirror server so i can download without going to the internet.
cheers.
Install RStudio and R Version With help of IT Team.
Download New Version of R from CRAN
Copy an internet.dll file (which Size should be Up to 5MB) from Existing Version Installed by IT Team on Your System
C:\Program Files\R\R-4.0.3\modules\x64 and
Paste it to C:\Users\MyUser\Documents\R\R-4.1.2\modules\x64 folder of New version
Then Restart RStudio you will not get any error
also you can install any packages
Do not need to make changes into any File like Rprofile and Renv
Or any other Options() Functions
Note: The File Path may be different in your System

How to load rJava into RStudio?

Although I'm running the risk of duplicating questions, I have yet to find a solution to my configuration.
I'm trying to load rJava into RStudio.
I am using the latest Mac OS x, with a build of Rstudio that's only a couple of months old, and I've just installed JDK x64 12.0.1
The version of rJava is 0.9-11
On executing:
library(rJava)
I am confronted with the usual:
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
I've tried setting my Java home path to:
Sys.setenv(JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home')
But that doesn't make any difference.
I've clearly missed the rJava instructions somewhere which lays out how to install the package on all computer setups. I'd appreciate some assistance.
EDIT #1
Following the link provided in the comments below, I managed to get the latest version of Java JDK running through rJava in RStudio. The document "R, Java, rJava and macOS adventures" isn't complete and doesn't work off the cuff. You'll probably end up hacking about to get it working.
I needed rJava to run venneuler, unfortunately, this was not work using the latest Oracle JDK version 12:
WARNING: Initial Java 12 release has broken JNI support and does NOT work. Use stable Java 11 (or watch for 12u if available).
ERROR: Java exception occurred during rJava bootstrap - see stderr for Java stack trace.
I'm going to try (wish me luck) to get two versions of Java on my machine and have RStudio recognise the right one.
Edit 2
Pure luck I think I have Java 11 working:
I had the this issue as well on my mac (OSX High Sierra v10.13.6) and could not solve it by following previous suggestions (reinstall JDK, R CMD javareconf or setting JAVA_HOME). The same error message persisted:
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
After looking closely at the error message, I found that I had JDK12, but R kept looking for libjvm.dylib under the JDK11 folder which does not exist in my system. The path to JDK11 appeared in Sys.get('DYLD_FALLBACK_LIBRARY_PATH'), but overwriting this variable did not help. Neither did dyn.load('PATH_TO_YOUR_JDK').
And then the second to last line of the error message caught my eye: the path to libjvm.dylib was referenced from rJava.so. Why not take a look at this file? At the end, I opened the rJava.so, found the JDK11 path and replaced it with JDK12 path, and rJava loaded perfectly. Hope this helps other people with the same issue.
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tabulizer_0.2.2 rJava_0.9-11
loaded via a namespace (and not attached):
[1] tabulizerjars_1.0.1 compiler_3.5.2 assertthat_0.2.1 cli_1.1.0 tools_3.5.2 withr_2.1.2
[7] rstudioapi_0.10 yaml_2.2.0 crayon_1.3.4 png_0.1-7 sessioninfo_1.1.1
I had the same issue and I was able to fix it by searching, but I don't remember exactly the step that I've done but I looked again and I found this answer and I hope it'll work for you. You'll have to run this command in a terminal. I don't know if I can post link but I just typed "rjava lib Rstudio error" and I find a couple of different solutions so you might give them a look if this doesn't work.
sudo R CMD javareconf

R Error when installing/loading packages from library on company pc

After opening R Studio the following Error-message appears:
This error also always appears in the end when I am trying to install or load packages:
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Some maybe helpful facts:
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1
I am working on a company laptop without admin-rights, why I have set my library path manually to the following writable folders:
> .libPaths()
[1] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/win-library/3.5"
[2] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
The second .libPath() was created automatically some weeks after the first.
I cannot manually delete both .libPaths from my laptop due to missing admin-rights.
I also tried to remove the libraries as recommended in several posts
with:
R_LIBS=C:/Program Files/R/R-2.15.2/library
Nevertheless, the .libPaths stayed the same after this:
> .libPaths()
[1] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/win-library/3.5"
[2] "\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
I also tried setting a new .libPath on a local folder C:// :
.libPaths("C:\\Users\\USERID\\Desktop\\R")
After that, the first .libPath is replaced by the new local one, while the second .libPath stays the same and I am getting the same error again:
> .libPaths()
[1] "C:/Users/USERID/Desktop/R"
"\\\\HOME.COMPANYNAME/USERNAME$/Files/R/R-3.5.1/library"
Error: invalid version specification ‘NA’
In addition: Warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
Setting the new .libPath on the local folder C:/ allows me to install and load packages but only temporarly within the R Studio-session:
> install.packages("FDboost")
Installing package into ‘C:/Users/USERID/Desktop/R/R-3.5.1/library’
(as ‘lib’ is unspecified)
After quitting and restarting the R session, the newly defined .libPath on C:/ as well as the installed packages are deleted.
Maybe I have to add the .libPath to the filepath as recommended by #r2evans so that it is saved also after quitting the R session? I did not figure out how to do so...
For the last months, I was able to install and load packages from these two library paths, maybe there was an antivirus update that now makes problems? I did not change any settings but it seems like R cannot find or edit the installed packages anymore.
Deinstalling R or RStudio is not a possible solution, since I need admin rights to reinstall them.
Since other posts did not bring the solution so far, maybe anybody has more ideas?

Resources