Skip to content

Should line ending default to LF in RStudio project files? #1002

Closed

Description

@gaborcsardi

Should we set the line ending characters to LF in the RStudio project files? Otherwise people might end up with CRLF line endings on Windows, depending on their git settings.

Activity

  1. jennybc commented on Feb 5, 2020

    @jennybc
    Member

    Thoughts @jmcphers?

    Some context and back story:

    • usethis writes .Rproj files sometimes. For now, we do this via a template file we ship inside usethis. If there was an official API for initiating / modifying .Rproj files -- perhaps in rstudioapi? -- I would certainly use it instead. Thereby washing my hands of this problem 🙂
    • We had a few line ending glitches at tidyverse dev day, due to lots of first-time git use by Windows people, with zero config.
  2. jmcphers commented on Feb 5, 2020

    @jmcphers

    There is currently no API for modifying Rproj files. I think it'd be fine to set line ending prefs by editing the file directly (especially if you're creating it yourself).

  3. jennybc commented on Feb 6, 2020

    @jennybc
    Member

    Just to make things crystal clear:

    We're talking about adding a line like this to usethis's default .Rproj, yeah? In which we declare how to end lines for files in this RStudio Project (vs. how we end lines in the .Rproj file itself):

    LineEndingConversion: Posix
    
  4. hadley commented on Mar 14, 2020

    @hadley
    Member

    This specifically concerns usethis creating new files, right? Because RStudio will already respect the line endings of existing files.

  5. gaborcsardi commented on Mar 14, 2020

    @gaborcsardi
    MemberAuthor

    @hadley I think so, yes, when creating a new project.

  6. hadley commented on Mar 14, 2020

    @hadley
    Member

    But the project already exists in the TDD scenario — it's that they're on windows, create a new file using (e.g.) use_r() and that file has windows line endings? But RStudio doesn't seem at all involved in that case.

  7. gaborcsardi commented on Mar 14, 2020

    @gaborcsardi
    MemberAuthor

    Right. Looking at it now, I don't think RStudio keeps the line ending characters. More precisely, maybe with some settings it does, but e.g. if the global option is set to 'Platform native' and the project does not set any option, like in the usethis template, then when editing a file, RStudio might change the line endings for the whole while.

    This is not a problem if git is set up to auto-convert. But it is not set up that way, the commit will have changed line endings.

    I think putting

    LineEndingConversion: Posix
    

    in project file (template) would solve this, irrespectively of the global Rstudio setting, OS and git conversion config.

  8. hadley commented on Mar 14, 2020

    @hadley
    Member

    So there are two problems:

    • If the RStudio default for "line ending conversion" is "native", any edit will change the line endings

    • Any usethis function that creates files will create with the native line ending

  9. hadley commented on Mar 17, 2020

    @hadley
    Member

    See also #767.

    Yet another idea: when you create a project, we set the line ending conversion to the current platform.

  10. added
    featurea feature request or enhancement
    tooling 🔨Internal usethis tooling
    on Mar 17, 2020
  11. added a commit that references this issue on Mar 19, 2020
    af43fbb
  12. added a commit that references this issue on Mar 23, 2020
    f5eb0e3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementtooling 🔨Internal usethis tooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions