Category Archives: Gems

Chef: knife “FATAL: X nodes found, but does not have the required attribute to establish the connection.”

A couple of weeks ago I was trying to do a chef-deploy using the knife ssh command from Chef and specifying the role, but was getting the following error:

chef-repo proctor$ knife ssh "role:reporting" "sudo chef-deploy"
FATAL: 12 nodes found, but does not have the required attribute to establish the connection. Try setting another attribute to open the connection using --attribute.

When I tried to do a search of nodes using the knife search command, I was getting another error:

chef-repo proctor$ knife search node role:reporting
ERROR: knife encountered an unexpected error
This may be a bug in the 'search' knife command or plugin
Please collect the output of this command with the `-VV` option before filing a bug report.
Exception: NoMethodError: undefined method `name' for #<Hash:0x007fa8d9914f40>

I could do a knife ssh and do a chef-deploy if I did a manual listing of the servers.

chef-repo proctor$ knife ssh -m "reportingserver.qualified.domain" "sudo chef-deploy"

I knew we had the servers setup with the chef gem at version 10.24.0, and had thought I was setup with 10.24.0 locally as well. When I double checked my local version of the chef gem I saw I was actually on 10.20.0 locally. After uninstalling the chef gem, and installing to target 10.24.0 to match the servers, everything started working as expected.

Hopefully, you encounter errors similar to the above this will save you some time, and help you learn from my problem, and serve as a notice to double check the versions of the chef gem between your local environment and your servers.

–Proctor

Error installing iconv

Today I was trying to install the iconv gem, and was getting this error

$gem install iconv
Building native extensions.  This could take a while...
ERROR:  Error installing iconv:
	ERROR: Failed to build gem native extension.

        <rvm_dir>/rubies/ruby-2.0.0-preview2/bin/ruby extconf.rb
checking for rb_enc_get() in ruby/encoding.h... yes
checking for iconv() in iconv.h... no
checking for iconv() in -liconv... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=<rvm_dir>/rubies/ruby-2.0.0-preview2/bin/ruby
	--with-iconv-dir
	--with-iconv-include
	--without-iconv-include=${iconv-dir}/include
	--with-iconv-lib
	--without-iconv-lib=${iconv-dir}/
	--enable-config-charset
	--disable-config-charset
	--with-config-charset
	--without-config-charset
	--with-iconvlib
	--without-iconvlib


Gem files will remain installed in <rvm_dir>/gems/ruby-2.0.0-preview2/gems/iconv-1.0.2 for inspection.
Results logged to <rvm_dir>/gems/ruby-2.0.0-preview2/gems/iconv-1.0.2/ext/iconv/gem_make.out

After a bit of searching, I found a number of answers suggesting that I would need to reinstall ruby via RVM, but in the following StackOverflow question
failed-to-build-iconv-gem-on-ruby-1-9-2.

In it was the solution:
gem install iconv -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1

After that, all was well.

–Proctor