lockedata / starters

R Package πŸ“¦ for initializing projects for various R activities :nut_and_bolt:
https://itsalocke.com/starters/
GNU General Public License v3.0
124 stars 16 forks source link

Github token: Error: The 'path' is not in a git repository #123

Closed moldach closed 5 years ago

moldach commented 5 years ago

Hello again, Thought I'd give the package another try. New error message further along now πŸŽ‰

After the browser opens a window on my github to create new personal access token since the recommended description, travis+tic for moldach/freshPrince, was copied to my clipboard I Ctrl+V that into the field and generate the token (no scope boxes selected; I'm not sure what scopes are and am ignorant of rate limits).

It opens a new browser window saying

Make sure to copy your new personal access token now. You won’t be able to see it again!

The token has an icon with what I can only assume to be a clipboard with an arrow. I clicked this and get the resulting error:

> starters::createTrainingProject("freshPrince")
Creating skeleton
βœ” Setting active project to 'C:/Users/Matthew/Documents/freshPrince'
βœ” Creating 'R/'
βœ” Writing 'freshPrince.Rproj'
βœ” Adding '.Rproj.user' to '.gitignore'
βœ” Setting active project to '<no active project>'
βœ” Setting active project to 'C:/Users/Matthew/Documents/freshPrince'
βœ” Writing 'DESCRIPTION'
Package: freshPrince
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R (parsed):
    * Matthew Oldach <moldach686@gmail.com> [aut, cre]
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Encoding: UTF-8
Language: es
LazyData: true
Initializing packrat project in directory:
- "~/freshPrince"

Adding these packages to packrat:
            _      
    packrat   0.5.0

Fetching sources for packrat (0.5.0) ... OK (CRAN current)
Snapshot written to "C:/Users/Matthew/Documents/freshPrince/packrat/packrat.lock"
Installing packrat (0.5.0) ... 
    OK (downloaded binary)
Initialization complete!
βœ” Writing 'README.Rmd'
βœ” Adding '^README\\.Rmd$' to '.Rbuildignore'
βœ” Adding Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. badge to 'README.Rmd'
● Re-knit 'README.Rmd'
βœ” Initialising Git repo
βœ” Adding '.Rhistory', '.RData' to '.gitignore'
There are 7 uncommitted files:
* '.gitignore'
* '.Rbuildignore'
* '.Rprofile'
* 'DESCRIPTION'
* 'freshPrince.Rproj'
* 'packrat/'
* 'README.Rmd'
Is it ok to commit them?

1: Absolutely not
2: Yup
3: No

Selection: 2
βœ” Adding files
βœ” Commit with message 'First commit of this fabulous project, yowza!'
Trying to create GitHub repo, try 1
βœ” Writing '.travis.yml'
βœ” Adding '^\\.travis\\.yml$' to '.Rbuildignore'
Finished initiating sync with GitHub.
Waiting for sync with GitHub....
Finished sync with GitHub.
Finished activating repo moldach/freshPrince on Travis CI.
βœ” Writing 'tic.R'
βœ” Adding '^tic\\.R$' to '.Rbuildignore'
Finished adding deploy keys on GitHub for repo moldach/freshPrince.
Successfully added public deploy key 'travis+tic' to GitHub for moldach/freshPrince. You should receive a confirmation e-mail from GitHub. Delete the key in the repository's settings to revoke access for that key or when you no longer need it.
Finished adding private environment variable id_rsa to moldach/freshPrince on Travis CI.
Successfully added private deploy key to moldach/freshPrince as secure environment variable id_rsa to Travis CI.
Create a personal access token, make sure that you are signed in as the correct user. The suggested description 'travis+tic for moldach/freshPrince' has been copied to the clipboard. If you use this token only to avoid GitHub's rate limit, you can leave all scopes unchecked. Then, copy the new token to the clipboard, it will be detected and applied automatically. Please visit
  https://github.com/settings/tokens/new
A browser window will be opened.
Waiting for PAT to appear on the clipboard.
Detected PAT, clearing clipboard.
Error: The 'path' is not in a git repository
Oops! An error was found and the `freshPrince` directory was deleted
Error: No root directory found in C:/Users/Matthew/Documents/freshPrince or its parent directories. Root criterion: contains a file `DESCRIPTION` with contents matching `^Package: `
Oops! An error was found and the `freshPrince` directory was deleted
Error: No root directory found in C:/Users/Matthew/Documents/freshPrince or its parent directories. Root criterion: contains a file `DESCRIPTION` with contents matching `^Package: `

Thank you

> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252   
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] usethis_1.4.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0         compiler_3.5.2     later_0.8.0        git2r_0.24.0      
 [5] starters_0.0.2     tools_3.5.2        digest_0.6.18      packrat_0.5.0     
 [9] jsonlite_1.6       evaluate_0.13      praise_1.0.0       memoise_1.1.0.9000
[13] rlang_0.3.1        rstudioapi_0.9.0   curl_3.3           yaml_2.2.0        
[17] xfun_0.4           httr_1.4.0         knitr_1.21         desc_1.2.0        
[21] fs_1.2.6           askpass_1.1        rprojroot_1.3-2    glue_1.3.0        
[25] here_0.1           R6_2.4.0           gh_1.0.1           rmarkdown_1.11    
[29] clipr_0.5.0        purrr_0.3.0        whisker_0.3-2      magrittr_1.5      
[33] backports_1.1.3    travis_0.2.11.9000 clisymbols_1.2.0   promises_1.0.1    
[37] htmltools_0.3.6    assertthat_0.2.0   httpuv_1.4.5.1     openssl_1.2.1     
[41] crayon_1.3.4   
maelle commented 5 years ago

Thanks!

Can you please run the brand-new starters::start_here() function just to check your setup?

