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

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

Closed
gaborcsardi opened this issue Jan 31, 2020 · 9 comments · Fixed by #1072
Closed

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

gaborcsardi opened this issue Jan 31, 2020 · 9 comments · Fixed by #1072
Labels
feature tooling 🔨

Comments

@gaborcsardi
Copy link
Contributor

@gaborcsardi gaborcsardi commented Jan 31, 2020

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.

@jennybc
Copy link
Member

@jennybc jennybc commented Feb 5, 2020

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.

@jmcphers
Copy link

@jmcphers jmcphers commented 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
Copy link
Member

@jennybc jennybc commented 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 .Rproj file itself):

LineEndingConversion: Posix

@hadley
Copy link
Member

@hadley hadley commented Mar 14, 2020

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

@gaborcsardi
Copy link
Contributor Author

@gaborcsardi gaborcsardi commented Mar 14, 2020

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

@hadley
Copy link
Member

@hadley hadley commented 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
Copy link
Contributor Author

@gaborcsardi gaborcsardi commented 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

LineEndingConversion: Posix

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

@hadley
Copy link
Member

@hadley hadley commented 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
Copy link
Member

@hadley hadley commented Mar 17, 2020

See also #767.

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

@hadley hadley added feature tooling 🔨 labels Mar 17, 2020
hadley added a commit that referenced this issue Mar 19, 2020
Minimal implementation for discussion - I'll add docs and tests if we agree that this approach makes sense.

Fixes #1002
hadley added a commit that referenced this issue Mar 23, 2020
* Set default line ending in `use_rstudio()`. Fixes #1002
* Respect current project line ending in `write_utf8()`. Fixes #767.
philip-khor added a commit to j450h1/bnmr that referenced this issue Oct 16, 2020
philip-khor added a commit to philip-khor/bnmr that referenced this issue Oct 16, 2020
* Update base_rate and exchange_rate by renaming with get_ prefix

* reduce diffs, export functions, rerender docs and pkgdown site

* use .Deprecated

per https://r-pkgs.org/release.html

* use template to generate docs for deprecated functions

satisfy R_CMD_CHECK

* make R CMD CHECK happy :(

* capitalization

* fix capitalization again

* Undo changes to Rproj from using different platforms

* Standardize line endings

r-lib/usethis#1002

Co-authored-by: Philip Khor <philip10khor@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature tooling 🔨
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants