engineyard / core-client-rb

Engine Yard Core API Ruby client
MIT License
4 stars 22 forks source link

ey-core throws exception (at ruby-2.4) #85

Closed victorjtfranco closed 7 years ago

victorjtfranco commented 7 years ago

I replicated the issue inside a Docker container:

docker run --rm -it -v ~/.eyrc:/root/.eyrc ruby bash 
# gem install ey-core 
# ey-core whoami 
Found legacy .eyrc token. Migrating to core file 
Creating /root/.ey-core 
Error: 
undefined method `+' for nil:NilClass 

The ~/.eyrc file is in the format

---
api_token: <here goes api token>

And the token is valid, because the followin command gives correct output:

curl --header "X-EY-TOKEN: `cat ~/.eyrc | grep 'api_token' | awk '{print $2}'`" "https://api.engineyard.com/accounts"

Is there any other info to get / tests to help debugging? Thanks!

jacobo commented 7 years ago

I've seen this issue before due to incompatible version of the colorize gem, workaround is gem install colorize but leaving this ticket open as it deserves an actual fix...

victorjtfranco commented 7 years ago

@jacobo Your comment broght to my attention the Ruby version. In my case, rvm install ruby-1.9; ey-core whoami solved it. (gem install colorize did not, though :confused: ) https://github.com/engineyard/core-client-rb/blob/40c5f3e1bb4f6bd90a70ea4799e268ee1bc57700/.ruby-version gave the hint Then, we have two different issues.

jacobo commented 7 years ago

so which version of ruby were you on previously that did not work? (we should try to raise a more helpful exception) .. oh wait you put it in the issue title. Yikes we better fix support for ruby 2.4

crigor commented 7 years ago

I was able to reproduce the issue. The code below from cistern-0.12.2/lib/cistern/attributes.rb doesn't work on ruby 2.4.

self.class.attributes[name.to_s.to_sym][:coverage_hits] += 1 rescue  nil
# Ruby 2.4
root@c2e916ec7a0e:/# irb
irb(main):001:0> h = {}
=> {}
irb(main):002:0> h[:foo] += 1 rescue nil
NoMethodError: undefined method `+' for nil:NilClass
    from (irb):2
    from /usr/local/bin/irb:11:in `<main>'
irb(main):003:0> 
# Ruby 2.3
2.3.1 :001 > h = {}
 => {} 
2.3.1 :002 > h[:foo] += 1 rescue nil
 => nil 
#<NoMethodError: undefined method `+' for nil:NilClass>
/usr/local/bundle/gems/cistern-0.12.2/lib/cistern/attributes.rb:124:in `read_attribute'
/usr/local/bundle/gems/cistern-0.12.2/lib/cistern/attributes.rb:75:in `block in attribute'
/usr/local/bundle/gems/cistern-0.12.2/lib/cistern/formatter/awesome_print.rb:30:in `block in awesome_cistern_model'
/usr/local/bundle/gems/cistern-0.12.2/lib/cistern/formatter/awesome_print.rb:30:in `each'
/usr/local/bundle/gems/cistern-0.12.2/lib/cistern/formatter/awesome_print.rb:30:in `inject'
/usr/local/bundle/gems/cistern-0.12.2/lib/cistern/formatter/awesome_print.rb:30:in `awesome_cistern_model'
/usr/local/bundle/gems/awesome_print-1.7.0/lib/awesome_print/formatter.rb:34:in `format'
/usr/local/bundle/gems/awesome_print-1.7.0/lib/awesome_print/inspector.rb:148:in `unnested'
/usr/local/bundle/gems/awesome_print-1.7.0/lib/awesome_print/inspector.rb:115:in `awesome'
/usr/local/bundle/gems/awesome_print-1.7.0/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
/usr/local/bundle/gems/awesome_print-1.7.0/lib/awesome_print/core_ext/kernel.rb:20:in `ap'
/usr/local/bundle/gems/ey-core-3.2.6/lib/ey-core/cli/current_user.rb:11:in `handle'
/usr/local/bundle/gems/belafonte-0.5.0/lib/belafonte/rhythm.rb:94:in `run_handle'
/usr/local/bundle/gems/ey-core-3.2.6/lib/ey-core/cli/subcommand.rb:21:in `run_handle'
/usr/local/bundle/gems/belafonte-0.5.0/lib/belafonte/rhythm.rb:26:in `calculate_exit_status'
/usr/local/bundle/gems/belafonte-0.5.0/lib/belafonte/rhythm.rb:13:in `execute!'
/usr/local/bundle/gems/belafonte-0.5.0/lib/belafonte/rhythm.rb:83:in `dispatch'
/usr/local/bundle/gems/belafonte-0.5.0/lib/belafonte/rhythm.rb:26:in `calculate_exit_status'
/usr/local/bundle/gems/belafonte-0.5.0/lib/belafonte/rhythm.rb:13:in `execute!'
/usr/local/bundle/gems/ey-core-3.2.6/bin/ey-core:4:in `<top (required)>'
/usr/local/bundle/bin/ey-core:23:in `load'
/usr/local/bundle/bin/ey-core:23:in `<main>'
ehowe commented 7 years ago

Another issue here: json 1.8.3 won't install on ruby 2.4

ehowe commented 7 years ago

Created a pull request to cistern to fix this

ddiachkov commented 7 years ago

Closing it now. We have Ruby 2.4 in Travis.