Skip to content

private method `format' called for nil:NilClass #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gtrias opened this issue May 15, 2023 · 4 comments
Closed

private method `format' called for nil:NilClass #371

gtrias opened this issue May 15, 2023 · 4 comments

Comments

@gtrias
Copy link

gtrias commented May 15, 2023

Hello,

Firstly, I'd like to express my appreciation for your outstanding work on this library. It's greatly appreciated!

We've integrated it into our Continuous Integration (CI) checks and have come across occasional type errors. Interestingly, I'm unable to reproduce this issue on my end. I've attempted to run the same code with the identical command on my local machine, and everything works flawlessly. Our CI environments aren't configured in any particularly unusual manner either.

Here's the warning we're encountering:

Running the command in this way:

echo "components/timeoff/spec/services/timeoff/working_hours_for_day_calculators/french_calendar_days_spec.rb" | xargs bundle exec stree check
[warn] components/timeoff/spec/services/timeoff/working_hours_for_day_calculators/french_calendar_days_spec.rb
private method `format' called for nil:NilClass
/runner/_work/foo/backend/vendor/bundle/ruby/2.7.0/gems/syntax_tree-6.1.1/lib/syntax_tree.rb:93:in `format_node'
/runner/_work/foo/backend/vendor/bundle/ruby/2.7.0/gems/syntax_tree-6.1.1/lib/syntax_tree.rb:65:in `format'
/runner/_work/foo/backend/vendor/bundle/ruby/2.7.0/gems/syntax_tree-6.1.1/lib/syntax_tree/cli.rb:136:in `run'
/runner/_work/foo/backend/vendor/bundle/ruby/2.7.0/gems/syntax_tree-6.1.1/lib/syntax_tree/cli.rb:671:in `block (2 levels) in process_queue'

Despite my best efforts, I'm currently unable to pinpoint the cause of this issue. Could you possibly shed some light on what might be the root cause?

If I manage to reproduce this bug consistently, I'll make sure to report it here. Thanks in advance for your assistance!

@davidwessman
Copy link

Could you add the contents of the file it fails to parse?

@gtrias
Copy link
Author

gtrias commented May 16, 2023

Sorry I can't share the file contents. But I think I've found the cause of the problem! It seems that all failing files have something in common. All them have emojis inside. I'm going to check what LANG env var we have set in CI and try to change it to see if it changes something.

@gtrias
Copy link
Author

gtrias commented May 19, 2023

I confirm the problem was related to utf8 characters such as emojis. We ended up fixing it by proper installing and setting the locales in our Github Actions Runner docker images:

# Set the locale
RUN sudo sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && sudo locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

@gtrias gtrias closed this as completed May 19, 2023
@phyzical
Copy link

Thanks for this, for us it was random characters for example É

adding the following to our dockerfile resolved the issue

ENV LC_ALL="C.UTF-8"
ENV LANG="C.UTF-8"

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

No branches or pull requests

3 participants