1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
# Ruby-GNOME
[](https://badge.fury.io/rb/gtk4)

Ruby bindings for GNOME
This is a set of bindings for the GNOME 3.x and 4.x libraries to use
from Ruby that allows you to write graphical user interfaces in Ruby.
## Installation Instructions for gtk3 and gtk4
### Debian/Ubuntu
Ruby can be run from the system directories, or from your home
directory, or both. Most people won't have the correct permissions
for a system install, so the vast majority of people to run Ruby from
their local, `/home/...` directory.
To test if your copy of Ruby is running locally enter this on the
command line:
```bash
which ruby
```
If it outputs something like this:
```bash
/home/ralph/.rbenv/shims/ruby
```
that starts with `/home/`, that's local (good!)
But if outputs something like this:
```bash
/usr/bin/ruby
```
That is a system directory, and the gtk4 gem will fail to install.
Actually, a system administrator with super-user permissions could
install everything in the system folders (see advanced install), but
its much better for everyone else to run Ruby locally.
If you're already running a copy of Ruby under your home directory,
you can install gtk4 (or gtk3):
```bash
gem install gtk4
```
But if you're running ruby from the system folders, you can install a
Ruby version manager like [RVM](https://rvm.io/) or
[rbenv](https://github.com/rbenv/rbenv). These programs allow you to
run multiple versions of Ruby from your home directory.
rbenv has a
[rbenv-installer](https://github.com/rbenv/rbenv-installer) that
installs everything and adds a line to your `.bashrc` file so you're
running local copies of Ruby.
To get rbenv:
1. Run the installer
2. Restart your command prompt
3. Run `rbenv install --list` (find recent Ruby version)
4. Run `rbenv install 3.3.5` (example version. choose one from list)
5. Run `which ruby` (check that its running from home directory)
If that works, then you're ready to install gtk4 (or gtk3):
```bash
gem install gtk4
```
### macOS
Input needed...
### Windows
In Windows, the gem should be installed without issue. If you install
Ruby using the [Ruby Installer](https://rubyinstaller.org/), make sure
that MSYS2 gets installed too. GTK needs MSYS2 to make the binary
files. Then, at the Ruby command prompt:
```bash
gem install gtk4
```
## Advanced Installation instructions
### Debian/Ubuntu
```bash
sudo apt install -y gcc make ruby-dev
sudo gem install rubygems-requirements-system
sudo gem install gtk4
```
## Install from GitHub master branch
You can also install these gems from GitHub master branch.
Create `Gemfile` like the following:
```ruby
source "https://rubygems.org/"
plugin "rubygems-requirements-system"
git "https://github.com/ruby-gnome/ruby-gnome.git" do
gem "gtk4"
end
```
Install these gems by Bundler:
```bash
bundle install
```
## Build From Source Code
```bash
ruby extconf.rb
make
```
To compile and install a particular sub-binding, you can add arguments:
```bash
ruby extconf.rb [subdir]...
# e.g.) ruby extconf.rb glib2 pango atk gdk_pixbuf2 gtk4
```
Or you can compile each sub-binding:
```bash
cd <each sub-directory>
ruby extconf.rb
make
```
### extconf.rb options
* `--ruby`
* ruby directory
* `--topsrcdir`
* top source directory
* `--topdir`
* top directory
* `--strict`
* if some libraries fail to compile/install, `make`
command returns 1(exit 1)
## Bugs
Please report bugs in our bug tracker:
* [https://github.com/ruby-gnome/ruby-gnome/issues](https://github.com/ruby-gnome/ruby-gnome/issues)
## Copying
Copyright (c) 2002-2025 Ruby-GNOME Project Team
This program is free software.
You can distribute/modify this program under the terms of
the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
### Exceptions
Some GTK+ 3 examples are licensed under GNU Free Documentation License
1.3 or any later version later; with no Invariant Sections, no
Front-Cover Texts, and no Back-Cover Texts.
Because they are based on scripts in
[PyGObject-Tutorial](https://github.com/sebp/PyGObject-Tutorial).
[PyGObject-Tutorial is licensed under GFDL 1.3](https://github.com/sebp/PyGObject-Tutorial/blob/master/COPYING).
See [gtk3/sample/](/gtk3/sample) directory for details.
## Project Website
[https://ruby-gnome.github.io/](https://ruby-gnome.github.io/)
|