14

I'm trying to install tortoiseHG with:

$ sudo dpkg -i tortoisehg_4.8.1-0.1_all.deb
Selecting previously unselected package tortoisehg.  
(Reading database ... 172882 files and directories currently installed.)  
Preparing to unpack tortoisehg_4.8.1-0.1_all.deb ...  
Unpacking tortoisehg (4.8.1-0.1) ...  
dpkg: dependency problems prevent configuration of tortoisehg:  
 tortoisehg depends on mercurial (<< 4.9~); however:  
  Version of mercurial on system is 5.3.2-1+exp1.  
 tortoisehg depends on python-pyqt5; however:  
  Package python-pyqt5 is not installed.  
 tortoisehg depends on python-pyqt5.qsci; however:  
  Package python-pyqt5.qsci is not installed.  
 tortoisehg depends on python:any (<< 2.8); however:  
 tortoisehg depends on python:any (>= 2.7~); however:  

dpkg: error processing package tortoisehg (--install):  
 dependency problems - leaving unconfigured  
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...  
Processing triggers for desktop-file-utils (0.24-1ubuntu2) ...  
Processing triggers for mime-support (3.64ubuntu1) ...  
Processing triggers for hicolor-icon-theme (0.17-2) ...  
Processing triggers for man-db (2.9.1-1) ...  
Errors were encountered while processing:  
 tortoisehg  

How do I resolve those errors?

Kulfy
  • 17,696
