cloudfoundry / cf-uaac

Apache License 2.0
41 stars 29 forks source link

Ruby Version 3.0.0 `tried to create Proc object without a block` (uaac target) #89

Closed kenswan closed 2 years ago

kenswan commented 3 years ago

Description

Receiving error on uaac target command with the latest version of Ruby (3.0.0). This is preventing connection to UAA.

Error

failed to access http://<domain>/uaa: tried to create Proc object without a block

Command

uaac target http://<domain>/uaa

Versions

UAAC

Java

Ruby

cf-gitbot commented 3 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/177227892

The labels on this github issue will be updated when the story is started.

friegger commented 3 years ago

Anybody looking into this? We would also like to use uaac in a Ruby 3 environment.

ameowlia commented 3 years ago

I also ran into this again. Ruby 3.0.0 has been out for 5 months. Please fix.

LittleBaiBai commented 2 years ago

Any update on this? We also ran into this and it has made troubleshooting harder than before.

gid0 commented 2 years ago

Same here since we updated our docker images to Alpine 3.15 (with Ruby 3.0).

geofffranks commented 2 years ago

Thanks for the fix @strehle / @bgandon!

I'm still seeing an issue though with uaac target <hostname> --skip-ssl-validation:

$ uaac target uaa.sys.sprintred.cf-app.com --skip-ssl-validation
Unknown key: Max-Age = 86400

Target: https://uaa.sys.<domain>
$ uaac target uaa.sys.<domain>

Target: https://uaa.sys.<domain>

This is occurring on ruby 2.7.4, and ruby 3.1.0 with cf-uaac 4.4.0. Any ideas?

geofffranks commented 2 years ago

Actually, on ruby 3.1.0, even without --skip-ssl-validation, i get failures still:

uaac target uaa.sys.<domain>
Unknown key: Max-Age = 86400
failed to access https://uaa.sys.<domain>: tried to create Proc object without a block
strehle commented 2 years ago

@geofffranks can you please check your cf-uaa-lib and cf-uaac versions with gem, because I have tested this with ruby 3.1.x ( ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux] ) and for me it worked, e.g.

uaac target https://login.uaa-acceptance.cf-app.com --skip-ssl-validation or other target with token request received one

check gem e.g. gem list |grep cf- cf-uaa-lib (3.14.4) cf-uaac (4.4.0)

if you have more version, please uninstall older versions, e.g. gem uninstall cf-uaa-lib and re-install latest cf-uaa-lib and cf-uaac

geofffranks commented 2 years ago

I only have cf-uaa-lib 3.14.4 and cf-uaac 4.4.0 as well. I did notice on ruby 3.1.0, if there was a nexisting uaac.yml, uaac target works, but other commands do not. Once deleting uaac.yml, target fails again on 3.1.0:

~ ad+gf
$ rbenv global 2.7.4
$ rbenv rehash
$ hash -r
$ uaac -v
rubUAA client 4.4.0

$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]

$ gem list | grep uaa
cf-uaa-lib (3.14.4)
cf-uaac (4.4.0)

$ uaac target uaa.sys.<domain>
Unknown key: Max-Age = 86400

Target: https://uaa.sys.<domain>

$ uaac token client get admin
Client secret:  **** (i specified a bad password here, hence the failure)
Unknown key: Max-Age = 86400

error response:
{
  "error": "unauthorized",
  "error_description": "Bad credentials"
}
attempt to get token failed

$ rbenv global system
$ rbenv rehash
$ hash -r
$ rbenv rehash
$ uaac -v
gemUAA client 4.4.0

$ gem list | grep uaa
cf-uaa-lib (3.14.4)
cf-uaac (4.4.0)

$ ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]

$ uaac target uaa.sys.<domain>

Target: https://uaa.sys.<domain>

$ uaac token client get admin
asdfClient secret:  ****

ArgumentError: tried to create Proc object without a block

attempt to get token failed

$ rm ~/.uaac.yml
$ uaac target uaa.sys.<domain>
Unknown key: Max-Age = 86400
failed to access https://uaa.sys.<domain>: tried to create Proc object without a block
strehle commented 2 years ago

sorry, but I did not see it. I see it, if I enforce "gem install cf-uaac -v 4.3.0" on runtime > 3.x

I tested now in matrix with 2.7.4 , 3.0.0, 3.1.0

-> gem install cf-uaa-lib -> gem install cf-uaac

I tested with rvm on a ubuntu 20.x native and on my WSL 2 with ubuntu 18.04. With rvm I had to install (and compile) always cf-uaa* newly but I get it working with and without .uaac.yml.

I can reproduce what you write, but only with the mixed versions.

I am no expert if rvm or rbenv is better, e.g. https://metova.com/choosing-a-ruby-version-management-tool-rbenv-vs-rvm/ However , I cannot see it, and therefore dont really can do any fix. For CI there is github action with tests on all runtimes we mentioned, https://github.com/cloudfoundry/cf-uaac/actions

@bgandon any hints from your side ?

geofffranks commented 2 years ago

Well, I repaved my workstation and everything seems to be working now (it had been built with 4.3.0/3.14.3 and upgraded). I have no idea what rbenv/gem install did to me that made it all blow up, but thanks for taking a look!