无法在 Windows 上使用 Cygwin 启动 Git GUI

发布于 2025-01-07 23:26:09 字数 716 浏览 0 评论 0原文

我曾经在 Cygwin 控制台中启动 Git GUI 没有任何问题,但自从我更新后Cygwin 我收到以下错误消息:

$ 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)

我该如何解决这个问题?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

沩ん囻菔务 2025-01-14 23:26:09

Cygwin 的 gitk 和 Git GUI 需要 X11。这意味着您需要安装一些 Cygwin X11 软件包并将其设置为能够打开 GUI。

这应该可以让您启动并运行:

  1. 再次运行 Cygwin 安装程序(再次下载相关的 setup-*.exe如果你需要的话)。
  2. 在软件包列表中,选择安装X11类别下的“xinit”。单击下一步,接受所有依赖项并安装。
  3. 在 Windows 开始菜单中,您应该有一个新组:Cygwin-X。从那里运行 XWin Server。
  4. 在 Cygwin shell 中,运行 export DISPLAY=:0.0

每次重新启动计算机时,您都需要重复步骤 3,每次打开新的 Cygwin shell 时都需要重复步骤 4(或者只需运行 echo "export DISPLAY=:0.0" >>>~/.profile< /code> 让它在您创建新 shell 时自动运行)。

在评论中,似乎有些人收到错误,指出“无法连接到显示“:0.0””。如果出现这种情况,请将鼠标悬停在本应出现在系统托盘中的 X 上(如果 X 图标已隐藏,则可能需要单击向上的小图标);弹出窗口标题应为“Cygwin/X Server:1.0”之类的内容。在步骤 4 中使用“:1.0”(或您看到的任何内容)作为 DISPLAY 的值,而不是“:0.0”,并确保包含冒号。

如果启动 X 服务器时遇到任何其他问题,您可能会发现有一个名为 ~/.xsession-errors 的文件;检查其中的内容是否出了问题。另请检查您是否有 ~/.startxwinrc 文件,并尝试删除它,看看是否可以解决问题。

对于感兴趣的人来说,X11 软件包不会自动安装的原因是它们 技术上不需要:可以通过某种复杂的方式使用与安装“xinit”包时 Cygwin 安装的服务器不同的 X11 服务器。

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.

如何视而不见 2025-01-14 23:26:09

避免 X11 并向 Cygwin 添加 Git GUI 支持

如果您想避免 X11(谁不想?):

  1. 安装适用于 Windows 的 Git(非 cygwin)http://git-scm.com/download/win
  2. 打开其命令 shell C:\Program Files (x86)\Git \Git Bash
  3. run git gui

(可选) 如果您想留在 Cygwin 中启动 Git GUI,请在 ~/.bashrc< 中添加一个函数/code> 来做到这一点。唯一需要注意的是不要将函数命名为 git 因为递归和参数混淆,而且您是 Windows shell 的 Git 也可能会添加相同的函数当它开始时。您还可能会遇到路径问题,因此请小心正确设置路径。

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


    }

编辑完 .bashrc 后,刷新您的设置:

source ~./bashrc

然后简单地:

gg

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
一场信仰旅途 2025-01-14 23:26:09

在花费了比我愿意承认的更多的时间之后,我设法找到了一个可行的解决方案来从我的 Cygwin shell 执行 gitk。我无法获得任何关于启动 X 服务器可靠工作的说明,最后,解决方案非常简单。

最大的警告是需要安装适用于 Windows 的 Git,可以在此处找到下载。

现在是整个正在运行的 gitk 部分。 Windows 版 Git 包含一个 cmd 文件夹,其中包含 gitk.cmd windows 命令文件。这就是打开 gitk 所需的全部调用。

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

在我的系统上,Git 路径位于“C:\Program Files (x86)\Git”,因此命令如下所示:

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

在我的 ~/.bash_profile 文件中,我添加了一个函数处理该调用,如下所示:

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

After spending more time than I'd care to admit, I managed to find a working solution to execute gitk from my Cygwin shell. I couldn't get any of the instructions with starting the X server to work reliably, and in the end, the solution was pretty simple.

The largest caveat is needing to have Git for Windows installed, the download for that can be found here.

Now for the whole running gitk part. Git for windows includes a cmd folder, that has a gitk.cmd windows command file. That's all you need to call to have gitk open.

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

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

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

In my ~/.bash_profile file I've added a function to handle that call which looks like this:

gitk() {
  "/cygdrive/c/Program Files (x86)/Git/cmd/gitk.cmd"
}
2025-01-14 23:26:09
echo "export DISPLAY=:0.0" >>~/.profile

或者

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

就我而言

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

or

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

in my case

在风中等你 2025-01-14 23:26:09

以下是对我有用的方法:

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

从 Cygwin 包管理器中,执行以下操作:

安装 xorg-server 和一些 xorg 字体,尤其是 xorg-x11-fonts-Type1。

接下来,创建一个指向 Windows 字体文件夹的链接以供 Git GUI 使用:

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

关闭 Cygwin 终端并再次打开,然后键入

startxwin &> /dev/null &

git gui &

Here is what worked for me:

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

From 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 the Cygwin terminal and open again then type

startxwin &> /dev/null &

git gui &
不再让梦枯萎 2025-01-14 23:26:09

遵循me_and给出的四个步骤后和 tititou36,您可能仍然遇到 XWin 的问题启动XwinServer后就死掉了。

原因是它依赖于 Cygwin 终端/控制台,即主机,如果没有 Cygwin 控制台,Xwin 就会死掉。

解决方案是:

启动 Cygwin 控制台(您可以通过将 mintty 命令放入 Cygwin 主目录下的文件 .startxwinrc 来使其自动启动)。

After following the four steps given by me_and and tititou36, you may still have issues of the XWin just die after you started the XwinServer.

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

The solution for this is:

Start a Cygwin console (you can make it automatically start by putting mintty command into the file .startxwinrc under your Cygwin home directory).

や三分注定 2025-01-14 23:26:09

基于 AndrewD 的回答:不要使用 Cygwin 的 git,但使用 Windows Git 的 gitkgit gui。换句话说,从 Cygwin 卸载 git-gui 和 gitk 软件包(如果已安装)。那么 which gitk 应该指向 Windows 文件,而不是 /usr/bin 中的 Cygwin 二进制文件。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文