StefanSalewski / gintro

High level GObject-Introspection based GTK3/GTK4 bindings for Nim language
MIT License
297 stars 20 forks source link

failed install #166

Closed unhandyandy closed 3 years ago

unhandyandy commented 3 years ago

I'm brand new to Nim, so I probably doing something stupid, but I'm I get a segfault when I try to install gintro via nimble.

I have Gtk3, but not Gtk4.

Here's the tail end of the progress message.

/tmp/gintrosalewski/gen.nim(65, 10) Hint: 'isTypeInfo' is declared but not used [XDeclaredButNotUsed]
Hint:  [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
70622 lines; 1.012s; 147.496MiB peakmem; proj: /tmp/gintrosalewski/gen.nim; out: /tmp/gintrosalewski/gen [SuccessX]
First we try generating bindings for GTK4, this may fail when GTK4 is not properly installed
on your computer. But don't worry, you can still use GTK3
Can't load gtk4 library!
Failed to load Gtk
Typelib file for namespace 'Gtk', version '4.0' not found
Maybe for your OS you have to install additional GTK related packages?
We continue with the remaining packages...
Failed to load Gdk
Typelib file for namespace 'Gdk', version '4.0' not found
Maybe for your OS you have to install additional GTK related packages?
We continue with the remaining packages...
Failed to load GdkX11
Typelib file for namespace 'GdkX11', version '4.0' not found
Maybe for your OS you have to install additional GTK related packages?
We continue with the remaining packages...
Failed to load Gsk
Typelib file for namespace 'Gsk' (any version) not found
Maybe for your OS you have to install additional GTK related packages?
We continue with the remaining packages...
Failed to load Graphene
Typelib file for namespace 'Graphene' (any version) not found
Maybe for your OS you have to install additional GTK related packages?
We continue with the remaining packages...
Traceback (most recent call last)
/tmp/gintrosalewski/gen.nim(4261) gen
/tmp/gintrosalewski/gen.nim(4192) launch
/tmp/gintrosalewski/gen.nim(3768) main
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
stack trace: (most recent call last)
/tmp/nimblecache-292239017/nimscriptapi_1398601063.nim(199, 29)
/tmp/nimble_22925/githubcom_stefansalewskigintro/gintro.nimble(77, 7) installBefore
/tmp/nimble_22925/githubcom_stefansalewskigintro/gintro.nimble(64, 7) prep
/home/dabrowsa/mygit/Nim/lib/system/nimscript.nim(273, 7) exec
/home/dabrowsa/mygit/Nim/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: /tmp/gintrosalewski/gen 1 [OSError]
     Error: Exception raised during nimble script execution

Here's what I get when I run gen in the /tmp directory:

/tmp/gintrosalewski]$ ./gen
Generating bindings for GTK3...
gtk.....................: Remaining delayed methods: 0 (Fine!)
gdk.....................: Remaining delayed methods: 0 (Fine!)
gdkx11..................: Remaining delayed methods: 0 (Fine!)
graphene................: Remaining delayed methods: 0 (Fine!)
Traceback (most recent call last)
/tmp/gintrosalewski/gen.nim(4261) gen
/tmp/gintrosalewski/gen.nim(4139) launch
/tmp/gintrosalewski/gen.nim(3768) main
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault
StefanSalewski commented 3 years ago

Thanks for reporting. Seems you are the second person with this issue, see

https://github.com/StefanSalewski/gintro/issues/151

We never had that issue before in the last five years, and we have no idea about the reason still.

If you are new to Nim, I assume you are new to GTK as well: For that case I would recommend avoiding GTK. Learning GTK is hard, much more effort than learning Nim. There are 20 other GUI toolkits for Nim now available, I have listed them at the beginning of the GTK4 book, see http://ssalewski.de/gtkprogramming.html

Araq and some other Nim core devs seems to promote fidget currently. At least for toy apps most of the 20 toolkits should be fine.

Of course we would love to find the reason for your install issue. Are you using Debian too? It would be nice if you could later, when you have some more experience with Nim, try to debug the issue. The missing GTK4 should be not a problem, it worked in the last year for a lot of people without GTK4 fine. I got myself preinstalled GTK4 on my gentoo linux box some months ago for the first time. Tested without GTK4 before, all was fine.

Of course if you should think that you really need gintro for Nim for some reason, then we can try harder to debug the issue, or maybe we can send you the prebuild GTK modules. Would be not a perfect match for your box, but when you tell us if you are using Windows, Mac or linux, and if it is 32 or 64 bit, then it should work. But I really assume that you do not need and do not want GTK.

StefanSalewski commented 3 years ago

we have no idea

Ah wait -- I just noticed that your

/tmp/gintrosalewski/gen.nim(3768) main

may be a different line on my box, as I am using "nimble install gintro @head" while you and the other reporter may be using v0.9.3. So maybe I looked at the wrong line 3 weeks ago. Will investigate the v0.9.3 gen.nim file this evening, maybe I will get an idea...

unhandyandy commented 3 years ago

I'm on Linux, Ubuntu 20, 64 bit, sorry I didn't mention that. I don't have much experience with Gtk, but I have successfully used it for a toy app in Julia.

StefanSalewski commented 3 years ago

Unfortunately I can currently not really help you. Assuming that you tried to install latest stable gintro v0.9.3 then the error seems to be at line 3768 which is

if gStructInfoFindMethod(info, n) != nil:

For me there the error position and the error message makes no sense.

Can you tell us which Nim compiler version you are using? Are you using some special options, maybe installed the compiler with ARC enabled or using clang?

I really wonder why this error is never occurred in the last 5 years before. For GTK4 I would be not that surprised, as GTK4 is in active development. But GTK3 should be really stable.

So I think we have to wait until this error will happen to someone with some Nim debugging experience. And follow my advice, use one of the other 20 GUI toolkits. GTK is hard -- I tried one hour to get a larger Icon for a GtkMenuButton in a GtkHeaderbar this morning, and still failed. May have to ask Mr Bassi again :-(

unhandyandy commented 3 years ago

I'm using the latest Nim git pull, it shows the most recent tag as v1.4.8. No special options (I wouldn't know how).

Maybe a bug in gStructInfoFindMethod?

I'll check out fidget, thanks.

gavr123456789 commented 3 years ago

@unhandyandy Do you have the gobject-introspection package installed? https://packages.ubuntu.com/search?keywords=gobject-introspection (I assume that if julia worked, then it should, but it's still better to check)

Can you run this hello world python example?

import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

win = Gtk.Window()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()

I have successfully launched gintro on windows, so I am sure that this should be possible on ubuntu as well. https://github.com/gavr123456789/Katana#windows

unhandyandy commented 3 years ago

I'm using the latest Nim git pull, it shows the most recent tag as v1.4.8. No special options (I wouldn't know how).

Maybe a bug in gStructInfoFindMethod?

I'll check out fidget, thanks.

unhandyandy commented 3 years ago

@gavr123456789 I have gobject-introspection 1.56.1. That python script runs without error. The problem seems to be with the gintro install script.

StefanSalewski commented 3 years ago

I have gobject-introspection 1.56.1

Really? That is 3 years old. But well, gintro was working 3 years ago well. Unfortunately I have still no idea, the issue is very strange.

gavr123456789 commented 3 years ago

Really? That is 3 years old.

This is not surprising, do not forget that ubuntu and most other distributions are not rolling, and receive package updates every 6 months or 2 years for LTS versions.

unhandyandy commented 3 years ago

OK, apparently the problem is my Ubuntu version, which is 18.04 LTS in my office.

I confused it with my home, where it is 20.10, actually now 21.04

It installs successfully under the latter. So the problem is at my end.

Thanks for your help.

gavr123456789 commented 3 years ago

@unhandyandy so can be closed?

StefanSalewski commented 3 years ago

It is not bad to leave it open, as other people with a corrupted Linux box may have a similar issue. Someone recently reported something similar. Unfortunately we do not know the exact reason for this error, seems to be somehow a broken gobject-introspection.

StefanSalewski commented 3 years ago

OK, seems that only very few people have this strange problem, so I think we can close this issue.