gedit-code-assistance in jhbuild

Since I began working on my GSoC project a while back with gnome, I was introduced to Vala, Autogen and jhbuild. Here, I describe how to get gedit-code-assistance working in jhbuild as it’s not as simple a process as I hoped it would be.

Useful tools

jhbuild is the tool which helps you install nightly builds (git’s master branch) of various modules,a nd handles all your dependency problems and so on. A word of caution : jhbuild would install every gnome utility in existence if you aren’t careful with it (not that it’s a bad thing). It was intended to be made on

vala is a nice programming language which has easy to use interfaces for the gobject object system and is a nice abstraction on top of the C language so that developers can code faster. The interesting thing about vala is that it compiles into C and then uses a C compiler to make an executable.

autogen again a tool built on top of the gnu-make and the configure utility, it creates a make+configure file with a nice syntax making it considerably easier and cleaner to use. (similar to cmake)

Install using jhbuild

So, I began with these to hack into gedit-code-assistance and came across multiple problems 😐 So, first off I ran jhbuild and asked it to install the module (it uses the moduleset gnome-module). The way jhbuild works is that first you have to install all the basic requirements which can be gotten through apt-get (sysdeps) – if you have apt-file installed, it can automatically install them for you (but it’s a bit slow). And then you ask it to build the package you want.

jhbuild -m gnome-world sysdeps --install gedit-code-assistance
jhbuild -m gnome-world build gedit-code-assistance

Once that completes you’ll have a lot (~26) of packages installed using jhbuild – the important ones are :gedit-code-assistance, gedit (the text editor itself), gnome-code-assistance (the backend for the plugin which does all the dirty work) and libpeas (the plugin system of gedit).

[Fix 1 – gnome-code-assistance and vala] There may be an error while compiling gedit-code-assistance saying the module ‘gca’ was not found in the vala-api directory. The workaround (currently) for this is to copy vapi files from ~/jhbuild/install/share/vala-0.28/vapi/ to ~/jhbuild/install/share/vala/vapi/ so that autogen can find the “gca.vapi” file.

Once that’s done, you can open gedit by running

jhbuild run gedit

And enable the CodeAssistance plugin in Preferences > Plugins. Now try opening a C file with a bug like:

#include <stdio.h>
int main (int argc, char ** argv) {
 if ( 1 ) {
 } else {
 return 0;

And it should show a minus sign on the gutter (left side) saying there are errors in line 2 and 3. If it does not, means more workarounds are in order.

[Fix 2 – dbus and jhbuild] So, to be able to see the actual output, we need to let jhbuild’s dbus service files be noticed by the dbus daemon running on your computer. We can do this by linking the jhbuild’s dbus directory to the one seen by the system. In ubuntu, this command will do it:

sudo ln -s ~/jhbuild/install/share/dbus-1 /usr/local/share/

the location /usr/local/share/dbus-1/ is a directory that dbus checks for services/*.service and other files which are installed in the jhbuild environment. Now, restart the computer and you’re ready to go.

You should be able to see something like this:

gedit-code-assistance at work

[Fix 3 – gdb with vala] [NOTE: This may or may not be needed, works on some computers, not on others]

Also, as I wanted to play around with the source I wanted a good debugger. So, I got gdb working with vala. The simple way to do this is by adding the flags -g and –save-temps in the valac command. But as jhbuild uses autogen and makefiles, this became a bit more difficult – where I had to edit the file ~/jhbuild/checkout/gedit-code-assistance/src/ and edit the VALAFLAGS to add -g to it (–save-temps is not needed as -c already does the same thing which is set in the already):

src_libcodeassistance_la_VALAFLAGS += --debug -g

Now, compile and run this to be able to use gdb along with Vala !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s