WeBWorK Main Forum

"Couldn't find branch in remote origin" error message

"Couldn't find branch in remote origin" error message

by Larry Riddle -
Number of replies: 10

When I logged into the admin course recently, I saw this message

The following upgrades are available for your WeBWorK system:
Couldn't find WeBWorK Branch main in remote origin
Couldn't find PG Branch main in remote origin
Couldn't find OPL Branch master in remote origin

This used to work fine, telling me we were up to date with webwork and PG (ver. 2.16). I haven't changed anything in any of the conf files. The default.config file contains the lines

$gitWeBWorKRemoteName = "origin";
$gitWeBWorKBranchName = "main";
$gitPGRemoteName = "origin";
$gitPGBranchName = "main";
$gitLibraryRemoteName = "origin";
$gitLibraryBranchName = "master";

These are identical but commented out in localOverrides.conf.

I haven't had to log in as admin for awhile, so has something changed that I need to address?

In reply to Larry Riddle

Re: "Couldn't find branch in remote origin" error message

by Glenn Rice -
The master branch of the OPL no longer exists. It has been renamed to main. Run the following commands from the webwork-open-problem-library directory to switch to the main branch:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

As to being unable to find the main branches of webwork2 and pg, this may have to do with the remote url for the origin. What does it show if you run "git remote -v" in the webwork2 directory?
In reply to Glenn Rice

Re: "Couldn't find branch in remote origin" error message

by Larry Riddle -
The "git fetch origin" command resulted in the message
fatal: unable to connect to github.com:
github.com[0: 140.82.112.3]: errno=Connection timed out

But when I tried to ping github.com, I got 21 packets transmitted, 21 received, 0% packet loss, time 20028ms.

The "git remote -v" command resulted in
origin git://github.com/openwebwork/webwork2.git (fetch)
origin git://github.com/openwebwork/webwork2.git (push)
In reply to Larry Riddle

Re: "Couldn't find branch in remote origin" error message

by Glenn Rice -
That is what I thought. The git protocol is no longer supported. Run
     git remote set-url origin https://github.com/openwebwork/webwork2.git
from the webwork2 directory, and run
    git remote set-url origin https://github.com/openwebwork/pg.git
from the pg directory to fix this.
You will probably also need to run
    git remote set-url origin https://github.com/openwebwork/webwork-open-problem-library.git
from the webwork-open-problem-library.

In reply to Glenn Rice

Re: "Couldn't find branch in remote origin" error message

by Larry Riddle -
Ok, that had some effect. I was able to successfully run the git fetch command for the OPL. And the "git remote -v" now returns
origin https://github.com/openwebwork/webwork2.git (fetch)
origin https://github.com/openwebwork/webwork2.git (push)

I restarted apache2 just in case that might make a difference. IHowever, when I log in to WeBWorK as admin, I still get the messages about not finding the webwork, pg, and OPL branches in remote origin (with the OPL branch now listed as main). Are there some other configuration settings I need to change? Do I need to changed the line
$gitLibraryBranchName = "master";
to say main instead of master?
In reply to Larry Riddle

Re: "Couldn't find branch in remote origin" error message

by Glenn Rice -
You will need to change the $gitLibraryBranchName to "main" in localOverrides.conf.  All of the branch names there should be "main" now.

So "git fetch" is not working in /opt/webwork/webwork2 or /opt/webwork/pg?


In reply to Glenn Rice

Re: "Couldn't find branch in remote origin" error message

by Larry Riddle -

Glenn, thanks so much for your help here. Greatly appreciated.

Running "git fetch" in the webwork2 directory resulted in

wwadmin@swoop:/opt/webwork/webwork2$ git fetch
remote: Enumerating objects: 4448, done.
remote: Counting objects: 100% (1488/1488), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 4448 (delta 1444), reused 1475 (delta 1443), pack-reused 2960
Receiving objects: 100% (4448/4448), 2.60 MiB | 17.49 MiB/s, done.
Resolving deltas: 100% (3484/3484), completed with 321 local objects.
From https://github.com/openwebwork/webwork2
   48b9feadd..488d48e77  main         -> origin/main
 * [new branch]          WeBWorK-2.17 -> origin/WeBWorK-2.17
error: cannot update the ref 'refs/remotes/origin/develop': unable to append to '.git/logs/refs/remotes/origin/develop': Permission denied
 ! 9bdbc1c5b..2d69c283e  develop      -> origin/develop  (unable to update local ref)

Running "git fetch" in the pg directory resulted in

wwadmin@swoop:/opt/webwork/pg$ git fetch
remote: Enumerating objects: 1177, done.
remote: Counting objects: 100% (490/490), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 1177 (delta 482), reused 484 (delta 482), pack-reused 687
Receiving objects: 100% (1177/1177), 1.72 MiB | 14.96 MiB/s, done.
Resolving deltas: 100% (716/716), completed with 131 local objects.
From https://github.com/openwebwork/pg
   b44b71e8..1b0b5ecd main       -> origin/main
 * [new branch]      PG-2.17    -> origin/PG-2.17
error: cannot update the ref 'refs/remotes/origin/develop': unable to append to '.git/logs/refs/remotes/origin/develop': Permission denied
 ! 8addfac0..7d3bad2e develop    -> origin/develop  (unable to update local ref)

So I assume than means the commands worked. I'm not sure if the reported error in both cases is critical. The permissions on develop are "-rw-r--r-- 1 root    root    581 Jul 23  2021 develop". That date is when I upgraded from 2.15 to 2.16.

But when I log into the course administration course as admin, I still get

The following upgrades are available for your WeBWorK system:
Couldn't find WeBWorK Branch main in remote origin
Couldn't find PG Branch main in remote origin
Couldn't find OPL Branch main in remote origin

so the changes I've made (so far) do not seem to have resolved that issue. In addition, WeBWorK also gives the warning
Argument "" isn't numeric in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/CourseAdmin.pm line 3453.

which seems to be due to not being able to find the OPL branch.

In reply to Larry Riddle

Re: "Couldn't find branch in remote origin" error message

by Glenn Rice -

It sounds like you have some permissions issues in your .git subdirectories.  Most likely that is the result of running a git command as root.  You should never do that.  To fix that run
     sudo chown -R wwadmin:wwadmin .git
in both the /opt/webwork/webwork2 and /opt/webwork/pg directories.

What is the output when you run:
    git log -1 --pretty=format:%at
in /opt/webwork/libraries/webwork-open-problem-library

Also, what is the output when you run:
    ls -l /opt/webwork/webwork2/htdocs/DATA


In reply to Glenn Rice

Re: "Couldn't find branch in remote origin" error message

by Larry Riddle -
Permissions fixed. Thanks.

wwadmin@swoop:/opt/webwork/libraries/webwork-open-problem-library$ git log -1 --pretty=format:%at
1629407085

wwadmin@swoop:/opt/webwork/libraries/webwork-open-problem-library$ ls -l /opt/webwork/webwork2/htdocs/DATA
total 1208
-rw-rw-r-- 1 wwadmin wwadmin 155276 Dec 30 2020 library-directory-tree.json
-rw-rw-r-- 1 wwadmin wwadmin 169639 Dec 30 2020 library-subject-tree.json
-rwxrwxr-x 1 wwadmin wwadmin 70 Jun 23 2015 README
-rw-rw-r-- 1 wwadmin wwadmin 58121 Jul 24 2021 tagging-taxonomy.json
-rw-rw-r-- 1 wwadmin wwadmin 843770 Dec 30 2020 textbook-tree.json

I just reran the git fetch command in webwork2 and pg, and now the result is

wwadmin@swoop:/opt/webwork/webwork2$ git fetch
From https://github.com/openwebwork/webwork2
   9bdbc1c5b..2d69c283e  develop    -> origin/develop

wwadmin@swoop:/opt/webwork/pg$ git fetch
From https://github.com/openwebwork/pg
   8addfac0..7d3bad2e  develop    -> origin/develop
In reply to Larry Riddle

Re: "Couldn't find branch in remote origin" error message

by Glenn Rice -

Are you still getting the messages about not being able to find the branch main in the remote origin in the webwork2/admin course?  I suspect that you are.  In fact, that is all anyone is ever going to get from the webwork2 update notification from now on it seems.  Looking closer at this, it seems that the approach that has been used of having the server execute git commands to determine if upgrades are available is dead in the water.  The server user (usually www-data on Ubuntu) can not run git commands on a repository it does not own.  This is something that has changed recently with git.  There may be workarounds to make it work, but none of them are secure.

I recommend that you disable webwork2 upgrade notifications.   Set "$enableGitUpgradeNotifier = 1;" in localOverrides.conf.

In reply to Glenn Rice

Re: "Couldn't find branch in remote origin" error message

by Larry Riddle -

Yes, I was still getting the messages, but I did turn off the upgrade notifications (I think you meant to write setting it equal to 0, not 1) and now they are gone.

Thank you again, Glenn, for all your help and suggestions.