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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to report the State of the Project and Working Directory #426

Merged
merged 9 commits into from Aug 8, 2018

Conversation

Projects
None yet
2 participants
@jennybc
Member

jennybc commented Aug 5, 2018

Objective: create a reporter or doctor function that reveals

  • working directory
  • active usethis project
  • active RStudio project

The print() method goes on to make observations about the state of things and to suggest ways to get back to the ideal situation: working directory == active usethis project == active RStudio project.

Intended for use in remote debugging / reprexing, live workshops, writing, when people get into weird situations due to awkward workflow (or a usethis bug).

Questions I have:

  • Overall 馃憤 or 馃憥?
  • Is this a good name? Recall, there are vague plans to add some other reporter/doctor functions.
  • Should I only offer advice on what to do or should there be functions to facilitate?
    • For example, setwd(rstudioapi::getActiveProject()) might deserve nicer packaging. This is equivalent to IDE workflows: Session > Set Working Directory > To Project Directory or Files pane > click on RStudio icon to focus file browser on Project > More ... > Set As Working Directory.
@jennybc

This comment has been minimized.

Show comment
Hide comment
@jennybc

jennybc Aug 6, 2018

Member

Situation normal (no RStudio, because reprex/callr):

library(usethis)

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     NULL
#>     active_rstudio_proj:     NULL
#> 
#> 鈼 There is currently no active usethis project.
#>   usethis attempts to activate a project upon first need.
#>   Call `proj_get()` to explicitly initiate project activation.

proj_get()
#> 鉁 Setting active project to '/Users/jenny/rrr/usethis'
#> /Users/jenny/rrr/usethis

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     '/Users/jenny/rrr/usethis'
#>     active_rstudio_proj:     NULL

Created on 2018-08-05 by the reprex package (v0.2.0.9000).


What this looks like in RStudio

library(usethis)

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     NULL
#>     active_rstudio_proj:     '/Users/jenny/rrr/usethis'
#> 
#> 鈼 There is currently no active usethis project.
#>   usethis attempts to activate a project upon first need.
#>   Call `proj_get()` to explicitly initiate project activation.

proj_get()
#> 鉁 Setting active project to '/Users/jenny/rrr/usethis'
#> /Users/jenny/rrr/usethis

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     '/Users/jenny/rrr/usethis'
#>     active_rstudio_proj:     '/Users/jenny/rrr/usethis'

Creating a much more disordered state, in RStudio:

> devtools::load_all("~/rrr/usethis")
Loading usethis
鉁 Setting active project to '/Users/jenny/rrr/usethis'

> ## set working to directory to NOT this RStudio Project
> setwd("~")

> ## set usethis project to something below tempdir
> usethis:::scoped_temporary_project()
鉁 Switching to a temporary project!
鈼 Restore current project with: `proj_set("/Users/jenny/rrr/usethis")`

> proj_sitrep()
      working_directory:     '/Users/jenny'
    active_usethis_proj:     '/private/var/folders/vr/gzrbtprx6ybg85y5pvwm1ct40000gn/T/Rtmp88agSz/aaa335b7f4aee01'
    active_rstudio_proj:     '/Users/jenny/rrr/usethis'

鈼 Your working directory is not the same as the active usethis project.
  To set working directory to the project: `setwd(proj_get())`
  To activate project in working directory: `proj_set(getwd())`
鈼 Your working directory is not the same as the active RStudio Project.
  To set working directory to the Project: `setwd(rstudioapi::getActiveProject())`
鈼 Your active RStudio Project is not the same as the active usethis project.
  To set usethis project to RStudio Project: `proj_set(rstudioapi::getActiveProject())`
Member

jennybc commented Aug 6, 2018

Situation normal (no RStudio, because reprex/callr):

library(usethis)

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     NULL
#>     active_rstudio_proj:     NULL
#> 
#> 鈼 There is currently no active usethis project.
#>   usethis attempts to activate a project upon first need.
#>   Call `proj_get()` to explicitly initiate project activation.

proj_get()
#> 鉁 Setting active project to '/Users/jenny/rrr/usethis'
#> /Users/jenny/rrr/usethis

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     '/Users/jenny/rrr/usethis'
#>     active_rstudio_proj:     NULL

Created on 2018-08-05 by the reprex package (v0.2.0.9000).


What this looks like in RStudio

library(usethis)

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     NULL
#>     active_rstudio_proj:     '/Users/jenny/rrr/usethis'
#> 
#> 鈼 There is currently no active usethis project.
#>   usethis attempts to activate a project upon first need.
#>   Call `proj_get()` to explicitly initiate project activation.

proj_get()
#> 鉁 Setting active project to '/Users/jenny/rrr/usethis'
#> /Users/jenny/rrr/usethis

proj_sitrep()
#>       working_directory:     '/Users/jenny/rrr/usethis'
#>     active_usethis_proj:     '/Users/jenny/rrr/usethis'
#>     active_rstudio_proj:     '/Users/jenny/rrr/usethis'

Creating a much more disordered state, in RStudio:

> devtools::load_all("~/rrr/usethis")
Loading usethis
鉁 Setting active project to '/Users/jenny/rrr/usethis'

> ## set working to directory to NOT this RStudio Project
> setwd("~")

> ## set usethis project to something below tempdir
> usethis:::scoped_temporary_project()
鉁 Switching to a temporary project!
鈼 Restore current project with: `proj_set("/Users/jenny/rrr/usethis")`

> proj_sitrep()
      working_directory:     '/Users/jenny'
    active_usethis_proj:     '/private/var/folders/vr/gzrbtprx6ybg85y5pvwm1ct40000gn/T/Rtmp88agSz/aaa335b7f4aee01'
    active_rstudio_proj:     '/Users/jenny/rrr/usethis'

鈼 Your working directory is not the same as the active usethis project.
  To set working directory to the project: `setwd(proj_get())`
  To activate project in working directory: `proj_set(getwd())`
鈼 Your working directory is not the same as the active RStudio Project.
  To set working directory to the Project: `setwd(rstudioapi::getActiveProject())`
鈼 Your active RStudio Project is not the same as the active usethis project.
  To set usethis project to RStudio Project: `proj_set(rstudioapi::getActiveProject())`

@jennybc jennybc requested a review from hadley Aug 6, 2018

@hadley

hadley approved these changes Aug 8, 2018

Show outdated Hide outdated NEWS.md
Show outdated Hide outdated R/sitrep.R
Show outdated Hide outdated R/sitrep.R

jennybc added some commits Aug 8, 2018

Merge branch 'master' into proj-sitrep
# Conflicts:
#	NEWS.md

@jennybc jennybc merged commit c86aaa2 into master Aug 8, 2018

3 of 6 checks passed

codecov/patch 16.98% of diff hit (target 62.15%)
Details
codecov/project 60.77% (-1.38%) compared to bc82105
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@jennybc jennybc deleted the proj-sitrep branch Aug 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment