greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
524 stars 63 forks source link

install_greta_deps() claims success when it has actually failed (windows) #572

Open goldingn opened 1 year ago

goldingn commented 1 year ago

Trying to install greta deps on a windows machine, with a clean R session. We get:

> install_greta_deps()

✔ greta-env environment created!                                                 

• To see full installation notes run:

• `greta_notes_conda_create_output()`

• To see any error messages, run:

• `greta_notes_conda_create_error()`

✔ Python modules installed!                                                                

• To see full installation notes run:

• `greta_notes_conda_install_output()`

• To see any error messages, run:

• `greta_notes_conda_install_error()`

✔ Installation of greta dependencies is complete!

• Restart R, then load greta with: `library(greta)`

but actually there are errors on the install:

> greta_notes_conda_install_output()

Collecting package metadata (current_repodata.json): ...working... failed

> greta_notes_conda_install_error()

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--name" "greta-env" "python" "--quiet" "-c" "conda-forge"

CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

Error : Error creating conda environment 'greta-env' [exit code 1]

here's the full set of console output and the session info:

> remotes::install_github("greta-dev/greta")

Downloading GitHub repo greta-dev/greta@HEAD

These packages have more recent versions available.

It is recommended to update all of them.

Which would you like to update?

1: All                               

2: CRAN packages only               

3: None                             

4: jsonlite (1.8.2  -> 1.8.3 ) [CRAN]

5: vctrs    (0.5.0  -> 0.5.1 ) [CRAN]

6: yaml     (2.3.5  -> 2.3.6 ) [CRAN]

7: globals  (0.16.1 -> 0.16.2) [CRAN]

8: digest   (0.6.29 -> 0.6.30) [CRAN]

9: callr    (3.7.2  -> 3.7.3 ) [CRAN]

Enter one or more numbers, or an empty line to skip updates:

✔  checking for file 'C:\Users\mg349\AppData\Local\Temp\RtmpmCF0o5\remotesbf07bd31be\greta-dev-greta-93aaf36/DESCRIPTION' (888ms)

─  preparing 'greta': (1.3s)

✔  checking DESCRIPTION meta-information ...

─  checking for LF line-endings in source and make files and shell scripts (827ms)

─  checking for empty or unneeded directories

─  building 'greta_0.4.3.9000.tar.gz'

* installing *source* package 'greta' ...

** using staged installation

** R

** inst

** byte-compile and prepare package for lazy loading

** help

*** installing help indices

*** copying figures

** building package indices

** installing vignettes

** testing if installed package can be loaded from temporary location

** testing if installed package can be loaded from final location

** testing if installed package keeps a record of temporary installation path

* DONE (greta)

> library(greta)

Attaching package: ‘greta’

The following objects are masked from ‘package:stats’:

    binomial, cov2cor, poisson

The following objects are masked from ‘package:base’:

    %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag, eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,

    tapply

> x <- normal(0, 1)

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--prefix" "C:/Users/mg349/AppData/Local/r-miniconda/envs/r-reticulate" "python=3.8" "numpy" "--quiet" "-c" "conda-forge"

Collecting package metadata (current_repodata.json): ...working... failed

CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to

download and install packages.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--prefix" "C:/Users/mg349/AppData/Local/r-miniconda/envs/r-reticulate" "python=3.8" "numpy" "--quiet" "-c" "conda-forge"

Collecting package metadata (current_repodata.json): ...working... failed

CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to

download and install packages.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--prefix" "C:/Users/mg349/AppData/Local/r-miniconda/envs/r-reticulate" "python=3.8" "numpy" "--quiet" "-c" "conda-forge"

Collecting package metadata (current_repodata.json): ...working... failed

CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

✖ Initialising python and checking dependencies, this may take a moment. ... failed

Error: We have detected that you do not have the expected python packages setup.

You can set these up by running this R code in the console:

`install_greta_deps()`

Then, restart R and run:

`library(greta)`

(Note: Your R session should not have initialised Tensorflow yet.)

For more information, see `?install_greta_deps`

> install_greta_deps()

✔ greta-env environment created!                                                 

• To see full installation notes run:

• `greta_notes_conda_create_output()`

• To see any error messages, run:

• `greta_notes_conda_create_error()`

✔ Python modules installed!                                                                

• To see full installation notes run:

• `greta_notes_conda_install_output()`

• To see any error messages, run:

• `greta_notes_conda_install_error()`

✔ Installation of greta dependencies is complete!

• Restart R, then load greta with: `library(greta)`

> greta_notes_conda_install_output()

Collecting package metadata (current_repodata.json): ...working... failed

> greta_notes_conda_install_error()

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--name" "greta-env" "python" "--quiet" "-c" "conda-forge"

CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

Error : Error creating conda environment 'greta-env' [exit code 1]

Restarting R session...

> library(greta)

Attaching package: ‘greta’

The following objects are masked from ‘package:stats’:

    binomial, cov2cor, poisson

The following objects are masked from ‘package:base’:

    %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag, eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,

    tapply

> x<- normal(0, 1)

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--prefix" "C:/Users/mg349/AppData/Local/r-miniconda/envs/r-reticulate" "python=3.8" "numpy" "--quiet" "-c" "conda-forge"

Collecting package metadata (current_repodata.json): ...working... failed

CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--prefix" "C:/Users/mg349/AppData/Local/r-miniconda/envs/r-reticulate" "python=3.8" "numpy" "--quiet" "-c" "conda-forge"

Collecting package metadata (current_repodata.json): ...working... failed

CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to

download and install packages.

Exception: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

+ "C:/Users/mg349/AppData/Local/r-miniconda/condabin/conda.bat" "create" "--yes" "--prefix" "C:/Users/mg349/AppData/Local/r-miniconda/envs/r-reticulate" "python=3.8" "numpy" "--quiet" "-c" "conda-forge"

✖ Initialising python and checking dependencies, this may take a moment. ... failed
R version 4.2.1 (2022-06-23 ucrt)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:

[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8

[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8   

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:

[1] greta_0.4.3.9000

loaded via a namespace (and not attached):

[1] Rcpp_1.0.9        rstudioapi_0.14   parallelly_1.32.1 magrittr_2.0.3    whisker_0.4       rappdirs_0.3.3    hms_1.1.2         progress_1.2.2  

 [9] here_1.0.1        lattice_0.20-45   R6_2.5.1          rlang_1.0.6       globals_0.16.1    tools_4.2.1       parallel_4.2.1    grid_4.2.1      

[17] png_0.1-7         cli_3.4.1         coda_0.19-4       tfruns_1.5.1      ellipsis_0.3.2    rprojroot_2.0.3   digest_0.6.29     lifecycle_1.0.3 

[25] crayon_1.5.2      tensorflow_2.9.0  processx_3.8.0    Matrix_1.4-1      callr_3.7.2       base64enc_0.1-3   vctrs_0.5.0       ps_1.7.2        

[33] codetools_0.2-18  compiler_4.2.1    prettyunits_1.1.1 jsonlite_1.8.2    reticulate_1.26   future_1.29.0     listenv_0.8.0     pkgconfig_2.0.3 
goldingn commented 1 year ago

In this particular installation issue, we got past the openSSL error by reinstalling reticulate from github as per: https://community.rstudio.com/t/reticulate-and-openssl-problem/152866/2

But the fact that the install step reported success rather than flagging that there was an error seems like it could be improved here?

njtierney commented 1 year ago

Thanks for this @goldingn !

To confirm, it sounds like the solution is to install reticulate from the dev GH version, is that right?

Sorry to hear about the false positive, trying to parse the errors is a bit tricky, as I'd ideally like the installation to know something was wrong on the processx side of things - e.g., it might pass an error flag in one of the variables, but in this case my fear is that it will still regard as "sucessful", despite the clear failing error/output message:

Collecting package metadata (current_repodata.json): ...working... failed

and

CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue.

My ideal thought is to capture the failure via some error slot in the callr/processx object, but I think that is somehow being obscured by the fact that the error is happening in Python/CLI somewhere. I'll see if I can replicate the issue with my current installation with TF2...which might be to my own detriment, but it sounds like it is a relatively easy solution.

At the moment my thought is to try and grep those error messages directly, perhaps? What do you think?

goldingn commented 1 year ago

To confirm, it sounds like the solution is to install reticulate from the dev GH version, is that right?

Yes, exactly.

Yeah I figured it might be a pain if it's not returning an error code correctly.

Grepping sounds good. If it's difficult to be sure of the result, in stone instances we could just mince the wording on the message, e.g. "may not have worked" and suggest they look at the logs. That's a bit icky, but might be the best option if it turns out to be really difficult.