ncosta
  • 163
  • TortoiseHg binary packages list Mercurial as a dependency, so it is usually installed for you automatically, as per https://tortoisehg.readthedocs.io/en/latest/intro.html However, https://tortoisehg.bitbucket.io/download/linux.html says you should be able to find Ubuntu packages at https://launchpad.net/~tortoisehg-ppa - . Did you add that ppa to your source repositories? See https://help.launchpad.net/Packaging/PPA/InstallingSoftware – K7AAY Apr 27 '20 at 23:15
  • I suppose the problem is here:

    tortoisehg depends on mercurial (<< 4.9~); however: Version of mercurial on system is 5.3.2-1+exp1.

    – ncosta Apr 28 '20 at 11:01
  • 1
    The real obstacle is python-pyqt5 : There is no "python2-pyqt5" for Ubuntu 20.04 .... so you cannot even build tortoisehg manually. ( https://bbuseruploads.s3.amazonaws.com/d2dca878-d630-4df4-aca5-943486bcfd9a/downloads/ca7cb710-3b87-45ab-9292-db8ad1c03dae/tortoisehg-5.0.2.tar.gz?Signature=tttLzFlPC4f8umjo1Jj9Jh%2FiAPc%3D&Expires=1588075962&AWSAccessKeyId=AKIA6KOSE3BNJRRFUUX6&versionId=IzHHHycUEoi3k1.QtWwP5W_nQthQSzYX&response-content-disposition=attachment%3B%20filename%3D%22tortoisehg-5.0.2.tar.gz%22 ) – Knud Larsen Apr 28 '20 at 13:58
  • I'm currently using jetbrains IDEs graphical interface for mercurial.. (mostly for viewing diffs) maybe you can do the same until someone fixes tortoisehg. Sorry I don't have a better answer right now. – user158443 May 04 '20 at 11:14
  • @K7AAY How do I add the launchpad.net/~tortoisehg-ppa? The ways I tried it always came back with Cannot add PPA ... user or team does not exist – FriendFX Jul 23 '20 at 00:31
  • @KnudLarsen The accepted answer, which says how to get it and run it manually, says to do so with Python 3, so it must be compatible with that. So I don't see how the lack of a Python 2 PyQt package is a problem - a hypothetical thg package for Ubuntu 20.04 could just use the Python 3 PyQt package. – Arthur Tacca Aug 20 '20 at 16:31

6 Answers6

19

Update: I now do have a working package. It is available on github:

https://github.com/glaure/tortoisehg4ubuntu

Please give feedback!

Old: I do not have a working package or snap. But using these instructions, it is rather easy to get tortoisehg working from source.

  1. Check that python --version returns a Python 3 interpreter. If not, you have to change the symlink /usr/bin/python to /usr/bin/python3.

    OK:

    $ python --version
    Python 3.8.2
    

    Not OK:

    $ python --version
    Python 2.7.18rc1
    

    Change the symlink:

    $ sudo rm /usr/bin/python
    $ sudo ln -s /usr/bin/python3 /usr/bin/python
    
  2. pip3 is needed to fulfill all the build dependencies.

    sudo apt install python3-pip build-essential
    
  3. Clone tortoisehg repository.

    hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
    
  4. Change into thg directory.

    cd thg
    
  5. Install PyQt5.

    pip3 install pyqt5
    
  6. Install mercurial.

    pip3 install mercurial
    
  7. Install Qscintilla.

    pip3 install qscintilla
    sudo apt install pyqt5.qsci-dev
    
  8. Lets build tortoisehg for inplace usage.

    make local
    
  9. Start tortoisehg.

    ./thg
    

I got tortoisehg working on three different Ubuntu 20.04 installations using this recipe.

Update: https://github.com/glaure/tortoisehg4ubuntu

Contains scripts for automating the tasks listed above..

Gunther
  • 306
  • 2
  • 3
  • Gunther, you was perfect and solved my problem. Thanks. – ncosta May 04 '20 at 15:19
  • Your approach failed for me: ModuleNotFoundError: No module named 'PyQt5.Qsci'. Any ideas? – axxel May 04 '20 at 20:50
  • I found the issue on my setup: pyqt5 was provided by the python3-pyqt5 package, so pip3 install pyqt5 did nothing. Interestingly the pyqt5.qsci-dev package was not necessary. – axxel May 05 '20 at 07:18
  • @axxel thank you. I will add this to the instructions. – Gunther May 05 '20 at 11:00
  • And one other minor improvement: instead of manually changing the /usr/bin/python symlink better sudo apt install python-is-python3. – axxel May 05 '20 at 15:35
  • Since early August 2020, there are few other steps needed. This is caused by the "release" of Mercurial 5.5, with which Tortoise is apparently incompatible. So, change step 6 to "pip install 'mercurial==5.4'" and add a new step (8.5?) "sudo apt install python3-pyqt5.qsci" (I see @Illa Brik spotted this last one too) – Mark Bradley Aug 04 '20 at 12:36
  • The above worked for me, with a couple caveats. I had to pull the stable branch (append -r stable to the hg pull command) rather than the main branch. And i had to add the python3-pyqt5.qsci package suggested below by user @Ilya Brick. – The Head Rush Sep 04 '20 at 15:16
  • You also need iniparse to edit hgrc files, so also do the following: sudo apt install python3-iniparse – AndrewWhalan Sep 05 '20 at 07:51
  • Thank you for this. But you also need iniparse so tortoise can read the .hgrc: pip3 install iniparse – ACz Nov 24 '20 at 09:55
  • i needed pip3 install QScintilla – C4F Mar 29 '22 at 16:54
4

When I tried to do the flow suggested by Gunter something went wrong and I got an error:

No module named 'PyQt5.Qsci'

None of the installation options proposed previously here worked.

I managed to eliminate it by running

sudo apt-get install python3-pyqt5.qsci 
Zanna
  • 70,465
3

Apart from confirming that the steps described by Gunther work well, I want to add that you also need to install iniparse to ensure TortoiseHg work properly. It needs iniparse to parse and update the Mercurial configuration.

Either

sudo apt-get install python3-iniparse

or

pip3 install iniparse

Also, if you want to make TortoiseHg available as desktop application from menu or so, you can first copy thg into /usr/bin or /usr/local/bin. You must also copy the Python module tortoisehg inside the directory where you built TortoiseHg to one of the paths in PYTHONPATH (PYTHONPATH is the path where Python searches for module files). Otherwise, TortoiseHg won't start with the following error.

$ thg
No module named 'tortoisehg'
abort: couldn't find tortoisehg libraries in [/usr/bin:/usr/lib/python38.zip:/usr/lib/python3.8:/usr/lib/python3.8/lib-dynload:/home/xxx/.local/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.8/dist-packages]

You can do:

sudo cp -R tortoisehg /usr/local/lib/python3.8/dist-packages

Then add a file ~/.local/share/applications/thg.desktop (for current user) or /usr/share/applications/thg.desktop (for system-wide usage).

[Desktop Entry]
Name=TortoiseHg
Exec=/usr/bin/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development

Update to set the Exec to the correct path of thg.

Also see: https://foss.heptapod.net/mercurial/tortoisehg/thg/-/wikis/developers/Linux

Alex
  • 31
  • Please, don't put comments as answers. What happens if the referenced answer gets removed or edited? You should provide a full answer or not answer at all. There will be a time when you have enough reputation to comment until it arrives just try to answer when you know the answer. – PhoneixS Sep 30 '20 at 15:02
3

For those running Ubuntu 20.04 on Windows Subsystem for Linux 2. Assuming you installed and launched an X Server on Windows (e.g. Vcxsrv), on Ubuntu do the following:

  1. Configure the DISPLAY environment variable in ~/.bashrc
IP=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}') 
export DISPLAY=$IP:0.0 
  1. Compile TortoiseHg
