Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot launch Git GUI using Cygwin on Windows

Tags:

git

cygwin

x11

tk

tcl

I used to launch Git GUI within my Cygwin console without any problems, but since I updated Cygwin I've got the following error message:

$ git gui Application initialization failed: no display name and no $DISPLAY environment variable Error in startup script: invalid command name "tk_messageBox"     while executing "tk_messageBox  -icon error  -type ok  -title "git-gui: fatal error"  -message $err"     invoked from within "if {[catch {package require Tcl 8.4} err]  || [catch {package require Tk  8.4} err] } {         catch {wm withdraw .}         tk_messageBox \                 -icon error \                 -typ..."     (file "/usr/lib/git-core/git-gui" line 34) 

How can I solve this?

like image 298
Stijn Vanpoucke Avatar asked Feb 22 '12 10:02

Stijn Vanpoucke


People also ask

How do I open a git GUI in terminal?

Windows and Linux Users To run gitk, type gitk in your command line or terminal. To run git-gui, type git gui instead.

What is GITK command?

Gitk is a graphical repository browser. It was the first of its kind. It can be thought of as a GUI wrapper for git log . It is useful for exploring and visualizing the history of a repository. It's written in tcl/tk which makes it portable across operating systems.


2 Answers

Cygwin's gitk and Git GUI require X11. This means you need to install some of the Cygwin X11 packages and set them up to be able to open the GUI.

This should get you up and running:

  1. Run the Cygwin installer again (download the relevant setup-*.exe again if you need to).
  2. At the package list, select to install "xinit" under the X11 category. Click next, accept all the dependencies, and install.
  3. In the Windows Start menu, you should have a new group: Cygwin-X. From there, run XWin Server.
  4. In your Cygwin shell, run export DISPLAY=:0.0.

You'll need to repeat step 3 every time you reboot your computer, and step 4 every time you open a new Cygwin shell (or just run echo "export DISPLAY=:0.0" >>~/.profile to have it run automatically whenever you create a new shell).

In the comments, it seems some people are getting errors stating 'couldn't connect to display ":0.0"'. If you get that, mouse over the X that should have appeared in your system tray (you may need to click the little up icon if the X icon has been hidden); the pop-up title should say something like "Cygwin/X Server:1.0". Use that ":1.0" (or whatever you see) as the value for DISPLAY in step 4, rather than ":0.0", making sure to include the colon.

If you have any other problems starting the X server, you will probably find you have a file called ~/.xsession-errors; check out the contents of that for what's going wrong. Also check whether you have a ~/.startxwinrc file, and try deleting it and seeing if that fixes the problem.

For the interested, the reason the X11 packages aren't installed automatically is that they're not technically needed: it's possible through somewhat convoluted means to use a different X11 server than the one Cygwin installs when you install the "xinit" package.

like image 126
me_and Avatar answered Sep 28 '22 04:09

me_and


Avoid X11 and add Git GUI support to Cygwin

If you want to avoid X11 (and who wouldn't?):

  1. Install Git for Windows (non-cygwin) http://git-scm.com/download/win
  2. Open its command shell C:\Program Files (x86)\Git\Git Bash
  3. run git gui

(Optional) If you want to stay in Cygwin to launch Git GUI, add a function in your ~/.bashrc to do it. The only caveat is do not name the function git because of recursion and confusion with arguments, and the fact that you're Git for Windows shell may also be adding the same function when it starts. You may also run into path issues so be careful about setting up your paths correctly.

# Call Git GUI from Git For Windows path with `ggui`     gg() {     command "/cygdrive/c/Program Files (x86)/Git/bin/git" gui  2>/dev/null;       } 

When you're done editing your .bashrc, refresh your settings:

source ~./bashrc 

and then simply:

gg 
like image 42
AndrewD Avatar answered Sep 28 '22 04:09

AndrewD