Ruby-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:
which rubyIf it outputs something like this:
/home/ralph/.rbenv/shims/rubythat starts with /home/, that's local (good!)
But if outputs something like this:
/usr/bin/rubyThat 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):
gem install gtk4But if you're running ruby from the system folders, you can install a Ruby version manager like RVM or rbenv. These programs allow you to run multiple versions of Ruby from your home directory.
rbenv has a
rbenv-installer that
installs everything and adds a line to your .bashrc file so you're
running local copies of Ruby.
To get rbenv:
- Run the installer
- Restart your command prompt
- Run
rbenv install --list(find recent Ruby version) - Run
rbenv install 3.3.5(example version. choose one from list) - Run
which ruby(check that its running from home directory)
If that works, then you're ready to install gtk4 (or gtk3):
gem install gtk4macOS
Input needed...
Windows
In Windows, the gem should be installed without issue. If you install Ruby using the Ruby Installer, make sure that MSYS2 gets installed too. GTK needs MSYS2 to make the binary files. Then, at the Ruby command prompt:
gem install gtk4Advanced Installation instructions
Debian/Ubuntu
sudo apt install -y gcc make ruby-dev
sudo gem install rubygems-requirements-system
sudo gem install gtk4Install from GitHub master branch
You can also install these gems from GitHub master branch.
Create Gemfile like the following:
source "https://rubygems.org/"
plugin "rubygems-requirements-system"
git "https://github.com/ruby-gnome/ruby-gnome.git" do
gem "gtk4"
endInstall these gems by Bundler:
bundle installBuild From Source Code
ruby extconf.rb
makeTo compile and install a particular sub-binding, you can add arguments:
ruby extconf.rb [subdir]...
# e.g.) ruby extconf.rb glib2 pango atk gdk_pixbuf2 gtk4Or you can compile each sub-binding:
cd <each sub-directory>
ruby extconf.rb
makeextconf.rb options
-
--ruby- ruby directory
-
--topsrcdir- top source directory
-
--topdir- top directory
-
--strict- if some libraries fail to compile/install,
makecommand returns 1(exit 1)
- if some libraries fail to compile/install,
Bugs
Please report bugs in our bug tracker:
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. PyGObject-Tutorial is licensed under GFDL 1.3.
See gtk3/sample/ directory for details.