Skip to content

[R-pkg-devel] Help with a github/Rstudio mess

5 messages · Duncan Murdoch, Ivan Krylov, Chris Evans +1 more

#
I hope this is a legitimate question here.? I have a package of very 
simple functions: https://github.com/cpsyctc/CECPfuns.? For the forseeable
future it's really only to stop me constantly having to rewrite 
functions I use and it is only also used by probably two or three 
colleagues who
also use R and are even less IT/programming/R competent than I am and 
are very happy to use my functions.

I hadn't done any work on it for two years but came back to it yesterday 
and added a function (getCIforQuantiles).? There were warnings about
things that are deprecated now in some of the older functions but 
otherwise things seemed OK.? However, I got a pkgdown error and warning 
after
pushing the updated package to github:

Annotations
1 error and 1 warning
pkgdown
Failed to get R 4.3.1: Failed to get R 4.3.1: Failed to download version 
4.3.1: Error: Unexpected HTTP response: 404
r-lib/actions/setup-r at v1 is deprecated.
r-lib/actions/setup-r at v1 is deprecated. Please update your workflow to 
use the 'v2' version. Also look at the examples at 
https://github.com/r-lib/actions/tree/v2/examples because '@v2' 
workflows are much simpler than 'v1' workflows.

So I tweaked 
https://github.com/cpsyctc/CECPfuns/blob/main/.github/workflows/pkgdown.yaml 
to change
 ?? - uses: r-lib/actions/setup-r at v1
to
 ?? - uses: r-lib/actions/setup-r at v2
rather optimistically hoping that might make the warning go away.

Today I did some work on the new function (trivial, correcting one 
"!is.na(" to the correct "is.na(" !!!).? More importantly, I created the
test-getCIforQuantiles.R file for testthat to test the sanity checks and 
add three simple output checks.

I built the source package locally, committed the changes and tried to 
push the update to github (inside Rstudio) but I get:

 >>> /usr/bin/git push origin HEAD:refs/heads/main
To https://github.com/cpsyctc/CECPfuns.git
 ?! [rejected]??????? HEAD -> main (fetch first)
error: failed to push some refs to 'https://github.com/cpsyctc/CECPfuns.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

OK.? So I try to pull thinking that made sense and that the change to 
pkgdown.yaml on github that I made yesterday is the offending change.

However, when I pull (in Rstudio again) I get this:

 >>> /usr/bin/git pull
fatal: pack has 6 unresolved deltas
fatal: fetch-pack: invalid index-pack output

I have never felt on top of the complexities of git and github but I'm 
clearly way out of my depth.? I am hoping someone here can see what
I need to do to get things back in synch and be able to get back to 
developing the package.

TIA,

Chris
#
I think this isn't the right place to ask for this sort of help. Maybe 
stackoverflow instead?

What I'd do in this case is to rename the local dir holding the 
repository, then clone a new copy from Github.  Assuming that works, 
compare all the files to make sure that you have all recent changes,
commit any that were missed, then throw away the damaged one.

Duncan Murdoch
On 05/07/2023 4:44 a.m., Chris Evans wrote:
#
On Wed, 5 Jul 2023 09:44:26 +0100
Chris Evans <chrishold at psyctc.org> wrote:

            
You are right about this.
I think it should be possible to get your work online if you push it
into a separate branch:

git checkout -b test-getCIforQuantiles
git push -u origin test-getCIforQuantiles

This still leaves the problem of merging it back into "main", but at
least you'll have a separate copy you'll be able to get back to.

Your clone of the repo seems to have become corrupted somehow. People
on the Internet mention that this may be related to "shallow" clones
(made with git clone --depth=...). `git fsck --full` may provide more
information, but will probably not be able to fix the problem. Removing
the "origin" remote and adding it back again may fix the problem, or
not. https://phabricator.wikimedia.org/T46129 is the most informative
discussion of this problem I could find, and they couldn't solve it
either.

If you have any other important local branches, push them to GitHub (in
a similar manner: git push origin LOCAL_BRANCH_NAME:REMOTE_BRANCH_NAME).
Move your current clone of the repository away and create it anew using
`git clone`. Once you have merged the branches into appropriate places,
you will be able to remove them using git branch -d BRANCH_NAME
(locally) and git push origin :BRANCH_NAME (on GitHub).
#
First, apologies for being off topic.? I guess I can see that this was 
pretty pure git/github/Rstudio with hindsight.? I am very leary of
stackoverflow, probably wrongly, but I find such a mix of misinformation 
and showboating there.? By contrast this list is a haven for me
to learn. However, point taken and I will try to be focused on the R 
package side if I post here again (quite possible as so much of this
is at my outer limits in skills and experience).

So huge thanks to Ivan for so much background: not sure if it's 
depressing or reassuring to see that this seems to be an erratic but known
thing.? Huge thanks to Duncan as I decided that I understood more of his 
suggested fix than of Ivan's so I would start there ... and it
simply worked!

Many thanks both and to all who have taught me so much here,

Chris
On 05/07/2023 10:12, Ivan Krylov wrote:
#
If I understand correctly, the errors come from github actions run on github. I think that you should update them first, since github switched to new versions in the meantime.

Georgi Boshnakov

Sent from Outlook for Android<https://aka.ms/AAb9ysg>