chef windows cookbook compile error, cannot find file windows/error - windows

On a chef-client run, I'm seeing this windows cookbook compile error, as show below. What is it trying to require in that it can't find, and how to fix? Is 'windows/error' a ruby gem or something else?
================================================================================
Recipe Compile Error in c:/chef/cache/cookbooks/windows/libraries/windows_privileged.rb
================================================================================
LoadError
---------
cannot load such file -- windows/error
Cookbook Trace:
---------------
c:/chef/cache/cookbooks/windows/libraries/windows_privileged.rb:24:in `<top (required)>'
Relevant File Content:
----------------------
c:/chef/cache/cookbooks/windows/libraries/windows_privileged.rb:
17: # distributed under the License is distributed on an "AS IS" BASIS,
18: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: # See the License for the specific language governing permissions and
20: # limitations under the License.
21: #
22:
23: if RUBY_PLATFORM =~ /mswin|mingw32|windows/
24>> require 'windows/error'
25: require 'windows/registry'
26: require 'windows/process'
27: require 'windows/security'
28: end
29:
30: #helpers for Windows API calls that require privilege adjustments
31: class Chef
32: class WindowsPrivileged
33: if RUBY_PLATFORM =~ /mswin|mingw32|windows/
Running handlers:
[2016-02-08T09:31:54-08:00] ERROR: Running exception handlers
Running handlers complete
[2016-02-08T09:31:54-08:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 minutes 44 seconds

Found solution with help from a friend.
chef-client versions > 12.5 will need to install a gem
gem install windows-pr
To find this solution, go to the cookbook github repo and search in the "issues" there. That's the method, here's the direct link:
https://github.com/chef-cookbooks/windows/issues/276

Related

Project working on one computer but not the other

My ruby project is working fine on one of my Macbooks, but on the other I get this error:
Traceback (most recent call last):
13: from bin/audiobook-now:5:in `<main>'
12: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/cli.rb:50:in `run'
11: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/cli.rb:7:in `get_books_from'
10: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/scraper.rb:7:in `scrape_book_list'
9: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/capybara-2.18.0/lib/capybara/session.rb:274:in `visit'
8: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:100:in `visit'
7: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:27:in `browser'
6: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:47:in `client'
5: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:16:in `start'
4: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:16:in `new'
3: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:53:in `initialize'
2: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver.rb:24:in `detect!'
1: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:116:in `detect!'
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:143:in `raise_not_found!': Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)
I had been getting similar problems at various points and most of the fixes were in the code (some require statements were looping around to each other), but the program works on my other Macbook without these errors. Their repos are synced, I've even tried looking at the code to make sure they're identical. I've also used bundle list to compare the versions of the gems and they match. Here's the gemfile, in case it's helpful.
source "https://rubygems.org"
gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'
gem 'pry-nav'
gem 'poltergeist'
gem 'nokogiri'
gem 'rspec'
gem 'require_all'
Both Macbooks are running the same version of Mojave and I don't think there's anything different about the systems that would cause this. They should all be on the same version of gems and bundlers etc.
Any ideas?
This line
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:143:in `raise_not_found!': Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)
explains why your project does not work on another computer.
Gem poltergeist is a PhantomJS driver for Capybara. To make it work you need to install phantomjs (a headless browser). You could download it from PhantomJS official site:
http://phantomjs.org/download.html
Make sure you're installing the same version. To do so run this command in Terminal of 1st Macbook:
phantomjs -v
to find out the installed version, and install the same version on the 2nd Macbook.

Error when installing Nokigori with Chef recipe

