Skip to content
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

NoMethodError (private method `puts' called for #<Cucumber::Formatter::Interceptor::Pipe:0x00007fc8a5bc0c08>) #1445

Closed
haonv88 opened this issue Jul 15, 2020 · 9 comments
Labels
🐛 bug Defect / Bug ⌛ stale Will soon be closed by stalebot unless there is activity

Comments

@haonv88
Copy link

haonv88 commented Jul 15, 2020

Describe the bug
When using the JUnit Formatter for --format , I got error NoMethodError (private method puts' called for #Cucumber::Formatter::Interceptor::Pipe:0x00007fc8a5bc0c08)`

To Reproduce
Steps to reproduce the behavior:

  1. Go to rails console
  2. require 'cucumber/formatter/interceptor'
  3. interceptederr = Cucumber::Formatter::Interceptor::Pipe.wrap(:stderr)
  4. $stderr.puts "test" # raise error NoMethodError (private method puts' called for #Cucumber::Formatter::Interceptor::Pipe:0x00007fc8a5bc0c08)`

Expected behavior
Should not raise error.

Context & Motivation

As I research, in cucumber-4.1.0/lib/cucumber/formatter/interceptor.rb:34
$stderr.puts("test") will invoke method

        def method_missing(method, *args, &blk)
          @pipe.send(method, *args, &blk) || super
        end

@pipe.send(method, *args, &blk) will log the error and return nil, then it keeps calling super and raise error

Screenshots
Screen Shot 2020-07-15 at 15 01 21

Your Environment

  • Versions used [4.1.0]
  • Operating System and version [MacOs 10.15.5 ]
@vincent-psarga vincent-psarga added the 🐛 bug Defect / Bug label Jul 15, 2020
@vincent-psarga
Copy link
Contributor

Thanks for the report.

I'm trying to investigate on what may cause this issue. Do you have a full stack-trace by any chance or is it the same than when you use the method to reproduce the issue ?

@haonv88
Copy link
Author

haonv88 commented Jul 21, 2020

Hi @vincent-psarga I don't have full stack-trace.

          command: |
            [[ -n $SKIP_EXECUTION ]] || (mkdir -p ~/cucumber && \
            ./bin/cucumber --format junit \
                                 --out ~/cucumber/junit.xml \
                                 $(circleci tests glob "features/**/*.feature" | circleci tests split --split-by=filesize))

When I run cucumber in CI. The above error (NoMethodError private method) will hide the real errors from ruby libraries, because $stderr.puts does not work anymore.

@luke-hill
Copy link
Contributor

luke-hill commented Jul 21, 2020

@haonv88 I think what vincent is saying is in your screenshot it says "traceback from irb (1)" could you paste the next 10-20lines of that. If there are no other lines, that is fine, but I would expect some interceptions to be passed which should give us more info.

@haonv88
Copy link
Author

haonv88 commented Jul 21, 2020

Hi @luke-hill There are no other lines for the traceback. I think it's easy to reproduce, you can do the same as the screenshot to see the error.

@vincent-psarga
Copy link
Contributor

In fact, what I'd like to understand is how cucumber ends up trying to call puts directly on $stderr (as usually the process uses named streams for I/O).
And I was not able to reproduce the issue, at least when running cucumber cli (your way to reproduce the bug works great and will certainly be used as the non-regression test :) )

I'm wondering if there's a step definition or something else trying to puts directly on $stderr for example, mainly to fix the bug in a more robust way.

@haonv88
Copy link
Author

haonv88 commented Jul 22, 2020

Screen Shot 2020-07-22 at 09 26 06

There are many places in my gem files which call puts directly on $stderr. Do you want to know that @vincent-psarga ?

@vincent-psarga
Copy link
Contributor

Yes that's what I was looking for.

I think the issue was introduced in this commit and, as I understand it, we were calling super when as calling puts on the stream does not return anything.

I've pushed a commit fixing that in #1449

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.

@stale stale bot closed this as completed Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug ⌛ stale Will soon be closed by stalebot unless there is activity
Projects
None yet
Development

No branches or pull requests

3 participants