2

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:

enter image description here

But then this error message pops up and R Studio aborts:

enter image description here

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!

Sescopeland
  • 315
  • 2
  • 16
  • Maybe verify that `tt` is of the expected class & the contents are valid? Try running some other "TKwidgets" functions with your `tt` to see if it's only `tkentry` which crashes. And verify the value of `Name` – Carl Witthoft Jun 12 '20 at 15:05
  • @CarlWitthoft, ```tktoplevel()```, ```tclVar```, ```tkwm.title``` all work properly. ```Name``` isn't able to be stored. That's where the crash occurs. – Sescopeland Jun 12 '20 at 15:32
  • @scopeland those aren't relevant. I mean any other functions listed at `?TkWidgets` – Carl Witthoft Jun 12 '20 at 17:57

2 Answers2

0

The problem appears to be with TclTk. Rcmdr won't run in R-4.0.1 but runs OK in R-4.0.0

My home-brew package won't load if Tcltk functionality is called.

0

The release notes for R 4.0.2 report that the bug has been fixed in that version:

Using tcltk widgets no longer crashes R on Windows.

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158