Actions

Difference between revisions of "Developer Area/Contributing Code/Troubleshooting your Gerrit connection"

From Mahara Wiki

< Developer Area‎ | Contributing Code
Line 139: Line 139:
 
Once you've done that, try doing a "git fetch gerrit" again, as described above.
 
Once you've done that, try doing a "git fetch gerrit" again, as described above.
  
=== Error 1.3:
+
=== Error 1.3: "Connection timed out." ===
 +
 
 +
When you run '''git fetch gerrit''' do you see this?
 +
 
 +
<source lang="bash">
 +
(master)[email protected]:~/code/mahara$ git fetch gerrit
 +
ssh: connect to host reviews.mahara.org port 29418: Connection timed out
 +
fatal: Could not read from remote repository.
 +
 
 +
Please make sure you have the correct access rights
 +
and the repository exists.
 +
</source>
 +
 
 +
This error indicates that you were not able to connect to reviews.mahara.org on port 29418, as required by its Gerrit git+ssh URL. If you're seeing this problem, you should:
 +
 
 +
'''Step 1:''' Verify you have the right URL and username. See the directions for this in the previous "Error 1.2" section. In particular, make sure you have the port number "29418" correct.
 +
 
 +
'''Step 2:''' Check your network connection. Can you connect to the Internet generally? Can you load up https://reviews.mahara.org in your browser?
 +
 
 +
'''Step 3:''' If you can connect to https://reviews.mahara.org in your browser, is it possible you're behind a firewall that is blocking your access to port 29418? You can check using the command "telnet reviews.mahara.org 29418". If you are successful, you will see output like below. Note that to quit telnet you'll need to press the "Control" key and the "]" key, and then type "quit" and press return.
 +
 
 +
<source lang="bash">
 +
(master)[email protected]:~/code/mahara$ telnet reviews.mahara.org 29418
 +
Trying 202.78.242.17...
 +
Connected to reviews.mahara.org.
 +
Escape character is '^]'.
 +
SSH-2.0-GerritCodeReview_2.11 (SSHD-CORE-0.14.0)
 +
^]
 +
 
 +
telnet> quit
 +
Connection closed.
 +
</source>
 +
 
 +
If you are unsuccessful, you will see Telnet say "Trying 202.78.242.17..." for a long time with no further output. (It may go on to give a message about the connection timing out). You can press Control-C to quit this state.
 +
 
 +
'''Step 4:''' If you can't access reviews.mahara.org on port 29418, but you can access https://reviews.mahara.org, then you can try connecting via HTTPS intead of SSH. See the section at the bottom of this page.

Revision as of 14:47, 13 November 2015

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 gerrit

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 gerrit

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"

[email protected]:~$ 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.

[email protected]:~$ sudo updatedb
[sudo] password for aaronw: <enter your password>
# ... wait several minutes
[email protected]:~$ 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?

(master)[email protected]:~/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:

[email protected]:~/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: "Connection timed out."

When you run git fetch gerrit do you see this?

(master)[email protected]:~/code/mahara$ git fetch gerrit
ssh: connect to host reviews.mahara.org port 29418: Connection timed out
fatal: Could not read from remote repository.

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

This error indicates that you were not able to connect to reviews.mahara.org on port 29418, as required by its Gerrit git+ssh URL. If you're seeing this problem, you should:

Step 1: Verify you have the right URL and username. See the directions for this in the previous "Error 1.2" section. In particular, make sure you have the port number "29418" correct.

Step 2: Check your network connection. Can you connect to the Internet generally? Can you load up https://reviews.mahara.org in your browser?

Step 3: If you can connect to https://reviews.mahara.org in your browser, is it possible you're behind a firewall that is blocking your access to port 29418? You can check using the command "telnet reviews.mahara.org 29418". If you are successful, you will see output like below. Note that to quit telnet you'll need to press the "Control" key and the "]" key, and then type "quit" and press return.

(master)[email protected]:~/code/mahara$ telnet reviews.mahara.org 29418
Trying 202.78.242.17...
Connected to reviews.mahara.org.
Escape character is '^]'.
SSH-2.0-GerritCodeReview_2.11 (SSHD-CORE-0.14.0)
^]

telnet> quit
Connection closed.

If you are unsuccessful, you will see Telnet say "Trying 202.78.242.17..." for a long time with no further output. (It may go on to give a message about the connection timing out). You can press Control-C to quit this state.

Step 4: If you can't access reviews.mahara.org on port 29418, but you can access https://reviews.mahara.org, then you can try connecting via HTTPS intead of SSH. See the section at the bottom of this page.