You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for the useful package and it works fine on my mac for both the R version and Cpp version. However, the cpp version of progress bar fails to display on windows. Here's a minimal repro (using the code from your test package):
@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.
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.
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
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
Activity
gaborcsardi commentedon Oct 23, 2017
Confirmed.
gaborcsardi commentedon Apr 22, 2018
Should be fixed by b1efa6b
shrektan commentedon Apr 23, 2018
@gaborcsardi I have installed the dev version of this package but it doesn't display the progress bar using my example code above.
gaborcsardi commentedon Apr 23, 2018
This works for me. What is your platform? Is this the latest progress version?
shrektan commentedon Apr 25, 2018
@gaborcsardi Windows 7 X64. The progress version is the latest on Github, installed via
devtools::install_github('r-lib/progress')(I even checked the installedRProgress.hheader file, it's the same as in Github). For details, please see the session info below.shrektan commentedon Apr 25, 2018
@gaborcsardi I did a simple debug. all the three functions below always return 0.
progress/inst/include/RProgress.h
Line 278 in a2678e8
Moreover, even I force the
is_r_studio()to returntrue(I test this in the Rstudio IDE), the progress bar won't be print, either... I don't know why.Thanks.
gaborcsardi commentedon Apr 25, 2018
What's your rstudio version?
shrektan commentedon Apr 25, 2018
Version 1.1.423
shrektan commentedon Apr 25, 2018
What' more, I just confirmed that it won't work for the RGui either.
gaborcsardi commentedon Apr 25, 2018
Yeah, looking at the code, RGui is expected I think. But RStudio should work. What is your
RSTUDIOenvironment variable set to?shrektan commentedon Apr 25, 2018
It's
"1". However, I tried in cpp usingstd::getenv("RSTUDIO")will get empty.Example
Moreover,
I find if I change the
%of the below line to anything else likeabcd, it gets worked in the CMD console.progress/inst/include/RProgress.h
Line 128 in a2678e8
So,
std::getenv("RSTUDIO")returns empty in the Rstudio IDE (even thoughSys.getenv("RSTUDIO")returns "1")...std::stringcontains%, theRprintf(str.c_str())will print nothing.shrektan commentedon Apr 25, 2018
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):gaborcsardi commentedon Apr 25, 2018
Oh, yeah, there is a bug here. The
%is interpreted inRprintf()orREprintf. I'll fix that.But that's independent of the
RSTUDIOenv var being unset. That is just strange. It seems like a windows specific thing. Wow.gaborcsardi commentedon Apr 25, 2018
I'll think about how to detect RStudio from C++ code then....
gaborcsardi commentedon Apr 25, 2018
Looks like a bunch of other env vars are there from C as well:
This might be an RStudio bug then?
gaborcsardi commentedon Apr 25, 2018
Looks like that if you set the variable explicitly with
Sys.setenv(RSTUDIO = "1")then it will be there in C++ as well?shrektan commentedon Apr 25, 2018
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?gaborcsardi commentedon Apr 25, 2018
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.appshrektan commentedon Apr 25, 2018
Thanks! 😃