[dphillips@imac:~/src/presto master] travis logs 29248.9
displaying logs for prestodb/presto#29248.9
undefined method `each_pair' for #<String:0x00007fd51a053e70>
Did you mean? each_char
for a full error report, run travis report --org
[dphillips@imac:~/src/presto master] travis report --org
System
Ruby: Ruby 2.5.0-p0
Operating System: Mac OS X 10.13.3
RubyGems: RubyGems 2.7.4
CLI
Version: 1.8.8
Plugins: none
Auto-Completion: no
Last Version Check: 2018-02-08 18:38:34 -0800
Session
API Endpoint: https://api.travis-ci.org/
Logged In: as "electrum"
Verify SSL: yes
Enterprise: no
Endpoints
org: https://api.travis-ci.org/ (access token, current)
Last Exception
An error occurred running `travis logs --org`:
NoMethodError: undefined method `each_pair' for #<String:0x00007fd51a053e70>
Did you mean? each_char
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/session.rb:139:in `load'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/session.rb:166:in `get'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/session.rb:319:in `fetch_one'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/session.rb:128:in `reload'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/entity.rb:208:in `load_attribute'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/entity.rb:54:in `block (2 levels) in attributes'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/entity.rb:194:in `relation'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/entity.rb:71:in `block (2 levels) in has'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/client/artifact.rb:51:in `body'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/cli/logs.rb:39:in `display_log'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/cli/logs.rb:23:in `run'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/cli/command.rb:198:in `execute'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/lib/travis/cli.rb:64:in `run'
from /Users/dphillips/homebrew/lib/ruby/gems/2.5.0/gems/travis-1.8.8/bin/travis:18:in `<top (required)>'
from /Users/dphillips/homebrew/bin/travis:23:in `load'
from /Users/dphillips/homebrew/bin/travis:23:in `<main>'
For issues with the command line tool, please visit https://github.com/travis-ci/travis.rb/issues.
For Travis CI in general, go to https://github.com/travis-ci/travis-ci/issues or email support@travis-ci.com.
Any progress on this? Still getting this when trying to do any travis command such as whoami or encrypt. “undefined method `each_pair’ for #String:0x00000001058240”
I have forked release 1.8.8 and applied the changes described in this thread, and it works for me 😃
https://github.com/textarcana/travis.rb/tree/fix-issue-578
The easiest way to install this is with bundler. Add the following to your
Gemfilethen runbundle install:gem 'travis', :git => 'https://github.com/textarcana/travis.rb.git', :branch => 'fix-issue-578'To figure out where bundler put the executable, type
bundle info travisUpdated: Here is an even easier way to install
gem install specific_installgem specific_install https://github.com/textarcana/travis.rb.git fix-issue-578You should be able to use the
traviscommand normally after that.Seems there’s some recent PR activity.
Been making do with this ugliness, but hopefully not for much longer:
Any progress on this?
I looked through this issue again after venting earlier this morning.
This is not a solution in itself, it’s just the piece that I didn’t pick up while skimming through this issue and being unfamiliar with ruby.
The workaround is to patch client/session.rb yourself as suggested and described in https://github.com/travis-ci/travis.rb/issues/578#issuecomment-368142083 .
If you don’t know where to find the file run
travis report --org. It’ll show you the stacktrace and a path like the following:/var/lib/gems/2.3.0/gems/travis-1.8.8/lib/travis/client/session.rbThen you add the
class Hashat the top of the file and the three lines to theloadmethod from from the comment above:This issue seems to still happen with Ruby 2.5.1 and
travisgem 1.8.9.Thanks @20goto10, I’ve added your patch to my local files and ran into:
undefined method 'pending?' for nil:NilClass for a full error report, run travis report --orgNoMethodError: undefined method 'pending?' for nil:NilClass from /usr/local/rvm/gems/ruby-2.1.8/gems/travis-1.8.8/lib/travis/client/artifact.rb:51:inbody’`I commented
unless stream and job.pending?on line 51 (artifact.rb) and now I’m getting the logs again.Hopefully they’ll address this issue soon.
I was running into this too, and added a patch you can insert in your own code to the “load” method, overriding it. It’s a total hack, but it works, which is enough for my purposes (an internal tool).
Note: I posted a solution earlier and then realized it was flawed, but the code below should work.
It should work now without updating your client.
Testing patch in textarcana#1 on travis gem
1.8.9with Ruby2.5.1still results in same error & stacktrace posted by @eneko.Function that fails is the line calling
each_pairhere:There is a
Stringin one of these data objects which looks like the log output. This can be observed if you add some print lines right before this to print things out:This object is a long ruby string with
"text" + " more text " + ...representing the build log output. Assumptions based on this are that at some point maybe this was a type supporting.each_pair, maybe this code was different, or Travis API output changed?Essentially the patch just forces the data into a Struct it won’t choke on later (which manifests as the whole ‘each_pair’ thing), whenever the data arrives as a String. So what I didn’t really look into is why it’s arriving sometimes as a String and sometimes not. I’m guessing there’s just a spot in the code somewhere where it usually takes the raw API results and puts them into some class, and in the case of these logs it isn’t doing it. But I didn’t have the patience to hunt that down at the time (and still don’t since my own use for this API is a simple internal helper app, nothing enterprise-y). Retrieving the logs would obviously be a major use case for this API so I’m pretty surprised this hasn’t been patched properly by now.
I don’t want to get in the way of progress but the original snippet I posted is really a hack. There should be a better solution to this problem. I just didn’t have the time to hunt through this code and work it out properly. That having been said… whatever works! Thanks for taking the time to put together a usable branch, @textarcana !
@textarcana Thanks, I applied those changes and it fixed the problem for me. Can finally show long logs again with
travis logs -i 29039.2|less -R🎉. Will you file it as PR here, so it can be merged upstream?@leusonmario did you try https://github.com/travis-ci/travis.rb/issues/578#issuecomment-368936908?
Same issue here 😦
Maybe I did it wrong but I also could not get the suggested “patch” to work
@textarcana Your patch that you made works like a charm for us too! I was wondering if you wanted to make a pull request on https://github.com/travis-ci/travis.rb so that your patch could be merged in with the official gem on RubyGems. We’d love to be able to use your patch on our own gems, but your patch would need to be merged into their original master branch.
heh. My use for this API is enterprisey like Starfleet 😃 so I definitely need the
logscommand to work.I can see how it’s an easy workaround and that’s probably why no one fixed it up to now?
Anyway now that you have explained a bit I feel I could take a dive into fixing the actual problem (as time allows). 👍
@20goto10 yes I too have no idea what the patch does.
It seems others who have commented here before, have more knowledge of how the gem works?
If we can arrive at a patch that someone who knows how this thing works 😃 can say is acceptable, I would be more than happy to create a PR and shepherd it through the merging process!