Skip to content

Conversation

@Foadsf
Copy link

@Foadsf Foadsf commented Apr 18, 2025

Ruby 3.4.0 changed the output format of caller, potentially omitting
quotes around method names. The previous code in ResourceScenario#treeSum
relied on a regex (/'(.*)'/) that expected these quotes. When the regex
failed to match on Ruby 3.4, it returned nil, leading to a fatal
undefined method '[]' for nil error when generating cache tags.

This change introduces a check for Ruby version >= 3.4.0. For these
versions, it attempts to parse the method name using a more flexible
regex (/in\s+\?([^'\`\s]+)'?/) that handles optional quotes.

Crucially, a fallback mechanism is added. If parsing the method name
still fails (which can happen if the caller format is unexpected,
producing warnings), it generates a cache tag using a hash of the
raw caller string. This prevents the fatal error and allows TaskJuggler
to run, albeit potentially with less optimal caching in those specific
edge cases.

Fixes #300

…uggler#300)

Ruby 3.4.0 changed the output format of \`caller\`, potentially omitting quotes around method names. The previous code in ResourceScenario#treeSum relied on a regex (\`/''.*''/\`) that expected these quotes. When the regex failed to match on Ruby 3.4, it returned nil, leading to a fatal \`undefined method ''[]'' for nil\` error when generating cache tags.

This change introduces a check for Ruby version >= 3.4.0. For these versions, it attempts to parse the method name using a more flexible regex (\`/in\s+\`?([^''\`\s]+)''?/\`) that handles optional quotes.

Crucially, a fallback mechanism is added. If parsing the method name still fails (which can happen if the caller format is unexpected, producing warnings), it generates a cache tag using a hash of the raw caller string. This prevents the fatal error and allows TaskJuggler to run, albeit potentially with less optimal caching in those specific edge cases.

Fixes taskjuggler#300
@scrapper
Copy link
Member

The example you've posted in #300 works fine for me with the latest TJ git version. Can you post the output of caller() with a TJ3 + Ruby 3.4 that does not work with the latest git version, please?

@sanjayankur31
Copy link

@scrapper : I was running into the same issue with 3.8.1, and no longer see it using the latest commit from git (this one: 5c38b42 ).

Cheers,

@gitlyap
Copy link

gitlyap commented Jun 8, 2025

hello, thanks for the update. Can you also update the version so that it is in the official release.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TaskJuggler 3.8.1 Fatal Error with Chart Column on Ruby 3.4.0

4 participants