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

Inconsistent output from tidy_description #83

Closed
csgillespie opened this issue Sep 11, 2019 · 1 comment
Closed

Inconsistent output from tidy_description #83

csgillespie opened this issue Sep 11, 2019 · 1 comment
Labels
bug

Comments

@csgillespie
Copy link

@csgillespie csgillespie commented Sep 11, 2019

I have the following package DESCRIPTION

Package: jrIdentity
Title: Style Jumping Rivers Branded Content
Version: 0.0.1
Authors@R:
    person(given = "Jumping",
           family = "Rivers",
           role = c("aut", "cre"),
           email = "info@jumpingrivers.com")
Description: Package to provide RMarkdown templates to create
    Jumping Rivers branded content.
License: file LICENSE
Imports:
    rmarkdown,
    rmdformats
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Suggest: knitr

Running on my laptop

library(desc)
desc = desc::description$new(".")
message(desc$get_field(key = "Description"))
desc$normalize()
message(desc$get_field(key = "Description"))

the Description tag isn't changed.

However, running on our GitLab runner it changes the description line to:

Description: Package to provide RMarkdown templates to create Jumping 
     Rivers branded content.

What I don't understand is why.

  • Both systems are ubuntu 18.04
  • Both running R 3.6
  • Both access the file via a GitLab repo
  • Both use the same versions of usethis (1.5.1) and desc (1.20).

I've searched desc for a width option, but it appears the width of the file is hard-coded

reprex

The DESCRIPTION file above. Not sure what the correct output should be.


Originally posted r-lib/usethis#887

@csgillespie
Copy link
Author

@csgillespie csgillespie commented Sep 16, 2019

The issue is due to counting characters. When calculating the width, the following line is called:

strwrap(paste0(x$key,  ": ", desc:::color_bad(x)), exdent = 4, width = 75)

However, x$key is

crayon::blue("Description")
# "\033[34mDescription\033[39m"

When calculating the nchar, we are including the colour

nchar(crayon::blue(""))
# 10 

Since the gitlab runner doesn't have a colour terminal the first line is different.

  • Setting options("crayon.enabled" = FALSE) on my laptop reproduces the output on the runner.
  • Conversely, setting options("crayon.enabled" = TRUE) matches the runner to the laptop
  • I would suggest that this is a bug since the intention is to stipulate a fixed width of 75, but in the practice, the first line has a width of only 65.

ThierryO added a commit to inbo/checklist that referenced this issue Jul 16, 2020
Finaly get this working correctly with the workaround from @csgillespie at r-lib/desc#83.
@gaborcsardi gaborcsardi added the bug label Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

2 participants