'XML parsing error when trying to configure gitweb after installing BugZilla perl dependencies

I installed and configured git, gitolite and gitweb on a personal sever it works fine at the begining and I had my web view on my repositories. but when I tried to install BugZilla (with all perl dependencies) I had a an error message on the racine of my gitweb URL:

XML Parsing Error: XML or text declaration not at start of entity Location: http://xxx.xxx.xx.xx/gitweb/ Line Number 22, Column 1:

The generated web page (firebug):

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<!-- git web interface version 1.7.10.4, (C) 2005-2006, Kay Sievers <[email protected]>, Christian Gierke -->
<!-- git core binaries version 1.7.10.4 -->
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="generator" content="gitweb/1.7.10.4 git/1.7.10.4"/>
<meta name="robots" content="index, nofollow"/>
<title>xxx.xxx.xx.xx Git</title>
<link rel="stylesheet" type="text/css" href="static/gitweb.css"/>
<link rel="alternate" title="xxx.xxx.xx.xx Git projects list" href="/gitweb/?a=project_index" type="text/plain; charset=utf-8" />
<link rel="alternate" title="xxx.xxx.xx.xx Git projects feeds" href="/gitweb/?a=opml" type="text/x-opml" />
<link rel="shortcut icon" href="static/git-favicon.png" type="image/png" />
</head>
<body>
<div class="page_header">
<a href="http://git-scm.com/" title="git homepage"><img alt="git" class="logo" height="27" src="static/git-logo.png" width="72" /></a><a href="/gitweb/">projects</a> / </div>
<div class="projsearch">
Content-type: text/html

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<!-- git web interface version 1.7.10.4, (C) 2005-2006, Kay Sievers <[email protected]>, Christian Gierke -->
<!-- git core binaries version 1.7.10.4 -->
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="generator" content="gitweb/1.7.10.4 git/1.7.10.4"/>
<meta name="robots" content="index, nofollow"/>
<title>xxx.xxx.xx.xx Git</title>
<link rel="stylesheet" type="text/css" href="static/gitweb.css"/>
<link rel="shortcut icon" href="static/git-favicon.png" type="image/png" />
</head>
<body>
<div class="page_header">
<a href="http://git-scm.com/" title="git homepage"><img alt="git" class="logo" height="27" src="static/git-logo.png" width="72" /></a><a href="/gitweb/">projects</a> / </div>
<div class="page_body">
<br /><br />
500 - Internal Server Error
<br />
<hr />
Can't locate object method &quot;startform&quot; via package &quot;CGI&quot; at /usr/share/gitweb/index.cgi line 5267.

</div>
<div class="page_footer">
<a class="rss_logo" href="/gitweb/?a=opml">OPML</a> <a class="rss_logo" href="/gitweb/?a=project_index">TXT</a>
</div>
<script type="text/javascript" src="static/gitweb.js"></script>
<script type="text/javascript">
window.onload = function () {
    var tz_cookie = { name: 'gitweb_tz', expires: 14, path: '/' };
    onloadTZSetup('local', tz_cookie, 'datetime');
};
</script>
</body>
</html>

I think that this error is due to the perl modules installed when I tried to install BugZilla.

How to de-install all perl modules and re-install default modules?

I use Apache as web server.

Does anyone have any idea on how to solve this?

UPDATE1:

My perl version is : v5.14.2

CGI version: 4.21



Solution 1:[1]

Had the same error message for gitweb with apache on Ubuntu after upgrading to 16.04. As stated by Slion, changing the two instances of "startform" to "start_form" in gitweb.cgi worked and I could use gitweb as before.

Solution 2:[2]

In my case, the commands below worked like a charm on Arch Linux.

$ sudo pacman -Rs perl-cgi #uninstalls
$ sudo pacman -S perl #updates to the latest version
$ sudo pacman -S perl-cgi #installs

(You may think this is the same as sudo pacman -S perl-cgi but, in my case, perl-cgi was already latest. Though perhaps just upgrading perl will do, the commands above are what I did anyway.)

I found this solution because I encountered the error on my server (with perl 5.30.2) after succeeding a simple test on my main desktop computer (with perl 5.30.3).

Solution 3:[3]

On Windows with either ActivePerl or Strawberry 5.22 I was getting that same error. Installing CGI module and replacing both "startform" instances in gitweb.cgi with "start_form" fixed the problem.

However I still could not get gitweb to list my projects for some reason. Git version is 1.9.5.

Solution 4:[4]

This error () might not be present with Git 2.36 (Q2 2022, seven years later), which removes the unneeded <meta http-equiv=content-type...> from gitweb output.

See commit a262585, commit 943fd02 (08 Mar 2022) by Jason Yundt (Jayman2000).
(Merged by Junio C Hamano -- gitster -- in commit bc3838b, 21 Mar 2022)

gitweb: remove invalid http-equiv="content-type"

Signed-off-by: Jason Yundt

Before this change, gitweb would generate pages which included:

<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>

When a meta's http-equiv equals "content-type", the http-equiv is said to be in the "Encoding declaration state".
According to the HTML Standard:

The Encoding declaration state may be used in HTML documents, but elements with an http-equiv attribute in that state must not be used in XML documents.

(Source)

This change removes that meta element since gitweb always generates XML documents.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 djoerch
Solution 2
Solution 3 Slion
Solution 4 VonC