Actions

Developer Area/Contributing Code/Troubleshooting your Gerrit connection

From Mahara Wiki

< Developer Area‎ | Contributing Code

Troubleshooting your Gerrit connection

This page contains instructions to help you troubleshoot your connection to the Mahara gerrit site, https://reviews.mahara.org . This page may be helpful if you've been following the instructions on these pages but receiving errors:

These instructions assume you are using Ubuntu Linux. They will probably be almost equally applicable to any type of Linux, somewhat helpful in Unix or Mac OS X, and of limited help in Windows.

Step 1: git fetch

The first step to figuring out what's wrong with your connection to gerrit is to run this command. It should be run in your terminal, while in the directory where your Mahara git repository is located.

git fetch

If this is successful, you will see output similar to this, fetching the list of branches from Gerrit.

From ssh://reviews.mahara.org:29418/mahara
 * [new branch]      1.0_STABLE -> gerrit/1.0_STABLE
 * [new branch]      1.10_STABLE -> gerrit/1.10_STABLE
 * [new branch]      1.1_STABLE -> gerrit/1.1_STABLE
 * [new branch]      1.2_STABLE -> gerrit/1.2_STABLE
 * [new branch]      1.3_STABLE -> gerrit/1.3_STABLE
 * [new branch]      1.4_STABLE -> gerrit/1.4_STABLE
 * [new branch]      1.5_STABLE -> gerrit/1.5_STABLE
 * [new branch]      1.6_STABLE -> gerrit/1.6_STABLE
 * [new branch]      1.7_STABLE -> gerrit/1.7_STABLE
 * [new branch]      1.8_STABLE -> gerrit/1.8_STABLE
 * [new branch]      1.9_STABLE -> gerrit/1.9_STABLE
 * [new branch]      15.04_STABLE -> gerrit/15.04_STABLE
 * [new branch]      15.10_STABLE -> gerrit/15.10_STABLE
 * [new branch]      master     -> gerrit/master

If you see that, then you're able to pull successfully. If you see an error, see if it's one of these:

Error 1.1: "fatal: not a git repository"

Do you see this error when you do git fetch gerrit?

fatal: Not a git repository (or any parent up to mount point /var)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

This indicates that you're not running the git command in the location where your mahara git repository is located. The mahara repo will be a directory sitting inside the directory where you did the "git clone" command earlier. It will be named "mahara" unless you renamed it. It will have an "invisible" directory called ".git" in it, which you can see if you run the command "ls -a" while in the directory.

  • If you are following the instructions on the Developer Environment setup page, then your Mahara git repository will be the directory ~/code/mahara. The ~ is a linux shortcut for your home directory; e.g. /home/YOURUSERNAME.
    • 1.1.1. Remember where you put your local mahara git repo.
    • 1.1.2. Locate your local mahara git repo
    • 1.1.3. Just clone a new local mahara git repo

==== Option 1.1.1: Remembering where you put your local mahara git repo.

I don't really have any good advice for this one. ;)

Option 1.1.2: Finding your local Mahara repo

(If you are very new to working with the command-line, it may be helpful to you to know that you can use the cd command to move around into different directories, and cd .. to move into the parent directory of your current directory, and pwd to print your current directory.)

The easiest way to search for Mahara's location on your computer is to use the find command, which will search the files on your computer in real-time. This can take a long time if you search your entire hard drive, so it is best to limit the search to a few specific likely locations. Mahara contains two files called "mahara.php"; searching for those should show you where it's located. (I add "2> /dev/null" to the end of the command to avoid warning messages about being unable to search private directories.)

find ~ /var/www /Library/WebServer /srv/www -name "mahara.php" -type f 2> /dev/null

If this is successful, then you'll see your Mahara directory. It'll be the directory which contains the "htdocs/lib/mahara.php" and "htdocs/lang/en.utf8/mahara.php"

aaronw@vegas:~$ find ~ /var/www /Library/WebServer /srv/www -name "mahara.php" -type f 2> /dev/null
/home/aaronw/code/mahara/htdocs/lib/mahara.php
/home/aaronw/code/mahara/htdocs/lang/en.utf8/mahara.php
# My mahara repo is /home/aaronw/code/mahara

If that doesn't work, then you may have put your Mahara repo somewhere unusual. You can try running find / -name "mahara.php" -type f 2> /dev/null to search your entire filesystem, but it may take several minutes. If you have root access, you can also try updating your "locate" index and using the locate command.

aaronw@vegas:~$ sudo updatedb
[sudo] password for aaronw: <enter your password>
# ... wait several minutes
aaronw@vegas:~$ locate mahara.php

==== Option 1.1.3. Clone a new local copy of mahara ====

It doesn't take long to clone a new copy of Mahara, so sometimes it's best just to do that. (The only downside is you might stumble across your lost copy later and confuse the two.) Just follow the directions you used earlier, on one of the links listed at the top of this page.

=== Error 1.2: Permission denied (publickey). ===

When you run git fetch, do you see this error?

<source lang="bash">
(master)aaronw@vegas:~/code/mahara$ git fetch gerrit
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This means you are failing to connect to Mahara via SSH. There can be several causes for this:

Step 1. Verify you have the right URL and username

In the terminal, run the "git remote-v" command from within your Mahara repo directory, and make sure the listing for the gerrit repo looks like this:

aaron@vegas:~/code/mahara$ git remote -v
gerrit	ssh://[email protected]:29418/mahara (fetch)
gerrit	ssh://[email protected]:29418/mahara (push)
origin	[email protected]:MaharaProject/mahara.git (fetch)
origin	[email protected]:MaharaProject/mahara.git (push)

Importantly, make sure that the part that reads "YOURUSERNAME" is replaced with the username you have registered in your reviews.mahara.org account settings, under the "Profile" section. This may be different from your username on your local filesystem! Also make sure that the URL itself doesn't have any typoes in it.

If there was a problem, then the easiest thing is to use the git remote rm command to remove the incorrect remote listing, and do git remote add again to fix it.

git remote rm gerrit
git remote add gerrit ssh://[email protected]:29418/mahara
git fetch gerrit

Step 2. Verify you've correctly loaded your SSH public key into Gerrit

If the URL is correct, then you'll want to verify your SSH public key is correctly in Gerrit. First, check to see if you have an SSH public key at all. In the terminal, run this command to see whether you have an SSH public key generated:

ls ~/.ssh

You should see (among other things) a file called id_rsa.pub there. If not, then follow the directions here to generate an SSH public/private key pair: Developer Area/Developer Tools#Secure Shell (SSH) Key

If you do have an id_rsa.pub file, then you'll need to make sure you have copied its contents into your reviews.mahara.org account, as described here: Developer Area/Developer Tools#Gerrit code review (reviews.mahara.org). Specifically, you'll need to view the contents of id_rsa.pub (perhaps by running this command in the terminal: cat ~/.ssh/id_rsa.pub, then copy-paste those contents into the "SSH Public Keys" section of your reviews.mahara.org account settings.

Once you've done that, try doing a "git fetch gerrit" again, as described above.

=== Error 1.3: