GithubHelp home page GithubHelp logo

cpp version won't work on windows about progress HOT 19 OPEN

r-lib avatar r-lib commented on June 27, 2024
cpp version won't work on windows

from progress.

Comments (19)

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Confirmed.

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Should be fixed by b1efa6b

from progress.

shrektan avatar shrektan commented on June 27, 2024

@gaborcsardi I have installed the dev version of this package but it doesn't display the progress bar using my example code above.

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

This works for me. What is your platform? Is this the latest progress version?

from progress.

shrektan avatar shrektan commented on June 27, 2024

@gaborcsardi Windows 7 X64. The progress version is the latest on Github, installed via devtools::install_github('r-lib/progress') (I even checked the installed RProgress.h header file, it's the same as in Github). For details, please see the session info below.

> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                                              
 version  R version 3.4.4 (2018-03-15)                       
 os       Windows 7 x64 SP 1                                 
 system   x86_64, mingw32                                    
 ui       RStudio                                            
 language (EN)                                               
 collate  Chinese (Simplified)_People's Republic of China.936
 tz       Asia/Taipei                                        
 date     2018-04-25                                         

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version     date       source                             
 ansistrings   1.0.0.9000  2018-04-13 Github (r-lib/ansistrings@4e4d309) 
 assertthat    0.2.0       2017-04-11 CRAN (R 3.4.4)                     
 backports     1.1.2       2017-12-13 CRAN (R 3.4.3)                     
 cli           1.0.0.9002  2018-04-13 Github (r-lib/cli@c408924)         
 clisymbols    1.2.0       2017-05-21 CRAN (R 3.4.1)                     
 crayon        1.3.4       2017-09-16 CRAN (R 3.4.1)                     
 DBI           0.8         2018-03-02 CRAN (R 3.4.4)                     
 desc          1.1.1       2017-08-03 CRAN (R 3.4.1)                     
 devtools      1.13.5.9000 2018-04-08 local                              
 digest        0.6.15      2018-01-28 CRAN (R 3.4.3)                     
 glue          1.2.0       2017-10-29 CRAN (R 3.4.2)                     
 hms           0.4.2       2018-03-10 CRAN (R 3.4.4)                     
 magrittr      1.5         2014-11-22 CRAN (R 3.4.4)                     
 memoise       1.1.0       2017-04-21 CRAN (R 3.4.0)                     
 pkgbuild      0.0.0.9000  2017-12-06 Github (r-lib/pkgbuild@ce7f6d1)    
 pkgconfig     2.0.1       2017-03-21 CRAN (R 3.4.4)                     
 pkgload       0.0.0.9000  2017-12-06 Github (r-lib/pkgload@70eaef8)     
 prettyunits   1.0.2       2015-07-13 CRAN (R 3.4.1)                     
 progress      1.2.0       2018-04-23 Github (r-lib/progress@a2678e8)    
 R6            2.2.2       2017-06-17 CRAN (R 3.4.1)                     
 Rcpp        * 0.12.16     2018-03-13 CRAN (R 3.4.4)                     
 rlang         0.2.0       2018-02-20 CRAN (R 3.4.3)                     
 rprojroot     1.3-2       2018-01-03 CRAN (R 3.4.3)                     
 rstudioapi    0.7.0-9000  2018-04-13 Github (rstudio/rstudioapi@e87b481)
 selectr       0.4-1       2018-04-06 CRAN (R 3.4.4)                     
 sessioninfo   1.0.1.9000  2017-12-06 Github (r-lib/sessioninfo@c871d01) 
 stringi       1.1.7       2018-03-12 CRAN (R 3.4.4)                     
 stringr       1.3.0       2018-02-19 CRAN (R 3.4.3)                     
 testthat      2.0.0       2017-12-13 CRAN (R 3.4.4)                     
 usethis     * 1.3.0       2018-02-24 CRAN (R 3.4.3)                     
 withr         2.1.2       2018-03-15 CRAN (R 3.4.4)                     
 xml2          1.2.0       2018-01-24 CRAN (R 3.4.3)                     
 yaml          2.1.18      2018-03-08 CRAN (R 3.4.4)  

from progress.

shrektan avatar shrektan commented on June 27, 2024

@gaborcsardi I did a simple debug. all the three functions below always return 0.

(isatty(1) || is_r_studio() || is_r_app());

Moreover, even I force the is_r_studio() to return true (I test this in the Rstudio IDE), the progress bar won't be print, either... I don't know why.

Thanks.

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

What's your rstudio version?

from progress.

shrektan avatar shrektan commented on June 27, 2024

Version 1.1.423

from progress.

shrektan avatar shrektan commented on June 27, 2024

What' more, I just confirmed that it won't work for the RGui either.

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Yeah, looking at the code, RGui is expected I think. But RStudio should work. What is your RSTUDIO environment variable set to?

Sys.getenv("RSTUDIO")

from progress.

shrektan avatar shrektan commented on June 27, 2024

It's "1". However, I tried in cpp using std::getenv("RSTUDIO") will get empty.

Example

Rcpp::cppFunction('void test() {
  char *v = std::getenv("RSTUDIO");                 
  Rcpp::Rcout << (v == 0);
}')
test()
# returns 1 meaning it's empty.  By contrast, if you change ”RSTUDIO" to "PATH", it returns 0.

Moreover,

I find if I change the % of the below line to anything else like abcd, it gets worked in the CMD console.

buffer << std::setw(3) << ratio_now * 100 << "%";

image

So,

  • don't know why std::getenv("RSTUDIO") returns empty in the Rstudio IDE (even though Sys.getenv("RSTUDIO") returns "1")...
  • don't know why if a std::string contains %, the Rprintf(str.c_str()) will print nothing.

from progress.

shrektan avatar shrektan commented on June 27, 2024

The example to my second point (change % to %% will solve the problem but I don't know why it's not needed on the OSX):

Rcpp::cppFunction('void test2() {
  std::string a = "abcd";                 
  std::string b = "efgh%";                 
  Rprintf(a.c_str());
  Rprintf(b.c_str());
}')
test2()
# abcdWarning message:
# In test2() : printing of extremely long output is truncated

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Oh, yeah, there is a bug here. The % is interpreted in Rprintf() or REprintf. I'll fix that.

But that's independent of the RSTUDIO env var being unset. That is just strange. It seems like a windows specific thing. Wow.

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

I'll think about how to detect RStudio from C++ code then....

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Looks like a bunch of other env vars are there from C as well:

RSTUDIO_WINUTILS=C:/Program Files/RStudio/bin/winutils
RSTUDIO_PANDOC=C:/Program Files/RStudio/bin/pandoc
RMARKDOWN_MATHJAX_PATH=C:/Program Files/RStudio/resources/mathjax-26
RSTUDIO_MSYS_SSH=C:/Program Files/RStudio/bin/msys-ssh-1000-18

This might be an RStudio bug then?

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Looks like that if you set the variable explicitly with Sys.setenv(RSTUDIO = "1") then it will be there in C++ as well?

from progress.

shrektan avatar shrektan commented on June 27, 2024

Yes, you are right. Calling Sys.setenv(RSTUDIO = "1") solves this. I don't really know why's that. Maybe a bug from the RStudio side?

from progress.

gaborcsardi avatar gaborcsardi commented on June 27, 2024

Maybe, but I don't know how that would be even possible. It is R calling the external code via .Call, RStudio has nothing to do with it AFAICT. Anyway, I asked the RStudio IDE team, will let you know.

I'll fix the other bugs as well, the % one, and the detection of RGui and R.app

from progress.

shrektan avatar shrektan commented on June 27, 2024

Thanks! 😃

from progress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.