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
{{ message }}
Repository navigation
Should line ending default to LF in RStudio project files? #1002
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.
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.
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).
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):
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.
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.
Activity
jennybc commentedon Feb 5, 2020
Thoughts @jmcphers?
Some context and back story:
.Rprojfiles sometimes. For now, we do this via a template file we ship inside usethis. If there was an official API for initiating / modifying.Rprojfiles -- perhaps in rstudioapi? -- I would certainly use it instead. Thereby washing my hands of this problem 🙂jmcphers commentedon Feb 5, 2020
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).
jennybc commentedon Feb 6, 2020
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.Rprojfile itself):hadley commentedon Mar 14, 2020
This specifically concerns usethis creating new files, right? Because RStudio will already respect the line endings of existing files.
gaborcsardi commentedon Mar 14, 2020
@hadley I think so, yes, when creating a new project.
hadley commentedon Mar 14, 2020
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.gaborcsardi commentedon Mar 14, 2020
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
in project file (template) would solve this, irrespectively of the global Rstudio setting, OS and git conversion config.
hadley commentedon Mar 14, 2020
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
hadley commentedon Mar 17, 2020
See also #767.
Yet another idea: when you create a project, we set the line ending conversion to the current platform.
Store current platform line ending in use_rstudio()
Store current platform line ending in use_rstudio() (#1072)
Standardize line endings
Update base_rate and exchange_rate by renaming with get_ prefix (#12)