workflowr / workflowr

Organize your project into a research website
https://workflowr.github.io/workflowr
Other
827 stars 106 forks source link

Error when pushing to GitHub #258

Open lrdegeest opened 3 years ago

lrdegeest commented 3 years ago

Thanks for making this package, it looks great.

I followed the directions to set up a new site. I was able to make a new project and create a remote repo with wflow_use_github(). Let's call it "lrdegeest/demo". I'm using workflowr_1.6.2.

However, after running wflow_build() and wflow_publish(), I'm unable to push changes to the remote repository created by wflow_use_github() and deploy the website.

When I ran wflow_use_github("lrdegeest") I asked the package to create the remote repository:

Summary from wflow_use_github():
account: lrdegeest
respository: demo
* The website directory is already named docs/
* Output directory is already set to docs/
* Remote "origin" already set to https://github.com/lrdegeest/memos.git
* Added GitHub link to navigation bar

and when I run wflow_status() it confirms the project is Git tracked:

The current Git status is: working directory clean

But after I update and commit documents with wflow_publish(), I try to push to the remote repo with wflow_git_push("lrdegeest") , and I get an error:

Error: The remote you specified is not one of the remotes available. Run ?wflow_git_remote
to learn how to add this remote.

I confirmed that the origin remote is tracked:

> wflow_git_remote()
The repository has the following remotes set:

   name                                    url
 origin https://github.com/lrdegeest/demo.git

So I checked ?wflow_git_remote and then re-ran the push:

wflow_git_push("origin", "lrdegeest", "demo")

but I get another error:

Error: Push failed for unknown reason.

and I guess the reason is that there is in fact no upstream branch. Because when I run git push in the terminal I get:

fatal: The current branch master has no upstream branch.

Did I miss a step somewhere? Not sure where to go from here.

Session info:

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
jdblischak commented 3 years ago

It's not immediately clear to me what the problem is. Below are some ideas to gain more information for troubleshooting.

  1. Please run the following lines in the R console and return the full output:

    git2r::libgit2_features()
    library(workflowr)
    wflow_git_push()
  2. Run the following in the terminal and return the full output:

    git branch
    git push -u origin master
jdblischak commented 3 years ago

Also note this may have to do with the very recent change by GitHub to remove password authentication when pushing from the command-line. While this has security benefits, it makes it the initial Git setup that much more difficult (and thus harder for tools like workflowr to assist you in the process).

Here are some brief instructions from GitHub. Essentially instead of entering your password when prompted, you copy-paste a Personal Access Token. For that reason you are better off using command line Git, since it will save this for future use. wflow_git_push() is only needed if you have trouble installing Git, and you already have it installed.

lrdegeest commented 3 years ago

Part 1.

> git2r::libgit2_features()
$threads
[1] FALSE

$https
[1] TRUE

$ssh
[1] TRUE

The second part (library(workflowr); wflow_git_push()) ask for my GitHub username (at the command line) and then my password (in a dialogue box).

Part 2.

$ git branch
fatal: not a git repository (or any of the parent directories): .git
$ git push -u origin master
fatal: not a git repository (or any of the parent directories): .git
jdblischak commented 3 years ago
$https
[1] TRUE

This is a good sign. git2r/libgit2 was compiled correctly on your machine to support the HTTPS protocol.

and then my password (in a dialogue box).

What did you enter in the dialogue box? Did you enter your GitHub password or did you copy-paste a personal access token with repo access?

fatal: not a git repository (or any of the parent directories): .git

Git commands only work when run inside the Git repository. You'll need to navigate to the Git repository using cd. If you're not sure where the Git repository is located, you can run getwd() in R and copy paste the working directory. Alternatively if you are using RStudio, you can open Terminal within RStudio, which should automatically be in the project directory.

jdblischak commented 3 years ago

@lrdegeest Any update on this? If you're having issues with GitHub authentication, I suspect other users will have similar issues, so I'd like to determine the source of the problem.

lrdegeest commented 3 years ago

@jdblischak Sorry for the delay, missed your message. So, I did run all the git commands inside the home directory, and that was when I got those errors. Using the personal access token seemed to make things work. My guess is that others will run into the same issue. Maybe it would be helpful to add a note to the documentation?