|
| 1 | +--- |
| 2 | +title: GTK OpenGL Context Errors |
| 3 | +description: |- |
| 4 | + In some situations, Ghostty may fail to start with an error about being |
| 5 | + "unable to acquire an OpenGL context". This page adds more details about |
| 6 | + this error and how to resolve it. |
| 7 | +--- |
| 8 | + |
| 9 | +The Ghostty GTK application uses OpenGL for rendering. To render with |
| 10 | +OpenGL, Ghostty needs to first acquire an "OpenGL context" from GTK. This |
| 11 | +gives us the namespace to execute OpenGL commands. |
| 12 | + |
| 13 | +In rare situations, GTK may be unable to provide Ghostty with an OpenGL |
| 14 | +context. When this happens, Ghostty is unable to render anything and must |
| 15 | +show this error. |
| 16 | + |
| 17 | +This is **always an environment issue**. GTK provides Ghostty with the OpenGL |
| 18 | +context, and there isn't generaly anything Ghostty itself can do to resolve |
| 19 | +this directly. It is usually an issue regarding a library, driver, or OS |
| 20 | +package version. This page will attempt to provide some assistance in |
| 21 | +tracking down the issue. |
| 22 | + |
| 23 | +## Quick Fixes |
| 24 | + |
| 25 | +If you want to try to get Ghostty working quickly, try the following. |
| 26 | + |
| 27 | +1. **Install a [binary package](/docs/install/binary).** If you're building |
| 28 | + from source, try using a binary package instead. Binary packages tend |
| 29 | + to be built in a more controlled environment that works with a specific |
| 30 | + distribution and its libraries. |
| 31 | + |
| 32 | +2. **Check your GPU drivers.** GPU drivers are a common cause of OpenGL |
| 33 | + issues. Try updating or downgrading your GPU drivers, especially if |
| 34 | + you're using proprietary drivers. |
| 35 | + |
| 36 | +3. **Build Ghostty from source using only system packages.** If you're using |
| 37 | + the Nix development environment to build Ghostty, try building it |
| 38 | + from source using only system packages. See the |
| 39 | + [build from source](/docs/install/build) instructions to do this |
| 40 | + (but ignore the "Building with Nix" section). |
| 41 | + |
| 42 | +<Important> |
| 43 | + This section purposely avoids any detail in understanding the root cause of |
| 44 | + this issue. If you want to better understand the root cause, please read below |
| 45 | + this section. |
| 46 | +</Important> |
| 47 | + |
| 48 | +## Mismatched Library Versions |
| 49 | + |
| 50 | +A common cause of this error is mismatched library versions. The balance |
| 51 | +between GTK, [Mesa](https://mesa3d.org/), libX11/libwayland, and the kernel is |
| 52 | +a fragile one. |
| 53 | + |
| 54 | +**The first most common cause of this error is using the Nix development |
| 55 | +environment to build Ghostty.** We recommend this environment for development, |
| 56 | +but it does pin various versions of these libraries and they may be |
| 57 | +incompatible with your global system. **To fix: try to build Ghostty using |
| 58 | +only system dependency packages, or Ghostty itself from a system package.** |
| 59 | +You can follow the [build from source](/docs/install/build) instructions |
| 60 | +to do this (but ignore the "Building with Nix" section) |
| 61 | + |
| 62 | +**Another common cause is outdated system packages.** |
| 63 | +Linux distributions tend to handle this fragile balance for you, so the |
| 64 | +try to update your entire system (or, specifically the |
| 65 | +packages above, at least). This often brings your system back into a |
| 66 | +coherent state that allows Ghostty to work. |
| 67 | + |
| 68 | +**Check your GPU drivers.** Try updating or downgrading your GPU drivers. |
| 69 | +We've had many cases where GPU driver changes have broken OpenGL in GTK. |
| 70 | + |
| 71 | +## Known Historical Causes |
| 72 | + |
| 73 | +- [Mesa 25.2.0 Regression](https://gitlab.freedesktop.org/mesa/mesa/-/issues/13719). |
| 74 | + Ghostty doesn't bundle a libwayland clent library, but building Ghostty |
| 75 | + from source with the Nix development environment will use a different |
| 76 | + libwayland client library than the system one. |
| 77 | + |
| 78 | +- [GTK4 + Nvidia + X11](https://gitlab.gnome.org/GNOME/gtk/-/issues/4950). |
| 79 | + I don't know the exact combination required to trigger this, but it seems |
| 80 | + in certain scenarios, the mixture of GTK4 (required by Ghostty), Nvidia, |
| 81 | + and X11 can cause this issue. Changing driver versions or changing to |
| 82 | + Wayland can resolve this. |
0 commit comments