startup icon indicating copy to clipboard operation
startup copied to clipboard

.gitignore inside .Rprofile.d

Open Ergodic-Commiter opened this issue 1 year ago • 2 comments

Disclaimer: I just recently started using your package. I find it really great, and I'm still getting the hang of it.

I have setup my local ~/.Rprofile.d And then I added a project one .../my-project/.Rprofile.d

The project profile has:

  • 0-local-profile.R which handles what's found in ~/.Rprofile.d
  • 1-proj-profile.R self contained profile
  • .gitignore to ignore the first 0-local-profile.R

So the issue is that startup() cannot process .gitignore because it is not an R-profile.
And I have two questions:

  • What other way is there to handle project and local profiles in parallel?
  • Is there a way to make this setup work, and ask startup() to simply ignore .gitignore?

Thank you.

Ergodic-Commiter avatar Mar 07 '24 19:03 Ergodic-Commiter

Does startup::startup(all=TRUE) provide what you need?

I don't understand the .gitignore part

HenrikBengtsson avatar Mar 07 '24 22:03 HenrikBengtsson

Thank you for your answer. I'll write in three bullets:

  • Explain what I mean with .gitignore.
  • Tell you about a workaround I found.
  • If you still want to get to the bottom, I'll comment on parameters all=TRUE, paths=c(...)
  1. In the vignette, you mention that file ending with *\.(txt|md|~), *\.(Rhistory|RData|DS_Store) or starting with \.\.* are ignored. I'm thinking along the lines of ignoring .gitignore as well.

I'll make a case, with a -hopefully- simple example.

# ~/.Rprofile
print("My local functions, which other developers don't need or even use.")
print("May include fortunes:fortune(), or set local repository")
# my-proj/R-src/.Rprofile.d/0-local.R
source(~/.Rprofile)  
print("I thought to call them here, since I set up my proj profile.")
# my-proj/R-src/.Rprofile.d/1-package.R
proj_function <- function(x) print("Project uses this function.")
# my-proj/R-src/.Rprofile.d/.gitignore
0-local.R 

This last file throws an error as it is in .Rprofile.d

  1. The workaround is to ignore 0-local.R from an outer .gitignore
# my-proj/R-src/.gitignore
.Rprofile.d/0-local.R

This is very close to ideal, so happy to live with that.

  1. Going back to the ideal solution, I didn't find how to make all=TRUE help.
    But partially found the following does: (using magrittr pipes)
"my-proj/R-src/.Rprofile.d" %>%
    list.files(all.files=TRUE, full.names=TRUE) %>%
    str_subset("/\\.", negate=TRUE) %>%  # Includes /.gitignore and others. 
    rprofile_d(paths=.)

I mean partially, because I can only call rprofile_d like this, but not startup.

So one final question, and one proposal:

i) Is there a parameter to ignore other files (like *.(txt|md|~)?

ii) if you think the .gitignore case is a strong one, I can look into the code and try a Pull Request.

Thank you =D

Ergodic-Commiter avatar Mar 08 '24 18:03 Ergodic-Commiter

This should be fixed in startup (>= 0.21.0-9010).

HenrikBengtsson avatar Jul 29 '24 21:07 HenrikBengtsson