Will check the rest when I come back from vacation.

moldach commented 5 years ago

Not sure what's going on here because I have git configured already and have been pushing/pulling from this computer the last couple of days.

It gives me an error about use_git_config (although it's already been done), when I do it again it fails again:

> starters::start_here()
Checking GitHub account can be guessed...
βœ” Your GitHub username is moldach.
Checking git is installed...
βœ” git seems to be installed!
Checking gitconfig...
● gitconfig not set yet. Use this code (copied to clipboard): use_git_config(user.name = 'Jane Doe', user.email = 'jane@example.com')
Error: Set your gitconfig then run starters::start_here() again.
In addition: Warning message:
In names(git2r::config()$global) == c("user.email", "user.name") :

 Show Traceback

 Rerun with Debug
 Error: Set your gitconfig then run starters::start_here() again. 
> use_git_config(user.name = 'Matthew J. Oldach', user.email = 'moldach@ucalgary.ca')
> start_here()
Checking GitHub account can be guessed...
βœ” Your GitHub username is moldach.
Checking git is installed...
βœ” git seems to be installed!
Checking gitconfig...
● gitconfig not set yet. Use this code (copied to clipboard): use_git_config(user.name = 'Jane Doe', user.email = 'jane@example.com')
Error: Set your gitconfig then run starters::start_here() again.
In addition: Warning message:
In names(git2r::config()$global) == c("user.email", "user.name") :

 Show Traceback

 Rerun with Debug
 Error: Set your gitconfig then run starters::start_here() again. 

P.S. FYI the start::here() function wasn't exported when I installed so I sourced it locally

maelle commented 5 years ago

Oh sorry. What does git2r::config()$global return?

moldach commented 5 years ago

It returns the same information for my Name and Public email (on Github personal settings) or as git config --global user.email or git config --global user.name, with the addition of the credential.helper = wincred field:

> git2r::config()$global
$credential.helper
[1] "wincred"

$user.email
[1] "moldach@ucalgary.ca"

$user.name
[1] "Matthew J. Oldach"
maelle commented 5 years ago

@moldach I don't think the error is at the GitHub token stage but a bit later and I'm trying to find out exactly where. In any of your working RStudio projects with a git repo could you run

library(git2r)
repo = repository(".")

and see whether you get the same error message?

It looks a bit like https://github.com/ropensci/git2r/issues/334 so we shall see.

maelle commented 5 years ago

oh now I can reproduce the bug :dancer:

maelle commented 5 years ago

@moldach I've made a PR to travis, it was merged so please re-install it.

devtools::install_github("ropenscilabs/travis")

things should work... at least until the next error message! :wink: Thanks again for the bug report. I'll look into start_here() now.

maelle commented 5 years ago

@moldach now start_here() 1) is exported 2) should work.

Another question, can I add you as a contributor ("ctb") of this package? Your bug reports have been most helpful.

moldach commented 5 years ago

Awesome, everything ran smoothly! starters::start_here() was exported and finished with an All set now! πŸ˜„

Next I ran starters::create_analysis_project() and this time when it's expecting the PAT to appear on clipboard it detected it, added travis build status badge to README.Rmd and made the skeleton of the project.

Not sure if the very last part is the desired result though? It seems to have set the active project to my root and not the project I created which would happen if you created a new project through RStudioπŸ€”

βœ” Adding '^tic\\.R$' to '.Rbuildignore'
Authenticating with GitHub
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Finished adding deploy keys on GitHub for repo moldach/spikesProject.
Successfully added public deploy key 'travis+tic' to GitHub for moldach/spikesProject. You should receive a confirmation e-mail from GitHub. Delete the key in the repository's settings to revoke access for that key or when you no longer need it.
Finished adding private environment variable id_rsa to moldach/spikesProject on Travis CI.
Successfully added private deploy key to moldach/spikesProject as secure environment variable id_rsa to Travis CI.
Create a personal access token, make sure that you are signed in as the correct user. The suggested description 'travis+tic for moldach/spikesProject' has been copied to the clipboard. If you use this token only to avoid GitHub's rate limit, you can leave all scopes unchecked. Then, copy the new token to the clipboard, it will be detected and applied automatically. Please visit
  https://github.com/settings/tokens/new
A browser window will be opened.
Waiting for PAT to appear on the clipboard.
Detected PAT, clearing clipboard.
Finished adding private environment variable GITHUB_PAT to moldach/spikesProject on Travis CI.
βœ” Adding Travis build status badge to 'README.Rmd'
● Re-knit 'README.Rmd'
βœ” Setting active project to 'C:/Users/Matthew/Documents'

Another question, can I add you as a contributor ("ctb") of this package? Your bug reports have been most helpful.

Yes please, and thank you very much.

I'll try out a few of the other functions (i.e. create_basic_project(), create_package_project() , create_training_project(),) to see if they work as well.

I noticed from the createBasicProject.R script this line of code:

#' @describeIn createPackageProject aesthetic addition for continuity purposes
create_package_project = createPackageProject

Mind me asking what the point of making two functions do the same thing? Is this for people who like the _ syntax versus camelCase, or for another reason?

maelle commented 5 years ago

:wave: @moldach!

Regarding the active project, it's because the new project is created elsewhere. Whilst setting it up we need to set the active project to the new project, in the console where you have your current project, so after setting it up we re-set the active project to the initial project. To open the new project you'd open a new RStudio session. If you think a feature to open the new project afterwards would be useful, can you open a new issue (or make a PR)? It'd be an argument for all 4 creation functions,open, FALSE by default, and when it is TRUE we'd get

if(open){
  rstudioapi::openProject(file.path(folder, name), newSession=TRUE)
}

I've now added you as ctb. :-)

Exactly, we have added the new functions with snake case names for folks who prefer that.