sudo apt install mercurial python3-pip build-essential pyqt5.qsci-dev
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo ln -s /usr/bin/pip3 /usr/bin/pip
pip install pyqt5 mercurial qscintilla iniparse
sudo apt install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0
hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
cd thg
make local

You may want to install WSL Windows Toolbar Launcher to launch TortoiseHg from Windows. In this case, create the file /usr/share/applications/tortoisehg.desktop

[Desktop Entry]
Name=TortoiseHg
Exec=/path/to/thg_repo/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development
Icon=/path/to/thg_repo/icons/thg_logo.ico
Marduk
  • 751
1

I decided to do this all with tortoisehg in a virtualenv. So here is a guide to do it that way, along with the desktop file. This is very much based on the guide in the earlier answer, with some bits and pieces from other answers to this question.

First install the required packages using apt:

sudo apt install python3-pip python3-venv build-essential pyqt5.qsci-dev

Then create your virtualenv and start using it:

python3 -m venv ~/.venv/thg
source ~/.venv/thg/bin/activate

(You can create your virtualenv where ever you want.)

Install packages into the virtualenv:

pip install pyqt5 mercurial==5.4 qscintilla iniparse

Note I have pinned mercurial at 5.4 because at the time of writing tortoisehg does not work with 5.5

Then we can clone the thg repository and build it:

hg clone https://foss.heptapod.net/mercurial/tortoisehg/thg
cd thg
make local

At this point we can run it directly

./thg

Or we can run it from anywhere, without activating the virtualenv, by using the python from the virtualenv. You could type the following at the command line, or put it in a shell script, say in ~/bin/

$HOME/.venv/thg/bin/python path/to/thg/thg

If you want to launch it as a desktop app you can put the following in a file at either ~/.local/share/applications/tortoisehg.desktop (just for your user) or at /usr/share/applications/tortoisehg.desktop (for all users of the system).

[Desktop Entry]
Name=TortoiseHg
Exec=/home/youruser/.venv/thg/bin/python /home/youruser/path/to/thg/thg
Type=Application
Terminal=false
Categories=GNOME;GTK;Mercurial;Development
Icon=/home/youruser/path/to/thg/icons/thg_logo.ico

Obviously update the paths on the Exec= and Icon= lines to match your actual path.

Hamish Downer
  • 19,181
1

There is now a snap package of tortoisehg.

sudo snap install tortoisehg --edge

(currently only available on edge (like alpha))

Tom
  • 1,774
  • 1
  • 12
  • 16