# Programmatically testing the version of ruby-gnome2?

**URL:** <https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981>\
**Category:** Ruby-Gnome 2\
**Created:** [July 2, 2008, 10:49am UTC](https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981 "2008-07-02T10:49:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 2, 2008, 10:49am UTC](https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981/1 "2008-07-02T10:49:16Z")

</div>

Hi,

If I’m correct, there’s no way to programmatically say what version of  
ruby-gnome2 an application is running with?

If it’s the case, wouldn’t it be helpful to add it? My intent is to  
avoid random crashes in my application when I detect known bad version  
combinations (currently I want to do it for rg2 0.15.0, and rg2 \<  
0.17.0 + ruby \>= 1.8.7).

Thanks,

–  
Guillaume C. - [http://zarb.org/~gc/](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 2, 2008, 10:53am UTC](https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981/2 "2008-07-02T10:53:21Z")

</div>

Hi,

2008/7/2 Guillaume C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> If I’m correct, there’s no way to programmatically say what version of  
> ruby-gnome2 an application is running with?

Gtk::BINDING\_VERSION?  
Some bindings have \*::BINDING\_VERSION but not all…

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 2, 2008, 12:47pm UTC](https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981/3 "2008-07-02T12:47:44Z")

</div>

Guillaume C. wrote:

> Hi,
> 
> If I’m correct, there’s no way to programmatically say what version of  
> ruby-gnome2 an application is running with?
> 
> If it’s the case, wouldn’t it be helpful to add it? My intent is to  
> avoid random crashes in my application when I detect known bad version  
> combinations (currently I want to do it for rg2 0.15.0, and rg2 \<  
> 0.17.0 + ruby \>= 1.8.7).

I used to have this in my code:

major, minor, micro = Gtk::BINDING\_VERSION  
if major == 0 and minor \< 16  
msg = "Error: Your ruby-gnome2 binding version is too old and WILL  
cause crashes. Please use 0.16.0 at least. "  
d = Gtk::MessageDialog.new(nil, Gtk::Dialog::MODAL,  
Gtk::MessageDialog::ERROR , Gtk::MessageDialog::BUTTONS\_OK,msg )  
d.run  
exit!  
end

Of course, you may encounter some “random” crashes in 0.16 too because  
of some GC-bugs, which are solved in 0.17.

For Ruby version you can read the constant RUBY\_VERSION .

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 2, 2008, 2:14pm UTC](https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981/4 "2008-07-02T14:14:50Z")

</div>

On Wed, Jul 2, 2008 at 12:47 PM, Joachim G.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Of course, you may encounter some “random” crashes in 0.16 too because  
> of some GC-bugs, which are solved in 0.17.

In my experience 0.16 is almost stable as long as ruby \<= 1.8.6 is  
used. But no way when using ruby 1.8.7.

> For Ruby version you can read the constant RUBY\_VERSION .

Yes. Here’s what I’ve actually added (too bad RUBY\_VERSION is a  
string, though there’s probably a more elegant way to use it).

binding\_version = Gtk::BINDING\_VERSION  
if binding\_version == [0, 15, 0]  
puts “It seems that we’re running ruby-gtk2 0.15.0; this version  
is known to crash; please upgrade or downgrade.”  
puts str  
exit  
end  
ruby\_version = RUBY\_VERSION.split(‘.’).collect { |v| v.to\_i }  
if binding\_version[0] \<= 0 && binding\_version[1] \<= 16 &&  
ruby\_version[0] \>= 1 && ruby\_version[1] \>= 8 && ruby\_version[2] \>= 7  
puts “It seems that we’re running ruby-gtk2 \<= 0.16.0 with ruby \>=  
1.8.7; this combination is known to crash; please upgrade or downgrade  
some.”  
puts str  
exit  
end

–  
Guillaume C. - [Guillaume Cottenceau](http://zarb.org/~gc/)

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 2, 2008, 3:26pm UTC](https://www.ruby-forum.com/t/programmatically-testing-the-version-of-ruby-gnome2/141981/5 "2008-07-02T15:26:55Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] programmatically testing the version of  
ruby-gnome2?” on Wed, 2 Jul 2008 14:14:40 +0200,  
“Guillaume C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> exit
> 
> ```
> 
> end  
> ruby\_version = RUBY\_VERSION.split(‘.’).collect { |v| v.to\_i }  
> if binding\_version[0] \<= 0 && binding\_version[1] \<= 16 &&  
> ruby\_version[0] \>= 1 && ruby\_version[1] \>= 8 && ruby\_version[2] \>= 7  
> puts “It seems that we’re running ruby-gtk2 \<= 0.16.0 with ruby \>=  
> 1.8.7; this combination is known to crash; please upgrade or downgrade  
> some.”  
> puts str  
> exit  
> end

if (Gtk::BINDING\_VERSION \<=\> [0, 17, 0]) \< 0 and  
(RUBY\_VERSION.split(‘.’).collect {|v| v.to\_i} \<=\> [1, 8, 7]) \>= 0  
puts “ruby-gtk2 \< 0.17.0 and ruby \>= 1.8.7”  
end

## Thanks,

kou
