Cannot start git gui using cygwin on windows

I ran git gui in my cygwin console without any problems, but since I updated cygwin, I 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) 

Who knows how to solve this?

+63
git cygwin tcl tk x11
Feb 22 '12 at 10:57
source share
7 answers

Edit : Updated in March 2016 to account for renamed packages, etc.

Cygwin gitk and git gui require X11. This means that you need to install some of the Cygwin X11 packages and configure them to open the graphical interface.

This should help you:

  • Run the Cygwin installer (download the appropriate setup - *. Exe again if you need to).
  • In the list of packages, select the "xinit" installation in the X11 category. Click Next, accept all the dependencies and install.
  • In the Windows Start menu, you should have a new group: Cygwin-X. From there, start the XWin Server.
  • In your Cygwin shell, run export DISPLAY=:0.0 .

You will need to repeat step 3 every time you restart the computer, and step 4 every time you open a new Cygwin shell (or just run echo "export DISPLAY=:0.0" >>~/.profile so that it starts automatically every time you create a new shell).

In the comments, it seems that some people get errors stating that โ€œthey couldnโ€™t connect to the display: 0.0.โ€ If you understand this, hover over the X icon that should appear on the taskbar (you may need to click the small icon if the X icon was hidden); the pop-up header should say something like โ€œCygwin / X Server: 1.0.โ€ Use the value โ€œ: 1.0โ€ (or whatever you see) as the value for DISPLAY in step 4, and not ": 0.0", making sure to include a colon.

If you have other problems starting the X server, you will probably find that you have a file called ~/.xsession-errors ; check the contents of this for what goes wrong. Also check if you have a ~/.startxwinrc file and try deleting it and see if this fixes the problem.

For the interested person, the reason why X11 packages are not installed automatically is that they are not technically necessary : it is possible, through a somewhat confusing one, to use a different X11 server than the one installed by Cygwin when installing the "xinit" package.

+117
Feb 23 '12 at 18:17
source share

After spending more time than I would like to admit, I managed to find a working solution to run gitk from my cygwin shell. I could not get any of the instructions to start the X server for reliable operation, and, in the end, the solution was quite simple.

The biggest caveat is that you need to install Git for Windows, you can download for it here .

Now for the whole gitk part being executed. Git for windows includes the cmd folder, which has the gitk.cmd command line gitk.cmd . That is all you need to call to open gitk .

 $ [path-to-git]/cmd/gitk.cmd 

On my system, the Git path is in "C: \ Program Files (x86) \ Git", so the command will look like this:

 $ "/cygdrive/c/Program Files (x86)/Git/cmd/gitk.cmd" 

In my ~ / .bash_profile, I added a function to handle this call that looks like this:

 gitk() { "/cygdrive/c/Program Files (x86)/Git/cmd/gitk.cmd" } 

Hope this helps someone else try to figure this out.

+9
Feb 12 '15 at 20:41
source share
 echo "export DISPLAY=:0.0" >>~/.profile 

or

 echo "export DISPLAY=:0.0" >>~/.bash_profile 

in my case

+6
Jun 13 '12 at 20:01
source share

Avoid X11 and add git gui support for cygwin

If you want to avoid X11 (and who not?):

(optional) If you want to stay in cygwin to run git gui , add a function to your ~/.bashrc to do this. The only caveat: do not call the git function due to recursion and confusion with the arguments, and the fact that you are Git for the Windows shell can also add the same function when it starts, you may also encounter path problems, so be careful with the correct one customizing your paths.

 # 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 finish editing your .bashrc, update your settings:

 source ~./bashrc 

and then just:

 gg 
+6
Feb 10 '15 at
source share

After following the 4 steps given by me_and and tititou36, you can still have problems with XWin, only after you start XwinServer.

The reason is that it relies on the CygWin terminal / console, which is the host, and Xwin dies if there is no CygWin console.

The solution for this:

Launch the Cygwin console. (you can do this automatically by placing the mintty command in the mintty file in your cygwin home directory.

+2
Mar 31 '15 at 0:02
source share

Here is what worked for me:

cat >> ~/.bash_profile <<< "export DISPLAY=:0.0"

In the cygwin package manager, do the following:

install xorg-server and some xorg fonts, xorg-x11-fonts-Type1 especially

Next, create a link to the Windows font folders for git gui to use

ln -s /cygdrive/c/Windows/Fonts /usr/share/fonts/win-fonts

Close cygwin terminal and open again, then type

startxwin &> /dev/null &

git gui &

+2
Sep 22 '15 at 5:54
source share

Based on AndrewD's answer: use cygwin git , but use Windows Git gitk and git gui . In other words, remove the git-gui and gitk packages from cygwin (if installed). Then which gitk should point to the Windows file, and not to the cygwin binary in /usr/bin .

0
Feb 08 '16 at 10:15
source share



All Articles