Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

num_colors() incorrectly reports 256 in RStudio Terminal #119

Closed
rossellhayes opened this issue Apr 24, 2021 · 3 comments
Closed

num_colors() incorrectly reports 256 in RStudio Terminal #119

rossellhayes opened this issue Apr 24, 2021 · 3 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@rossellhayes
Copy link

Even when setting forget = TRUE, num_colors() incorrectly reports 256 in the RStudio Terminal. Calling show_ansi_colors() reveals that the true number is much lower.

Capture

@gaborcsardi
Copy link
Member

What's your OS? What's your RStudio version? What's crayon's version?

What's the output of

crayon:::detect_tty_colors()

What's the output of

system("tput colors 2>/dev/null", intern = TRUE)

@rossellhayes
Copy link
Author

rossellhayes commented Apr 24, 2021

Sorry, that was really bad GitHub etiquette on my part.

I'm running RStudio 1.4.1106 on Windows 10 build 19042. This is R 4.0.5 and crayon 1.4.1.

Both crayon:::detect_tty_colors() and system("tput colors 2>/dev/null", intern = TRUE) return 256 in RStudio's terminal.

I ran through num_ansi_colors() with debugging and none of the if statements were true. This meant it went to the last condition, running detect_tty_colors(). In detect_tty_colors(), the condition os_type() == "windows" && win10_build() >= 16257 was true, which returns a hardcoded 256L.

Here's the session info:

Session info
# - Session info ---------------------------------------------------------------
#  setting  value
#  version  R version 4.0.5 (2021-03-31)
#  os       Windows 10 x64
#  system   x86_64, mingw32
#  ui       RTerm
#  language (EN)
#  collate  English_United States.1252
#  ctype    English_United States.1252
#  tz       America/Los_Angeles
#  date     2021-04-24
# 
# - Packages -------------------------------------------------------------------
#  package     * version date       lib source
#  cli           2.4.0   2021-04-05 [1] standard (@2.4.0)
#  crayon      * 1.4.1   2021-02-08 [1] CRAN (R 4.0.5)
#  glue          1.4.2   2020-08-27 [1] CRAN (R 4.0.3)
#  rlang         0.4.10  2020-12-30 [1] CRAN (R 4.0.5)
#  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.0.0)
#  withr         2.4.1   2021-01-26 [1] standard (@2.4.1)
# 
# [1] C:/Users/Alex/Documents/R/win-library/4.0
# [2] C:/Program Files/R/R-4.0.5/library

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Apr 26, 2021
@gaborcsardi
Copy link
Member

What's your shell in the terminal? CMD or PowerShell?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants