Search code examples
linuxgitubuntubeyondcompare

Locate an executable file of newly installed application "Beyond Compare"


Some source control viewers allow the user to choose a non-default application to resolve conflicts during merges. For that I need to specify the location of my desired tool, So I installed Beyond Compare from Ubuntu Software. But I couldn't find it's installed base folder.

Tried to figure it out by checking attributes of a running instance of "Beyond Compare" using ps -ef. Indeed, one of the running processes spawned from file /snap/bcompare/90/usr/bin/bcompare which is from type bash script.

I assume this is the file that called once double clicking on the Beyond Compare icon in the application list.

I opened the file and saw that it points to $SNAP/usr/lib/beyondcompare/Bcompare but I cannot find the setting of $SNAP.

So I searched for the application name in the suffix ("/usr/lib/beyondcompare.. ) but found nothing.

Eventually I've found the missing executable Link in /snap/bin/bcompare,

zohark@ubuntu:/snap/bin$ ls -ltr /snap/bin/bcompare 
lrwxrwxrwx 1 root root 13 Nov 14 00:21 /snap/bin/bcompare -> /usr/bin/snap

When I run it directly, I get beyond compare, but if I run the linked file /usr/bin/snap I get the snap tool.

My questions are

  1. Why does the installer, choose a location outside /usr/share/application of this tool?

  2. Where can I see the flow of double clicking an application up to the stage where it's running? Where it set some environment variables like $SNAP?.

Thanks


Solution

    1. Since version 16.04, Canonical decided to introduce snap, their own package management system, to Ubuntu in addition to the existing deb/apt which comes from Debian. It is mainly used for non-free (non open-source, i.e. proprietary) software such as Beyond Compare, and other software which were never added to Ubuntu deb* repositories.

    I expect they decided to have snap install package to some other place than the default because it helps prevent certain kinds of conflicts that could be caused by the coexistence of files managed by different package management systems in the same directory(ies).


    1. Application icons actually correspond to .desktop files. Those files are usually placed in dedicated folders where file managers and desktop environments will be able to find them. The folders I'm aware of are the following:

      • /usr/share/applications
      • /var/lib/snapd/desktop
      • ~/.local/share/applications
      • /etc/xdg/autostart/

    The below command should be able to find about all .desktop files on your system.

    find /opt /snap /usr ~ /etc /lib* /srv /var /sbin /bin -name '*.desktop' 2>/dev/null
    

    A .desktop file looks like this:

    $ cat /usr/share/applications/filezilla.desktop
    [Desktop Entry]
    Name=FileZilla
    GenericName=FTP client
    GenericName[da]=FTP-klient
    GenericName[de]=FTP-Client
    GenericName[fr]=Client FTP
    Comment=Download and upload files via FTP, FTPS and SFTP
    Comment[da]=Download og upload filer via FTP, FTPS og SFTP
    Comment[de]=Dateien über FTP, FTPS und SFTP übertragen
    Comment[fr]=Transférer des fichiers via FTP, FTPS et SFTP
    Exec=filezilla
    Terminal=false
    Icon=filezilla
    Type=Application
    Categories=Network;FileTransfer;
    Version=1.0
    

    For applications whose location in unusual, the Exec= entry will usually be an absolute path, so you know where the file to execute actually is. This is the case for Visual Studio Code:

    $ cat /usr/share/applications/code.desktop 
    [Desktop Entry]
    Name=Visual Studio Code
    Comment=Code Editing. Redefined.
    GenericName=Text Editor
    Exec=/usr/share/code/code --unity-launch %F
    Icon=code
    Type=Application
    StartupNotify=true
    StartupWMClass=Code
    Categories=Utility;TextEditor;Development;IDE;
    MimeType=text/plain;inode/directory;
    Actions=new-empty-window;
    Keywords=vscode;
    
    [Desktop Action new-empty-window]
    Name=New Empty Window
    Exec=/usr/share/code/code --new-window %F
    Icon=code
    

    If you want to know the value of the variable $SNAP, I expect the best thing you can do is modify the script and include a line like the one below at the top.

    echo 'SNAP='"$SNAP" > /tmp/SNAP_VALUE
    

    Then run the application and check the file /tmp/SNAP_VALUE, either with gedit or from the terminal:

    more /tmp/SNAP_VALUE