I'm trying to install and use Nokigoro for XML parsing (if there is an alternative parser that doesn't result in mindless head hitting of wall - I'm happy to check it out)
I'm running this via a recipe on the chef client, in my recipe I have:
# include_recipe 'ohai'
chef_gem 'nokogiri'
require 'nokogiri'
which is as far as it gets really.
Running this as my run list results in the following error:
Starting Chef Client, version 12.12.15
[2017-03-31T14:07:36+00:00] WARN: Run List override has been provided.
[2017-03-31T14:07:36+00:00] WARN: Original Run List: []
[2017-03-31T14:07:36+00:00] WARN: Overridden Run List: [recipe[steve-solr]]
resolving cookbooks for run list: ["steve-solr"]
Synchronizing Cookbooks:
- steve-solr (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: steve-solr::default
* chef_gem[nokogiri] action install
================================================================================
Error executing action `install` on resource 'chef_gem[nokogiri]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1/ext/nokogiri
/opt/chef/embedded/bin/ruby -r ./siteconf20170331-19864-1d63c49.rb extconf.rb
checking if the C compiler accepts ... *** 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
--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=/opt/chef/embedded/bin/ruby
--help
--clean
/opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `block in try_compile'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:533:in `with_werror'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:630:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:406:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
Ran /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/steve-solr/recipes/default.rb:8:in `from_file'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/steve-solr/recipes/default.rb
8: chef_gem 'nokogiri'
9: require 'nokogiri'
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/steve-solr/recipes/default.rb:8:in `from_file'
chef_gem("nokogiri") do
package_name "nokogiri"
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :chef_gem
cookbook_name "steve-solr"
recipe_name "default"
gem_binary "/opt/chef/embedded/bin/gem"
end
Platform:
---------
x86_64-linux
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/steve-solr/recipes/default.rb
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
chef_gem[nokogiri] (steve-solr::default line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1/ext/nokogiri
/opt/chef/embedded/bin/ruby -r ./siteconf20170331-19864-1d63c49.rb extconf.rb
checking if the C compiler accepts ... *** 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
--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=/opt/chef/embedded/bin/ruby
--help
--clean
/opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `block in try_compile'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:533:in `with_werror'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:630:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:406:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
Ran /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" returned 1
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/steve-solr/recipes/default.rb:8:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/steve-solr/recipes/default.rb:
1: #
2: # Cookbook Name:: steve-solr
3: # Recipe:: default
4: #
5: # Copyright (c) 2017 The Authors, All Rights Reserved.
6: # include_recipe 'aws'
7: # include_recipe 'ohai'
8>> chef_gem 'nokogiri'
9: require 'nokogiri'
10:
11: class SolrObject
12: attr_reader :coreName
13: def initialize(name)
14: #coreName = name
15: end
16:
17: def coreName
Platform:
---------
x86_64-linux
Running handlers:
[2017-03-31T14:07:38+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-03-31T14:07:38+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2017-03-31T14:07:38+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2017-03-31T14:07:38+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-03-31T14:07:38+00:00] ERROR: chef_gem[nokogiri] (steve-solr::default line 8) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
STDOUT: Building native extensions. This could take a while...
STDERR: ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1/ext/nokogiri
/opt/chef/embedded/bin/ruby -r ./siteconf20170331-19864-1d63c49.rb extconf.rb
checking if the C compiler accepts ... *** 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
--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=/opt/chef/embedded/bin/ruby
--help
--clean
/opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `block in try_compile'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:533:in `with_werror'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:582:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:630:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:406:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/nokogiri-1.7.1 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.7.1/gem_make.out
---- End output of /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" ----
Ran /opt/chef/embedded/bin/gem install nokogiri -q --no-rdoc --no-ri -v "1.7.1" returned 1
[2017-03-31T14:07:38+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
with this being in my error file:
"gcc -o conftest -I/opt/chef/embedded/include/ruby-2.1.0/x86_64-linux -I/opt/chef/embedded/include/ruby-2.1.0/$
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
any help or suggestions on fixing would be fantastic, thanks.
Just remove the chef_gem entirely. We bundle nokogiri with the Chef installer so you don't have to install or compile it unless you specifically need the latest version for some reason.

Is it possible (or even recommended) to mock a Ruby require statement in ChefSpec?

I've been writing ChefSpec unit test suites for the past couple of weeks and have managed to do quite a bit with it, but I have found a scenario that got me stumped. I have a recipe that includes the 'aws' cookbook's default recipe, which in turn installs the right_aws and then proceeds to require it.
But the ChefSpec runner seems to have problems with it, spitting out a Ruby LoadError:
LoadError
---------
cannot load such file -- right_aws
Cookbook Trace:
---------------
/var/folders/0r/cg1hmpkj2nb3wh6slrg1hkhm0000gn/T/d20140612-36208-q1ecjj/cookbooks/aws/recipes/default.rb:25:in `from_file'
/var/folders/0r/cg1hmpkj2nb3wh6slrg1hkhm0000gn/T/d20140612-36208-q1ecjj/cookbooks/acmecorp-postgresql/recipes/server.rb:71:in `from_file'
Relevant File Content:
----------------------
/var/folders/0r/cg1hmpkj2nb3wh6slrg1hkhm0000gn/T/d20140612-36208-q1ecjj/cookbooks/aws/recipes/default.rb:
18: #
19:
20: chef_gem "right_aws" do
21: version node['aws']['right_aws_version']
22: action :install
23: end
24:
25>> require 'right_aws'
26:
Is there a way to mock that require 'right_aws' line from the 'aws' cookbook in my test? Is it recommended?
Is it better to simply install the right_aws gem on the system running ChefSpec tests?
You have a few options:
You can ensure right_aws is available by installing it directly on your machine or with a Gemfile (as noted in the question comments)
You can mock the call to include_recipe directly (if you don't need the included recipe for your test)
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe)
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe).with('aws').and_return(true)
Mock the requires call itself.
allow(Kernel).to receive(:require)
allow(Kernel).to receive(:require).with("right_aws").and_return(true)
If possible, I'd recommend #2

Chef does non sequential recipe execution

I followed tutorial http://gettingstartedwithchef.com/, chapter 1.
My run list is
"run_list": [ "recipe[apt]", "recipe[phpap]" ]
My default recipe of phpap cookbook
include_recipe "apache2"
include_recipe "build-essential"
include_recipe "openssl"
include_recipe "mysql::client"
include_recipe "mysql::server"
include_recipe "php"
include_recipe "php::module_mysql"
include_recipe "apache2::mod_php5"
include_recipe "mysql::ruby"
Dependencies of my cookbook
depends "apache2"
depends "mysql"
depends "php"
depends "database"
My repo has following downloaded cookbooks
apache2 aws database openssl phpap xml
apt build-essential mysql php postgresql xfs
I use chef-solo. My host has outdated apt repo info.
Old apt repo should not be a problem because the first recipe in my run list
updates it. But chef ignores apt recipe and starts from mysql one.
See log
dan#mywp3:~/chef-repo$ sudo chef-solo -c solo.rb -j web.json
Starting Chef Client, version 11.6.2
Compiling Cookbooks...
[2013-10-27T00:59:28+04:00] WARN: Cloning resource attributes for service[apache2] from prior resource (CHEF-3694)
[2013-10-27T00:59:28+04:00] WARN: Previous service[apache2]: /home/dan/chef-repo/cookbooks/apache2/recipes/default.rb:24:in `from_file'
[2013-10-27T00:59:28+04:00] WARN: Current service[apache2]: /home/dan/chef-repo/cookbooks/apache2/recipes/default.rb:210:in `from_file'
[2013-10-27T00:59:28+04:00] WARN: Cloning resource attributes for directory[/var/cache/local/preseeding] from prior resource (CHEF-3694)
[2013-10-27T00:59:28+04:00] WARN: Previous directory[/var/cache/local/preseeding]: /home/dan/chef-repo/cookbooks/apt/recipes/default.rb:76:in `block in from_file'
[2013-10-27T00:59:28+04:00] WARN: Current directory[/var/cache/local/preseeding]: /home/dan/chef-repo/cookbooks/mysql/recipes/server.rb:44:in `from_file'
[2013-10-27T00:59:28+04:00] WARN: Cloning resource attributes for directory[/var/lib/mysql] from prior resource (CHEF-3694)
[2013-10-27T00:59:28+04:00] WARN: Previous directory[/var/lib/mysql]: /home/dan/chef-repo/cookbooks/mysql/recipes/server.rb:117:in `block in from_file'
[2013-10-27T00:59:28+04:00] WARN: Current directory[/var/lib/mysql]: /home/dan/chef-repo/cookbooks/mysql/recipes/server.rb:117:in `block in from_file'
[2013-10-27T00:59:28+04:00] WARN: Cloning resource attributes for template[/etc/mysql/my.cnf] from prior resource (CHEF-3694)
[2013-10-27T00:59:28+04:00] WARN: Previous template[/etc/mysql/my.cnf]: /home/dan/chef-repo/cookbooks/mysql/recipes/server.rb:134:in `from_file'
[2013-10-27T00:59:28+04:00] WARN: Current template[/etc/mysql/my.cnf]: /home/dan/chef-repo/cookbooks/mysql/recipes/server.rb:194:in `from_file'
Recipe: mysql::client
* package[mysql-client] action install
================================================================================
Error executing action `install` on resource 'package[mysql-client]'
================================================================================
Chef::Exceptions::Exec
----------------------
apt-get -q -y install mysql-client=5.5.32-0ubuntu0.12.04.1 returned 100, expected 0
Cookbook Trace:
---------------
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:44:in `block in from_file'
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:43:in `each'
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:43:in `from_file'
/home/dan/chef-repo/cookbooks/phpap/recipes/default.rb:20:in `from_file'
Resource Declaration:
---------------------
# In /home/dan/chef-repo/cookbooks/mysql/recipes/client.rb
46: package name
47: end
Compiled Resource:
------------------
# Declared in /home/dan/chef-repo/cookbooks/mysql/recipes/client.rb:46:in `block in from_file'
package("mysql-client") do
action :install
retries 0
retry_delay 2
package_name "mysql-client"
version "5.5.32-0ubuntu0.12.04.1"
cookbook_name :mysql
recipe_name "client"
end
================================================================================
Recipe Compile Error in /home/dan/chef-repo/cookbooks/phpap/recipes/default.rb
================================================================================
Chef::Exceptions::Exec
----------------------
package[mysql-client] (mysql::client line 46) had an error: Chef::Exceptions::Exec: apt-get -q -y install mysql-client=5.5.32-0ubuntu0.12.04.1 returned 100, expected 0
Cookbook Trace:
---------------
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:44:in `block in from_file'
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:43:in `each'
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:43:in `from_file'
/home/dan/chef-repo/cookbooks/phpap/recipes/default.rb:20:in `from_file'
Relevant File Content:
----------------------
/home/dan/chef-repo/cookbooks/mysql/recipes/ruby.rb:
37: when 'rhel'
38: resources('yum_key[RPM-GPG-KEY-percona]').run_action(:add)
39: resources('yum_repository[percona]').run_action(:add)
40: end
41: end
42:
43: node['mysql']['client']['packages'].each do |name|
44>> resources("package[#{name}]").run_action(:install)
45: end
46:
47: chef_gem 'mysql'
48:
[2013-10-27T00:59:30+04:00] ERROR: Running exception handlers
[2013-10-27T00:59:30+04:00] ERROR: Exception handlers complete
[2013-10-27T00:59:30+04:00] FATAL: Stacktrace dumped to /home/dan/chef-solo/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2013-10-27T00:59:30+04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
The host runs ubuntu 12.04.
I tried to put my own recipes before phpap in the run list but without any success.
I can workaround this with manual placing apt-get update in bash script right before chef-solo.
Is it mysql cookbook so bad? As far as I know chef ALWAYS follows run-list strait forward.
In general chef will always honor the run list. However sometimes you might want to run a resource before any others (like to configure a package manager, apt/yum/etc). What seems to be happening in the mysql ruby recipe is that the recipe is explicitly running some package installs at compile time (before chef has begun to execute resources). They fail as the apt recipe hasn't been run yet (none have).
There's a good opscode post explaining compile/execute phases here.
The offending code in mysql::ruby is
node['mysql']['client']['packages'].each do |name|
resources("package[#{name}]").run_action(:install)
end
The run_action(:install) is telling chef to run this now (at compile time).
I got phpap recipe without failure on bare ubuntu 12.04 (without any manual pre update) with following fix.
I removed recipes "build-essential" and "openssl" from phpap one.
After that change chef executes recipes as expected.
But weird behavior left unexplained.
vagrant destroy -f && vagrant up // destroy everything and start over => OK

Ruby windows installer: cannot run gem - required files not found

I'm new to ruby gems. I'm trying to get ruby on rails but the gem command does not work on my system. Searched the internet and SO site, but cannot find this specific issue. I realize this must be something basic that's wrong, but I don't know what it is... Here are the details:
Got ruby installer from http://rubyforge.org/frs/?group_id=167, install went fine. Downloaded ruby gems from http://rubygems.org/pages/download, unzipped and in the unzipped directory ran:
ruby setup.rb
Output:
C:/tools/rubygems-1.8.17# ruby setup.rb
RubyGems 1.8.17 installed
== 1.8.17 / 2012-02-17
* 2 minor enhancements:
* Add MacRuby to the list of special cases for platforms (ferrous26)
* Add a default for where to install rubygems itself
* 3 bug fixes:
* Fixed gem loading issue caused by dependencies not resolving.
* Fixed umask error when stdlib is required and unresolved dependencies exist.
* Shebang munging would only take one arg after the cmd
* Define SUCKAGE better, ie only MRI 1.9.2
* Propagate env-shebang to the pristine command if set for install.
------------------------------------------------------------------------------
RubyGems installed the following executables:
C:/tools/ruby/bin/e
C:/tools/ruby/bin/gem
When I try running gem I get the following error:
C:/tools/ruby# gem env
require: C:/tools/ruby/bin/gem 8: not found
require: C:/tools/ruby/bin/gem 9: not found
require: C:/tools/ruby/bin/gem 10: not found
required_version: C:/tools/ruby/bin/gem 12: not found
unless: C:/tools/ruby/bin/gem 14: not found
abort: C:/tools/ruby/bin/gem 15: not found
end: C:/tools/ruby/bin/gem 16: not found
args: C:/tools/ruby/bin/gem 18: not found
begin: C:/tools/ruby/bin/gem 20: not found
Gem::GemRunner.new.run: C:/tools/ruby/bin/gem 21: not found
rescue: C:/tools/ruby/bin/gem 22: not found
exit: C:/tools/ruby/bin/gem 23: unknown operator in arithmetic expression "e.exit_code" near e.
I reinstalled everything and before running "ruby setup.rb" for gems, I defined GEM_HOME directory, pointing to C:/tools/ruby/gems (which I created). That did not help in any way. Any pointers appreciated.
Verify that the gem binary is in your executable path.
I'm on Windows XP. I wanted to follow up with an explanation of / versus \ in my setup and this pointed me to the culprit: I have MKS Toolkit installed on my system and execute everything from bash, instead of windows cmd. Once I switched to windows cmd, gem finally works fine. A simple thing, yet took hours to debug...

Resources