Open mccarthyryanc opened 4 years ago
Hi,
thanks for reporting this! However, there probably is no easy fix for this; the package seems to be relying on working with a "real" terminal (which the RStudio console is not). Would it be an option for you to run this in the linux console?
@skeydan , thanks for the response! Running from the command line is what I'm doing now, but not everyone that uses the code is comfortable with that. Users are typically in windows with RStudio. While the code runs fine from the windows command line (CMD, windows terminal, etc.) it is an intimidating step for a lot of people.
Perhaps there is a secure way to grab input in R and securely pass it to reticulate?
I just wanted to confirm this issue when trying to access getpass from the python REPL:
> reticulate::repl_python()
## Python 3.7.11 (/path/to/python.exe)
## Reticulate 1.22 REPL -- A Python interpreter in R.
## Enter 'exit' or 'quit' to exit the REPL and return to R.
>>> import getpass
>>> getpass.getpass()
When running getpass.getpass()
the cursor just moves to the next line in the console and blinks. The R session freezes in RStudio (stop sign in RStudio indicates something is running) and it won't terminate unless I force kill RStudio.
> sessionInfo()
# R version 4.0.5 (2021-03-31)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 17763)
#
# 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 LC_TIME=English_United States.1252
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] reticulate_1.22
#
# loaded via a namespace (and not attached):
# [1] Rcpp_1.0.7 gert_1.4.2 lattice_0.20-45 png_0.1-7 gitcreds_0.1.1 fansi_0.5.0 utf8_1.2.2 crayon_1.4.2 grid_4.0.5 jsonlite_1.7.2 sys_3.4
# [12] lifecycle_1.0.1 magrittr_2.0.1 credentials_1.3.1 pillar_1.6.4 rlang_0.4.12 Matrix_1.3-2 vctrs_0.3.8 ellipsis_0.3.2 tools_4.0.5 compiler_4.0.5 askpass_1.1
# [23] pkgconfig_2.0.3 openssl_1.4.5 tibble_3.1.6
# RStudio Version: 2021.09.1 Build 372
I am able to run it just fine through a cmd terminal, but I feel that this workaround is not something that an R user foraying into python only through {reticulate} would think of and difficult to look up the issue because no error or message of any kind is given (the session just freezes). Putting myself in those shoes, I would first think that something is broken in the getpass package before I considered an issue with {reticulate}'s implementation of the python REPL.
I was curious how Jupyter handles this, and it looks like their kernel overrides the getpass()
function in that module:
We'll probably have to do something similar here.
I have a python package that uses getpass to retrieve login credentials. If I run this from an R session in bash everything works as expected:
Howerver, if I try the same from the console in RStudio it becomes unresponsive and doesn't even display the
Prompt:
text. I have to click the "Stop" icon to get control back.Seems similar to https://github.com/rstudio/reticulate/issues/685, but the same workaround from that issue doesn't help:
System Info