Undefined method error - please advise
pmjs opened this issue · 13 comments
C:\Users\pmjs>claws
undefined method inject' for #<String:0x248a078> C:/Ruby193/lib/ruby/gems/1.9.1/gems/claws-1.2.0/lib/claws/report/ec2.rb:29:in
b
lock in run': undefined method each' for nil:NilClass (NoMethodError) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/command_line_reporter-3.2.1/lib /command_line_reporter.rb:118:in
table'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/claws-1.2.0/lib/claws/report/ec
2.rb:16:in run' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/claws-1.2.0/lib/claws/command/e c2.rb:19:in
exec'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/claws-1.2.0/bin/claws:13:in <t op (required)>' from C:/Ruby193/bin/claws:23:in
load'
from C:/Ruby193/bin/claws:23:in `
I would advise a little more information to help solve the problem you are encountering. Just throwing up a stack trace doesn't really help much.
Thanks for your response.
I am using fog.io. I wanted something to glance at my instances. From the description - CLAWS seemed to fit the bill. hence wanted to take it for a spin :-)
here is some info that might be useful. Please let me know what other information i could provide.
Platform : windows 7/ Ruby 1.9
i was following along with the getting started tutorial. I just wanted to display the instances running in my EC2 account.
Steps to reproduce the error :
- install claws gem
- claws --init #create the initial config file
- edit the configuration file - provide security key & key id
- claws # run claws
this is where i am getting the above mentioned error
am i missing something ?
P.S. I was trying to do the same on Amazon Linux instance and ran into an issue in the same line report/ec2.rb:29. i Read in one of your other post that you have only tested claws on 1.9. Amazon Linux AMI comes with Ruby 1.8.
Master now has 1.8.7 support. Try cloning and issuing:
ruby -I lib bin/claws -d
I cloned the master and tried to run but still unable to get past that line - ./lib/claws/report/ec2.rb:29. this is on ruby 1.8.7 on amazon ec2 linux AMI. if this is useful info ; i am only populating the security key & id in the config file. I am not populating the ssh keys.
$ ruby -I lib bin/claws -d
undefined method last' for #<String:0xb6e4dc8c> ./lib/claws/report/ec2.rb:29:in
run': undefined method each' for nil:NilClass (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/command_line_reporter-3.2.1/lib/command_line_reporter.rb:118:in
table'
from ./lib/claws/report/ec2.rb:16:in run' from ./lib/claws/command/ec2.rb:19:in
exec'
from bin/claws:13
The ssh keys won't matter when using the -d flag. It seems as if you are getting an error response back from AWS instead of a collection of instance objects. Since you have cloned it do you know how to step through the code with the debugger? I would love to know what the value of collection is on line 21 of lib/claws/collection/ec2.rb after the call AWS is complete. A puts would help as well if you can't do the debugger.
the code is not reaching the lib/claws/collection/ec2.rb at all.
I wrote some puts at different parts of the code. but i was not able to see y the collections was not called.
Can you let me know the call stack for collections/ec2.rb .. then it might be helpful for me to find out why the code is not reaching there.
thanks for helping.
P.S. i dont have regions in the current config file. does it have to do anything with this?
Regions in the config file won't have anything to do with it because when they are not defined here the code collects instances from all regions.
Try putting some puts statements around lib/claws/command/ec2.rb. Specifically dump the instances variable before the report is run on line 19. What does that give us?
The instance is nil in the command/ec2.rb
- Looks like instances = Claws::Collection::EC2.new(config).get in command/ec2.rb raises an exception
- The control goes into the rescue Exception => e block , how ever e.message doesn't get printed.
- puts e : inside exception block returns
undefined method `last' for #String:0xb6eb8244
am i making sense ?
You are making sense. My next suggestion is to modify the following in lib/claws/command/ec2.rb at line 13:
begin
instances = Claws::Collection::EC2.new(config).get
rescue Exception => e
puts e.message
end
into separate statements (always on the fence about method chaining):
proxy, instances = nil, nil
begin
proxy = Claws::Collection::EC2.new(config)
rescue Exception => e
puts e
end
puts proxy
begin
instances = proxy.get
rescue Exception => e
puts e
end
puts instances
Hate doing it this way but without using a debugger in that environment this is forcing our hand
results from the puts statement in the above code change
undefined method last' for #<String:0xb6e34214> nil undefined method
get' for nil:NilClass
nil
So given the fact that the proxy is nil in this case it makes me wonder if your configuration is correct? We are not getting a response from AWS is what this is indicating. I wonder if you could test connecting to AWS from the command line for me. From your cloned repo:
w.bailey@MC-W8012PTTAGW:~/dev/claws[master]> irb -I lib -r claws
1.9.3p125 :001 > config = Claws::Configuration.new
=> #<Claws::Configuration:0x007f8e0a08a008 ..., @aws={"access_key_id"=>"xxx", "secret_access_key"=>"xxx"}, ...>>
1.9.3p125 :002 > AWS.config config.aws
=> <AWS::Core::Configuration>
That last line indicates success. What do you get?
I found the issue. As you guessed there was a problem with the configuration.
In the config file where you specify the AWS key, there should be 1 space or 1 tab and there shall be no quotes
e.g :
aws:
secret_access_key: WSAWDAJCYSES7H1wc4/DkMSD7yKwc4/DkMYSES73
access_key_id: WDFHHJASS7HOLHXKYDA
thanks for helping me figure out the issue.
may be a FAQ would be in place to avoid someone run in to this issue.
There is both good and bad in that last response. The good is that we found the issue. The bad is that you actually posted your keys which you should never do! I would suggest you change those immediately.
I did make the assumption that most folks knew how to author a yaml file but i'll add some basic instructions to the wiki to make sure others don't make this mistake.