Skip to content

Initializing git in another project from a RStudio session #571

Description

@maelle

I'm opening this after a bug report in the starters previously called pRojects package cc @moldach. In the package we create and set up projects, possibly from RStudio, without opening them. We're encountering an error when trying to do that from RStudio, at the stage where we initialize a git repo, because usethis:::restart_rstudio() fails.

If I run the following lines in RStudio, not from any project

usethis::create_package("coolcool", open = FALSE)
usethis::proj_set(file.path(getwd(), "coolcool"))
usethis::use_git()

I get

> usethis::create_package("coolcool", open = FALSE)
✔ Creating 'coolcool/'Setting active project to '/home/maelle/coolcool'Creating 'R/'Creating 'man/'Writing 'DESCRIPTION'
Package: coolcool
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R (parsed):
    * First Last <first.last@example.com> [aut, cre]
Description: What the package does (one paragraph).
License: What license it uses
Encoding: UTF-8
LazyData: trueWriting 'NAMESPACE'Writing 'coolcool.Rproj'Adding '.Rproj.user' to '.gitignore'Adding '^coolcool\\.Rproj$', '^\\.Rproj\\.user$' to '.Rbuildignore'Setting active project to '<no active project>'
> usethis::proj_set(file.path(getwd(), "coolcool"))
✔ Setting active project to '/home/maelle/coolcool'
> usethis::use_git()
✔ Initialising Git repoAdding '.Rhistory', '.RData' to '.gitignore'
There are 5 files uncommited files:
* '.gitignore'
* '.Rbuildignore'
* 'coolcool.Rproj'
* 'DESCRIPTION'
* 'NAMESPACE'
Is it ok to commit them?

1: For sure
2: Not now
3: No way

Selection: 1Adding filesCommit with message 'Initial commit'
Error in enc2utf8(path) : argument is not a character vector

I've tried running the corresponding usethis internal functions one by one and the exact line causing the error is

usethis:::in_rstudio(usethis::proj_get())

More precisely what fails inside usethis:::in_rstudio is

fs::path_real(proj)
Error in enc2utf8(path) : argument is not a character vector

because proj is NULL.

I'm wondering whether this is something that could be fixed in usethis i.e. making it possible to initialize a git repo in another project, or whether we in starters should rather use git2r functions directly?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorgitgit, GitHub, and CI in general

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions