-
Notifications
You must be signed in to change notification settings - Fork 3
/
session-usethis-errors.qmd
151 lines (100 loc) · 4.48 KB
/
session-usethis-errors.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
title: "Introduction to Git and GitHub"
subtitle: "Session - {usethis} errors"
---
## Error in "stop_bad_github_remote_config()"
If you get this
```
✔ Setting active project to '/cloud/project'
Error in `stop_bad_github_remote_config()`:
! Unsupported GitHub remote configuration: 'no_github'
• Host = NA
• origin = <not configured>
• upstream = <not configured>
• Neither 'origin' nor 'upstream' is a GitHub repo.
Read more about the GitHub remote configurations that usethis supports at:
'https://happygitwithr.com/common-remote-setups.html'
Run `rlang::last_trace()` to see where the error occurred.
```
It's because GitHub connections (including personal access tokens) haven't been set up.
The {usethis} functions won't work though as they require a connection to GitHub
You can use Git locally (F5 refresh in the Cloud).
## If they continue
In the Terminal (starts with `$` on the command line
```{bash}
git remote -v
```
Gives details of the remote branch, if nothing shows and both the `push` and `pull` buttons in RStudio are grey
```{bash}
git remote add origin <remote_URL>
```
with the url coming from the HTTPS url from GitHub's green button `Code` on the repo.
## Posit Cloud repos are called `project`
Particularly because Posit Cloud repos are called `project`, if you have set up a connection to GitHub before you will geta message
> Error: Repo 'Lextuga007/project' already exists on 'github.com'
It's best to delete the GitHub repo (check for any work you want to keep!) and start again when using Posit Cloud.
In GitHub, under the Settings tab and scroll down to the `Danger Zone`.
You may need to Restart the R session as a refresh.
## Pop up for username for `https://github.com`
This is because the Personal Access Token hasn't been set up correctly.
It might have expired or deleted.
Best resolved by resetting the PAT details.
## Unable to confirm the GitHub remote configuration is "pull request ready"
```
Unable to confirm the GitHub remote configuration is "pull request ready".
You probably need to configure a personal access token for 'github.com'.
See `gh_token_help()` for help.
(Or maybe we're just offline?)
Unexpected GitHub remote configuration: 'maybe_ours_or_theirs'
Host = 'https://github.com'
origin = 'nhs-r-community/intro-git-github'
upstream = <not configured>
'origin' is a GitHub repo and 'upstream' is either not configured or is not a GitHub repo.
We may be offline or you may need to configure a GitHub personal access
token. `gh_token_help()` can help with that.
Read more about what this GitHub remote configurations means at:
'https://happygitwithr.com/common-remote-setups.html'
1: Yes, I want to proceed. I know what I'm doing.
2: No, I want to stop and straighten out my GitHub remotes first.
```
Trying `pr_pull()` may give this:
```
Error: Unable to get GitHub info for these remotes: 'origin'
Are we offline? Is GitHub down? Has the repo been deleted?
Otherwise, you probably need to configure a personal access token (PAT) for 'github.com'
See `?gh_token_help` for advice
```
which suggests the PAT has been removed/deleted or is unobtainable by the project.
It may be that an alternative place to save the PAT is needed
## Storing the PAT in .Renviron
This is no longer a recommended way of saving a PAT but is required in some circumstances (linux servers)
```{r}
usethis::edit_r_environ()
```
will open a blank document in RStudio
## Text in .Renviron
With no spaces, returns or any spacing the PAT is added to the file like
> GITHUB_PAT=ghp_gobbledygookgeneratedbygithub
Restart the R session (Ctrl+Shift+F10)
Running `Sys.getenv("GITHUB_PAT")` in the Console will show the PAT code
## "Error in libgit2::git_branch_create"
With the error:
>Error in libgit2::git_branch_create :
the given reference name 'refs/heads/Add render specifics to _quarto.yml' is not valid
Check that the name given in the command `usethis::pr_init()` is in the branch format
```{r}
usethis::pr_init("update-quarto-yml")
```
not like a commit format (with spaces often)
```{r}
usethis::pr_init("Add render specifics to _quarto.yml")
```
## Error: The `pr_*()` functions facilitate pull requests.
This may be where the function `pr_push()` is being used but from the main branch
If changes are required (for example to reinstate the greyed out `push` and `pull` in RStudio)
On the Git Terminal (where the command line starts with `$`)
```{bash}
git push --set-upstream origin main
```
Refresh the RStudio git pane to ensure the buttons are no longer greyed out
## End session