I recently upgraded my R to 4.0.1 from 3.4.1 because I needed to use the TSP package and hadn't updated R in a while. TSP only requires greater than 3.5.0 but I figured I would install the latest version, right?
Now, I'm trying to run code I use daily for the past several years but am getting a fatal error in both R Studio and the R console. It uses the tcltk library to store username and password, which is crucial as I pull in SQL data from our server to utilize in my code. I don't want to store my credentials in the code, and it's a hassle as our passwords change monthly.
I've tried looking at other questions, such as Fatal Error After Upgrading R / R Studio but that doesn't seem to be the problem.
Here's my sessionInfo()
:
R version 4.0.1 (2020-06-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 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.1 tools_4.0.1
I suspect that tcltk::tkentry
is the issue, as I went line by line and that's what causes the fatal error.
Here's my function:
getLoginDetails <- function(){
## Based on code by Barry Rowlingson
## http://r.789695.n4.nabble.com/tkentry-that-exits-after-RETURN-tt854721.html#none
require(tcltk)
tt <- tktoplevel()
tkwm.title(tt, "Get login details")
Name <- tclVar("Login ID")
Password <- tclVar("Password")
entry.Name <- tkentry(tt,width="20", textvariable=Name)
entry.Password <- tkentry(tt, width="20", show="*",
textvariable=Password)
tkgrid(tklabel(tt, text="Please enter your login details."))
tkgrid(entry.Name)
tkgrid(entry.Password)
OnOK <- function()
{
tkdestroy(tt)
}
OK.but <-tkbutton(tt,text=" OK ", command=OnOK)
tkbind(entry.Password, "<Return>", OnOK)
tkgrid(OK.but)
tkfocus(tt)
tkwait.window(tt)
invisible(c(loginID=tclvalue(Name), password=tclvalue(Password)))
}
credentials <- getLoginDetails()
The package loads correctly and capabilities("tcltk")
comes back as TRUE
.
The empty tktoplevel()
will load:
But then this error message pops up and R Studio aborts:
Any help would be appreciated! I need this getLoginDetails
function for my daily work activities.
If someone has an alternative, I would be open to that, too.
Cheers!