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

Redefine proj_path_prep() #905

Open
jennybc opened this issue Oct 1, 2019 · 4 comments
Open

Redefine proj_path_prep() #905

jennybc opened this issue Oct 1, 2019 · 4 comments
Labels
feature a feature request or enhancement paths 🚶‍♂️ tooling 🔨 Internal usethis tooling

Comments

@jennybc
Copy link
Member

jennybc commented Oct 1, 2019

Reconsider @jimhester's proposal from #479

Define proj_path_prep() as fs::path_abs(fs::path_expand()) instead of fs::path_real().

I think, in general, there is less path agony on Windows this way (will come back with concrete examples).

The new agony will be that rprojroot calls normalizePath(), so this issue is really to investigate how hard it would be to finesse that.

@jennybc
Copy link
Member Author

jennybc commented Oct 1, 2019

This is a mess:

> library(usethis)
> proj_get()
✔ Setting active project to '//vmware-host/Shared Folders/win10/frommacos'
//vmware-host/Shared Folders/win10/frommacos
> proj_sitrep()
*   working_directory: 'Z:/win10/frommacos'
* active_usethis_proj: '//vmware-host/Shared Folders/win10/frommacos'
* active_rstudio_proj: 'Z:/win10/frommacos'Your working directory is not the same as the active usethis project.
  Set working directory to the project: `setwd(proj_get())`
  Set project to working directory:     `proj_set(getwd())`Your active RStudio Project is not the same as the active usethis project.
  Set usethis project to RStudio Project: `proj_set(rstudioapi::getActiveProject())`
  Restart RStudio in the usethis project: `rstudioapi::openProject(proj_get())`
  Open the usethis project in a new instance of RStudio: `proj_activate(proj_get())`

I am able to create almost all possible combinations of these 3 paths being Z:/ or UNC style. So perhaps the sitrep function itself should become aware of that? But, in general, making Z:/ style the default seems preferable to me.

@jennybc
Copy link
Member Author

jennybc commented Oct 1, 2019

Various fs functions struggle more with UNC paths than drive paths:

> library(usethis)
> create_project("Z:/win10/jkl")
✔ Creating 'Z:/win10/jkl/'Setting active project to '//vmware-host/Shared Folders/win10/jkl'
 Error: [ENOENT] Failed to make directory '//vmware-host/Shared Folders': no such file or directorySetting active project to '<no active project>'
> fs::dir_create("Z:/win10/jkl")

It seems I would explore fewer fs edge cases if I stuck with drive or DOS paths.

@hadley hadley added feature a feature request or enhancement tooling 🔨 Internal usethis tooling labels Oct 16, 2019
@nalsalam
Copy link

This is a mess:

> library(usethis)
> proj_get()
✔ Setting active project to '//vmware-host/Shared Folders/win10/frommacos'
//vmware-host/Shared Folders/win10/frommacos
> proj_sitrep()
*   working_directory: 'Z:/win10/frommacos'
* active_usethis_proj: '//vmware-host/Shared Folders/win10/frommacos'
* active_rstudio_proj: 'Z:/win10/frommacos'Your working directory is not the same as the active usethis project.
  Set working directory to the project: `setwd(proj_get())`
  Set project to working directory:     `proj_set(getwd())`Your active RStudio Project is not the same as the active usethis project.
  Set usethis project to RStudio Project: `proj_set(rstudioapi::getActiveProject())`
  Restart RStudio in the usethis project: `rstudioapi::openProject(proj_get())`
  Open the usethis project in a new instance of RStudio: `proj_activate(proj_get())`

I am able to create almost all possible combinations of these 3 paths being Z:/ or UNC style. So perhaps the sitrep function itself should become aware of that? But, in general, making Z:/ style the default seems preferable to me.

Yes, this is a problem for me. I created an issue in fs (r-lib/fs#402) but maybe it is more properly here.

@chriscarrollsmith
Copy link

I also encountered this problem on Windows.

...
ℹ Your working directory is not the same as the active RStudio Project. 
☐ Set working directory to the Project:
  `setwd(rstudioapi::getActiveProject())`.
...
> setwd(rstudioapi::getActiveProject())
Error in setwd(rstudioapi::getActiveProject()) : 
  cannot change working directory
> rstudioapi::getActiveProject()
[1] "/c:/Users/chris/Software/R/Projects/countryaggr"
> getwd()
[1] "C:/Users/chris/Software/R/Projects/countryaggr"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement paths 🚶‍♂️ tooling 🔨 Internal usethis tooling
Projects
None yet
Development

No branches or pull requests

4 participants