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

How to play more nicely with file path expansion? #7

Closed
jennybc opened this Issue Dec 13, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@jennybc
Member

jennybc commented Dec 13, 2017

In a recent twitter-storm about project-based thinking and file paths, a really good point was raised that I too have felt (sorry, I can't find the tweet now).

RStudio, for example, does tab completion on filenames within a Project, which is very handy.

But then here::here() expects the path parts separated out into a character vector.

Is there a way to have our cake and eat it too? Could the relative paths produced by RStudio be acceptable to here::here()? Or could there be a helper function or add-in that converts these easy-to-get paths into the proper form?

@krlmlr

This comment has been minimized.

Member

krlmlr commented Dec 13, 2017

I think you can still use the path as one single string in here(), like in here("tests/testthat"). I just checked, this is what RStudio generates when I auto-complete testthat. We have no code that checks for slashes. Maybe we can add an example that clarifies this?

@jennybc

This comment has been minimized.

Member

jennybc commented Dec 13, 2017

Would such paths retain portability to, say, Windows? I guess I’ve always assumed that separate parts was a best practice, but maybe it is unnecessary.

@krlmlr

This comment has been minimized.

Member

krlmlr commented Dec 14, 2017

Windows accept slashes, mostly. In my experience, problems arise if they get converted to backslashes and you try to compare paths and find they're different even if they are the same. So, code that works on Linux/OS X may fail on Windows.

I just checked, here::here("a", "b") returns a path with slashes also on Windows. We could look for backslashes in the path and warn users, but that would be the responsibility of rprojroot.

@krlmlr krlmlr closed this in 60c863f Dec 14, 2017

krlmlr added a commit that referenced this issue Dec 14, 2017

Merge tag 'v0.1-10'
- More explicit documentation for the `...` argument to `here()` (#7).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment