SU 2024 Issue (Fixnum & Bignum)

I’ve been trying to find all of the ways in which SU 2024 has broken my plugins the last few days. Granted I should have addressed this weeks ago but I was stuck in the middle of a move.

I have this one module coded and graciously donated by TIG that I adopted into my own code quite a few years back and it has never given me any trouble but now this one line seems to be causing issues. It must have something to do with the new Ruby engine but so far I’m not seeing what the exact error is.

The error code generated is:

Error: uninitialized constant Medeek_Engineering_Inc_Extensions::MedeekTrussPlugin::Complex::TIG::Smart_offset::Fixnum
Stacktrace: ["c:/users/owner/appdata/roaming/sketchup/sketchup 2024/sketchup/plugins/medeek_truss_ext/medeek_roof_complex_globals.rbe:1319:in `initialize'",

The lines of revelant code are:

def initialize(face=nil, dist=nil, tidy=false)
		return nil unless face && face.is_a?(Sketchup::Face) && face.valid?
		return nil unless dist && ((dist.class==Fixnum || dist.class==Float || dist.class==Length) && dist!=0)

The last line shown is line 1319 in my code.


There have been some recent posts that may help. Have you searched the forum for “Fixnum”?

I’m almost positive this has something to do with some deprecated feature or method in Ruby 3.0.0, but I’m guess I’m not as Ruby knowledgeable as I thought I was.

I see that Dan has already provided a temporary fix for what seems like the same issue or a related issue here:

However I’m wondering what a more permanent fix would be and also maintaining backward compatibility to previous versions of SketchUp and Ruby.

1 Like

You can also try to change “Fixnum” to “Integer” in your above mentioned code.
(Or change all “Fixnum” and “Bignum” to “Integer”…)
But I believe Dan’s temporary solution - in a quoted topic - is to define aliases to the Integer class - perhaps with a condition of SU version - sounds better for maintaining backward compatibility.

1 Like

I’m testing it further.

I just dropped this little block at the start of the class and so far it doesn’t seem to break SU 2017, but I will also test SU 2023 as well… and of course SU 2024.

### Ruby 3.X fix per Dan Rathbun on Apr. 23, 2024 ###

Fixnum = ::Integer
Bignum = ::Integer

Without Dan’s help (life line) I probably would have given up coding these extensions years ago.


Little off topic:
I’ve come to the conclusion - although I still don’t agree with myself :stuck_out_tongue_winking_eye: - that at some point you need to stop using backwards compatibility like the SU team does… or otherwise you go crazy. :slight_smile:

1 Like

Backwards and forwards compatibility both drive me crazy. This time around I wasn’t prepared but every year I get a little stressed about what the new release of SU will break.

1 Like

You should not define class aliases (at the top-level) if the class identifier is still defined. You could break Ruby in older SketchUp versions.

Fixnum = ::Integer unless defined?(::Fixnum)
Bignum = ::Integer unless defined?(::Bignum)

It may not hurt either way if the aliases are local constants with custom modules or classes.

Regarding the example code that produces the error, I might just have checked dist to be some object of a Numeric or sublcass like:

return nil unless dist && dist.is_a?(Numeric) && dist != 0

This line:

return nil unless dist && dist.is_a?(Numeric) && dist != 0

Seems like the cleanest and easiest fix.

I think one could also use:

return nil unless dist.respond_to?(:zero?) && !