Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

ERROR: TypeError: can't convert Array into String #278

Closed
daachi opened this issue Aug 20, 2013 · 20 comments · Fixed by #300
Closed

ERROR: TypeError: can't convert Array into String #278

daachi opened this issue Aug 20, 2013 · 20 comments · Fixed by #300

Comments

@daachi
Copy link

daachi commented Aug 20, 2013

I've come to rely on knife solo and for months it has worked without issue. Recently I rebuilt my gemset and version 0.3.0 was installed, and now knife solo simply doesn't work. Everything I've tried so far results in this error locally.

When I try to run chef-solo -j dna.json on an instance where the 'kitchen' has been uploaded I get an error message that the cookbooks can't be found.

I've spent about two full days trying to figure out how to get this working and am giving up at this point.

@tmatilai
Copy link
Collaborator

@daachi Very sorry to hear that. :(

Could you please run the knife solo command with -VV option and gist the debug output. That should reveal the problem.

@matschaffer
Copy link
Owner

Ouch. Sorry about that @daachi. Definitely get in touch asap next time. I feel bad having wasted your time like that.

Just doing some code browsing, it looks like this is probably coming out of solo_cook.rb:118 since it looks like Pathname.new can throw this. Example from ruby 2.0:

irb(main):003:0> Pathname.new(['a'])
TypeError: no implicit conversion of Array into String
    from (irb):3:in `initialize'
    from (irb):3:in `new'
    from (irb):3
    from /usr/local/opt/ruby/bin/irb:12:in `<main>'

Can you post your librarian and berkshelf version as well? That might help in diagnosing.

@danivovich
Copy link

I had this issue when I was setting role_path like cookbook path is set, with an array (in my .chef/knife.rb file), once I made sure role_path was just a string, it worked fine. The same issue could occur with data_bag_path. I think the wiki for updating to 0.3.0 was a bit misleading because role_path was nil, so it wasn't clear what the format of that should be if you want it to be non-nil. Maybe if I was more familiar with the knife.rb file I'd know that, but after only using chef solo, I've never had to mess with it much.

Hope this helps

@matschaffer
Copy link
Owner

@danivovich mind mosting your knife.rb for sake of completeness? Feel free to redact any sensitive names.

I'd say this is still an "issue" in that we should at least offer a better error. Looks like some some folks also think that role path should be an array.

@danivovich
Copy link

.chef/knife.rb

current_dir = File.dirname(__FILE__)
cookbook_path ["#{current_dir}/../cookbooks"]
role_path "#{current_dir}/../roles"
data_bag_path "#{current_dir}/../data_bags"

@matschaffer
Copy link
Owner

was it previously like this?

role_path ["#{current_dir}/../roles"]

@danivovich
Copy link

yes sorry, I should have posted the before and after. My natural tendency here was to copy the existing line I had, which was just cookbook_path part (and the current_dir assignment)

@daachi
Copy link
Author

daachi commented Aug 28, 2013

Sorry I have not had the chance to test this again yet. FWIW, cookbook_path and role_path are arrays, as in the other example (which I think is pretty standard, no?)

Anyway, once I get some other stuff finished up, I'll be testing the new version again in the next day or so.

Sorry for the grumpy original post; other than this, the solo plugin has been awesomely awesome.

@tmatilai
Copy link
Collaborator

Yeah, chef-solo does not accept arrays for role_path (only for cookbook_path), so knife-solo does neither. But for sure an array could be detected and a better error message shown.

@danivovich btw, you can use relative paths (rooting from the kitchen root) in knife.rb, e.g. role_path "roles".

@tmatilai
Copy link
Collaborator

How about #300 for a fix?

tmatilai added a commit to tmatilai/knife-solo that referenced this issue Oct 16, 2013
tmatilai added a commit to tmatilai/knife-solo that referenced this issue Oct 19, 2013
@tmatilai
Copy link
Collaborator

tmatilai commented Nov 8, 2013

The CHEF-2928 Mat linked made it to Chef 11.8.0. So chef-solo accepts arrays for role_path (and for cookbook_path, but not for others). Should we start supporting it? We should either have even more Chef version validation or people with older Chef versions on the node will get once again cryptic can't convert Array into String errors.

@matschaffer
Copy link
Owner

I don't want to spend too much time on cleaning up shortcomings in chef
itself. For example if chef's error messages suck, then I'd rather send a
PR to chef than code around it in knife-solo. Of course if someone's
passionate about it I wouldn't refuse a PR. Just probably not gonna pick it
up myself ;)

-Mat

about.me/matschaffer

On Fri, Nov 8, 2013 at 11:37 AM, Teemu Matilainen
notifications@github.comwrote:

The CHEF-2928 https://tickets.opscode.com/browse/CHEF-2928 Mat linked
made it to Chef 11.8.0. So chef-solo accepts arrays for role_path (and
for cookbook_path, but not for others). Should we start supporting it? We
should either have even more Chef version validation or people with older
Chef versions on the node will get once again cryptic can't convert Array
into String errors.


Reply to this email directly or view it on GitHubhttps://github.com//issues/278#issuecomment-28091223
.

@tmatilai
Copy link
Collaborator

if chef's error messages suck, then I'd rather send a PR to chef than code around it in knife-solo

Well, not possible in this case as the current and future versions support Arrays, but old one won't. And many will stick to Chef < 11.8 for a long time still.

Just probably not gonna pick it up myself ;)

Sure. Let's see if someone even explains the case why they need multiple role directories. =)

@holms
Copy link

holms commented Nov 11, 2013

just for the feedback: if you getting this error, please check that you in chef-repo directory.

@tmatilai
Copy link
Collaborator

@holms with Chef 11.8.0? #308 should fox it.

@ydawant
Copy link

ydawant commented Nov 14, 2013

I am getting this error and the only thing I have as an array is the cookbook_path. I'm sure I'm doing something wrong, if you guys could lead me in the right direction, I would appreciate it.

cookbook_path ["./cookbooks", "/Users/yannickdawant/.berkshelf/cookbooks"]

Log files in the gist.
https://gist.github.com/ydawant/7475537

@tmatilai
Copy link
Collaborator

@ydawant you hit #308. Add this to .chef/knife.rb:

chef_repo_path "."

Btw, pointing to berkshelf's repo probably work. You should just have Berksfile in your kitchen. Readme and wiki have more info.

@ydawant
Copy link

ydawant commented Nov 15, 2013

thanks @tmatilai! That seemed to work, and I did get it to work just pointing to berkshelf's repo before, I was more curious as to why I couldn't do the array if I wanted to, because I knew that I should be able to. At any rate, your fix worked. I appreciate it!

@tombeynon
Copy link

2 years later - thank you @tmatilai!

@thomasbiddle
Copy link

Another thanks to @tmatilai ! I ended up using this in solo.rb for a chef-solo setup. My only change was that I had to point it at the root folder for what held my environment folder.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants