# Mysql-0.23 cookbook fails on Lucid

**URL:** <https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466>\
**Category:** Chef Infra (archive)\
**Created:** [July 15, 2010, 9:34am UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466 "2010-07-15T09:34:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dmitry\_Vyal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dmitry_vyal/32/742_2.png) [@Dmitry\_Vyal](https://discourse.chef.io/u/Dmitry_Vyal)\
**Post date:** [July 15, 2010, 9:34am UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466/1 "2010-07-15T09:34:29Z")

</div>

Hello, I’m struggling trying to debug my cookbooks

I have a node with a runlist:

“run\_list”: [  
“recipe[apt::default]”,  
“recipe[nginx::passenger]”,  
“recipe[mysql::server]”,  
“recipe[php-fpm::default]”,  
“recipe[monit::default]”,  
“recipe[bodhysite::default]”,  
“recipe[mail-system::vdomains]”  
],

nginx::passenger starts with include\_recipe “build-essential”.

The chef run fails saying this: [http://pastebin.com/H7nFSqdy](http://pastebin.com/H7nFSqdy)  
Looks like mysql::client fails while building mysql gem because mkfs  
from ruby-dev is missing. So I added

r1 = package "ruby1.8-dev"  
r1.run\_action(:install)

to mysql client, but now it still fails with the messages:

[Thu, 15 Jul 2010 09:01:45 +0000] INFO: Installing gem\_package[mysql]  
version 2.8.1  
Building native extensions. This could take a while…  
[Thu, 15 Jul 2010 09:01:46 +0000] ERROR: Running exception handlers  
[Thu, 15 Jul 2010 09:01:46 +0000] ERROR: Exception handlers complete  
[Thu, 15 Jul 2010 09:01:46 +0000] ERROR: Re-raising exception:  
Gem::Installer::ExtensionBuildError - ERROR: Failed to build gem native  
extension.

/usr/bin/ruby1.8 extconf.rb  
checking for mysql\_ssl\_set()… no  
checking for rb\_str\_set\_len()… no  
checking for rb\_thread\_start\_timer()… no  
checking for mysql.h… no  
checking for mysql/mysql.h… no  
\*\*\* extconf.rb failed \*\*\*

Necessary headers are there, the root of problem is what gcc isn’t  
installed. But build-essential included as part of nginx::passenger  
earlier than mysql. I even tried to add it into run\_list as a separate  
recipe right after apt::default, it didn’t helped.

A nice person on #chef told me there’s some magic in mysql cookbook, it  
makes use of run\_action method.

Can someone please clarify it a bit and point me in right direction?

Oh forgot to mention, all this was about mysql-0.23 and  
build-essential-0.7 cookbooks.

Thanks,  
Dmitry

---

<div class="post-metadata">

**Author:** ![Sahil\_R\_Cooner](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/sahil_r_cooner/32/773_2.png) [@Sahil\_R\_Cooner](https://discourse.chef.io/u/Sahil_R_Cooner)\
**Post date:** [July 15, 2010, 10:21am UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466/2 "2010-07-15T10:21:13Z")

</div>

You do need build-essential, that will install gcc for you, I do not see it  
in your run\_list and just checked the mysql cookbooks for server/client that  
is also pulled in by mysql::server and I didn't see an include\_recipe.

--sahil

On Thu, Jul 15, 2010 at 2:34 AM, Dmitry V'yal [akamaus@gmail.com](mailto:akamaus@gmail.com) wrote:

> Hello, I'm struggling trying to debug my cookbooks
> 
> I have a node with a runlist:
> 
> "run\_list": [  
> "recipe[apt::default]",  
> "recipe[nginx::passenger]",  
> "recipe[mysql::server]",  
> "recipe[php-fpm::default]",  
> "recipe[monit::default]",  
> "recipe[bodhysite::default]",  
> "recipe[mail-system::vdomains]"  
> ],
> 
> nginx::passenger starts with include\_recipe "build-essential".
> 
> The chef run fails saying this: [http://pastebin.com/H7nFSqdy](http://pastebin.com/H7nFSqdy)  
> Looks like mysql::client fails while building mysql gem because mkfs from  
> ruby-dev is missing. So I added
> 
> r1 = package "ruby1.8-dev"  
> r1.run\_action(:install)
> 
> to mysql client, but now it still fails with the messages:
> 
> [Thu, 15 Jul 2010 09:01:45 +0000] INFO: Installing gem\_package[mysql]  
> version 2.8.1  
> Building native extensions. This could take a while...  
> [Thu, 15 Jul 2010 09:01:46 +0000] ERROR: Running exception handlers  
> [Thu, 15 Jul 2010 09:01:46 +0000] ERROR: Exception handlers complete  
> [Thu, 15 Jul 2010 09:01:46 +0000] ERROR: Re-raising exception:  
> Gem::Installer::ExtensionBuildError - ERROR: Failed to build gem native  
> extension.
> 
> /usr/bin/ruby1.8 extconf.rb  
> checking for mysql\_ssl\_set()... no  
> checking for rb\_str\_set\_len()... no  
> checking for rb\_thread\_start\_timer()... no  
> checking for mysql.h... no  
> checking for mysql/mysql.h... no  
> \*\*\* extconf.rb failed \*\*\*
> 
> Necessary headers are there, the root of problem is what gcc isn't  
> installed. But build-essential included as part of nginx::passenger earlier  
> than mysql. I even tried to add it into run\_list as a separate recipe right  
> after apt::default, it didn't helped.
> 
> A nice person on #Chef Infra (archive) told me there's some magic in mysql cookbook, it  
> makes use of run\_action method.
> 
> Can someone please clarify it a bit and point me in right direction?
> 
> Oh forgot to mention, all this was about mysql-0.23 and build-essential-0.7  
> cookbooks.
> 
> Thanks,  
> Dmitry

---

<div class="post-metadata">

**Author:** ![Joshua\_Timberman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_timberman/32/424_2.png) [@Joshua\_Timberman](https://discourse.chef.io/u/Joshua_Timberman)\
**Post date:** [July 15, 2010, 3:58pm UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466/3 "2010-07-15T15:58:59Z")

</div>

Hello!

On Jul 15, 2010, at 3:34 AM, Dmitry V'yal wrote:

> I have a node with a runlist:
> 
> "run\_list": [  
> "recipe[apt::default]",  
> "recipe[nginx::passenger]",  
> "recipe[mysql::server]",  
> "recipe[php-fpm::default]",  
> "recipe[monit::default]",  
> "recipe[bodhysite::default]",  
> "recipe[mail-system::vdomains]"  
> ],

Just to note, you don't need to specify default, it is implied if a recipe isn't specified for the cookbook.

E.g., "recipe[apt]" is the same as "recipe[apt::default]".

That said...

> nginx::passenger starts with include\_recipe "build-essential".
> 
> The chef run fails saying this: [http://pastebin.com/H7nFSqdy](http://pastebin.com/H7nFSqdy)  
> Looks like mysql::client fails while building mysql gem because mkfs from ruby-dev is missing. So I added
> 
> r1 = package "ruby1.8-dev"  
> r1.run\_action(:install)  
> ...  
> Necessary headers are there, the root of problem is what gcc isn't installed. But build-essential included as part of nginx::passenger earlier than mysql. I even tried to add it into run\_list as a separate recipe right after apt::default, it didn't helped.

Recall that the Chef client run processes recipes in two phases[0] - the compile phase and the execution phase. During the compile phase your Ruby code is processed:

r1 = package "ruby1.8-dev"  
r1.run\_action(:install)

So this gets evaluated and the resource is created and the package installed. The mysql cookbook uses this 'trick' to ensure the mysql gem can be installed and later used in the mysql cookbook's library in the same Chef client run.

The build-essential and ruby cookbooks do not do this (the Opscode Ruby cookbook installs the ruby dev package, so you can use that). They create the package resources during the compile phase as normal but Chef doesn't actually run the package installation until the execution phase. You should modify your local copy of the build-essential recipe to have the following block for the package installation:

%w{build-essential binutils-doc}.each do |pkg|  
p = package pkg do  
action :nothing  
end  
p.run\_action(:install)  
end

And the ruby recipe to have the following:

extra\_packages.each do |pkg|  
p = package pkg do  
action :nothing  
end  
p.run\_action(:install)  
end

Upload the cookbooks to the Chef Server and rerun Chef on the node in question.

Since we (Opscode) first distribute Chef as RubyGems, the recipes are a bit narrow-minded in assuming that by the time Chef runs for the first time the C compiler and Ruby dev packages are available, because that is required to build Gems (like json) with native extensions to get Chef installed in the first place.

It sounds like you have installed Chef from Debian/Ubuntu packages, which is good, but it does mean this adjustment in your local recipe is necessary.

That said, we'll look at how to make these cookbooks better, and the mysql cookbook's readme will be updated to reflect this "requirement".

[0]: Anatomy of a chef run: [http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run](http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run)

--  
Opscode, Inc  
Joshua Timberman, Senior Solutions Engineer  
C: 720.334.RUBY E: [joshua@opscode.com](mailto:joshua@opscode.com)

---

<div class="post-metadata">

**Author:** ![Dmitry\_Vyal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dmitry_vyal/32/742_2.png) [@Dmitry\_Vyal](https://discourse.chef.io/u/Dmitry_Vyal)\
**Post date:** [July 15, 2010, 4:13pm UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466/4 "2010-07-15T16:13:39Z")

</div>

On 15.07.2010 14:21, [sahil.cooner@gmail.com](mailto:sahil.cooner@gmail.com) wrote:

> You do need build-essential, that will install gcc for you, I do not see  
> it in your run\_list and just checked the mysql cookbooks for  
> server/client that is also pulled in by mysql::server and I didn't see  
> an include\_recipe.
> 
> --sahil

well, probably I wasn't clear enough. It's included as part of  
nginx::passenger recipe.

Still for testing I've included it explicitly

% knife role show webserver  
{  
"name": "webserver",  
"default\_attributes": {

},  
"json\_class": "Chef::Role",  
"run\_list": [  
"recipe[apt::default]",  
"recipe[build-essential::default]",  
"recipe[nginx::passenger]",  
"recipe[mysql::server]",  
"recipe[php-fpm::default]",  
"recipe[monit::default]",  
"recipe[bodhysite::default]",  
"recipe[mail-system::vdomains]"  
],  
"description": "nginx with passenger and mysql",  
"chef\_type": "role",  
"override\_attributes": {  
"mysql": {  
"bind\_address": [  
"localhost"  
]  
}  
}  
}

This gives the following(slightly truncated at top):

[Thu, 15 Jul 2010 16:00:11 +0000] DEBUG: Sending HTTP Request via GET to  
[chef-server.vpn.bodhy.ru:4000/roles/webserver](http://chef-server.vpn.bodhy.ru:4000/roles/webserver)  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Applying attributes from json file  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Loading Recipe apt::default via  
include\_recipe  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Found recipe default in  
cookbook apt  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Executing apt-get update  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: ---- Begin output of apt-get  
update ----  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: STDOUT: Hit  
[http://security.ubuntu.com](http://security.ubuntu.com) lucid-updates Release.gpg  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security Release.gpg  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid Release.gpg  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid-updates Release.gpg  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-updates Release  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid Release  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid-updates Release  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security Release  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-updates/main Packages  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-updates/restricted Packages  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-updates/main Sources  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-updates/restricted Sources  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid/main Packages  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid/restricted Packages  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid/main Sources  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid/restricted Sources  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid/universe Packages  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid/universe Sources  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid-updates/universe Packages  
Hit [http://us.archive.ubuntu.com](http://us.archive.ubuntu.com) lucid-updates/universe Sources  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security/main Packages  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security/restricted Packages  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security/main Sources  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security/restricted Sources  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security/universe Packages  
Hit [http://security.ubuntu.com](http://security.ubuntu.com) lucid-security/universe Sources  
Hit [http://apt.opscode.com](http://apt.opscode.com) lucid Release.gpg  
Hit [http://apt.opscode.com](http://apt.opscode.com) lucid Release  
Ign [http://apt.opscode.com](http://apt.opscode.com) lucid/main Packages  
Ign [http://apt.opscode.com](http://apt.opscode.com) lucid/main Packages  
Hit [http://apt.opscode.com](http://apt.opscode.com) lucid/main Packages  
Reading package lists...  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: STDERR:  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: ---- End output of apt-get  
update ----  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Ran apt-get update returned 0  
[Thu, 15 Jul 2010 16:00:12 +0000] INFO: Ran execute[apt-get update]  
successfully  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Loading Recipe  
build-essential::default via include\_recipe  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Found recipe default in  
cookbook build-essential  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Loading Recipe nginx::passenger  
via include\_recipe  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Found recipe passenger in  
cookbook nginx  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Loading Recipe build-essential  
via include\_recipe  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Found recipe default in  
cookbook build-essential  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Setting  
package[build-essential] to the state of the prior package[build-essential]  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Setting package[binutils-doc]  
to the state of the prior package[binutils-doc]  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Setting package[autoconf] to  
the state of the prior package[autoconf]  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Setting package[flex] to the  
state of the prior package[flex]  
[Thu, 15 Jul 2010 16:00:12 +0000] DEBUG: Setting package[bison] to the  
state of the prior package[bison]  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Loading Recipe mysql::server  
via include\_recipe  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Found recipe server in cookbook  
mysql  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Loading Recipe mysql::client  
via include\_recipe  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Found recipe client in cookbook  
mysql  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Checking apt-cache policy for  
libmysqlclient-dev  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Current version is  
5.1.41-3ubuntu12.3  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Current version is  
5.1.41-3ubuntu12.3  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Checking apt-cache policy for  
mysql-client  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Current version is  
5.1.41-3ubuntu12.3  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Current version is  
5.1.41-3ubuntu12.3  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Checking apt-cache policy for  
ruby1.8-dev  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Current version is 1.8.7.249-2  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: Current version is 1.8.7.249-2  
[Thu, 15 Jul 2010 16:00:13 +0000] DEBUG: No installed version found for  
mysql (\>= 0, runtime)  
[Thu, 15 Jul 2010 16:00:16 +0000] DEBUG: Found gem mysql version 2.8.1  
for platform ruby from [http://gems.rubyforge.org/](http://gems.rubyforge.org/)  
[Thu, 15 Jul 2010 16:00:16 +0000] INFO: Installing gem\_package[mysql]  
version 2.8.1  
Building native extensions. This could take a while...  
[Thu, 15 Jul 2010 16:00:17 +0000] ERROR: Running exception handlers  
[Thu, 15 Jul 2010 16:00:17 +0000] ERROR: Exception handlers complete  
[Thu, 15 Jul 2010 16:00:17 +0000] ERROR: Re-raising exception:  
Gem::Installer::ExtensionBuildError - ERROR: Failed to build gem native  
extension.

/usr/bin/ruby1.8 extconf.rb  
checking for mysql\_ssl\_set()... no  
checking for rb\_str\_set\_len()... no  
checking for rb\_thread\_start\_timer()... no  
checking for mysql.h... no  
checking for mysql/mysql.h... no  
\*\*\* extconf.rb failed \*\*\*

Tests fail because gcc is not installed. Looks like the mysql cookbook  
gets executed just after apt.

Best wishes,  
Dmitry

---

<div class="post-metadata">

**Author:** ![Jon\_Wood](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jon_wood/32/826_2.png) [@Jon\_Wood](https://discourse.chef.io/u/Jon_Wood)\
**Post date:** [July 15, 2010, 4:56pm UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466/5 "2010-07-15T16:56:54Z")

</div>

> ... snip ...  
> Since we (Opscode) first distribute Chef as RubyGems, the recipes are a bit narrow-minded in assuming that by the time Chef runs for the first time the C compiler and Ruby dev packages are available, because that is required to build Gems (like json) with native extensions to get Chef installed in the first place.
> 
> It sounds like you have installed Chef from Debian/Ubuntu packages, which is good, but it does mean this adjustment in your local recipe is necessary.
> 
> That said, we'll look at how to make these cookbooks better, and the mysql cookbook's readme will be updated to reflect this "requirement".

Every time I do the initial setup of Chef for a new environment I get  
bitten by this, and I doubt I'm the only one. Is there any chance of  
adding these assumed dependencies to the recommended packages for  
Chef? That way everything works as expected, and people who are  
disgusted by the thought of having a compiler on their server can  
choose to remove it.

---

<div class="post-metadata">

**Author:** ![Dmitry\_Vyal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dmitry_vyal/32/742_2.png) [@Dmitry\_Vyal](https://discourse.chef.io/u/Dmitry_Vyal)\
**Post date:** [July 15, 2010, 6:57pm UTC](https://discourse.chef.io/t/mysql-0-23-cookbook-fails-on-lucid/1466/6 "2010-07-15T18:57:46Z")

</div>

On 15.07.2010 19:58, Joshua Timberman wrote:

> Recall that the Chef client run processes recipes in two phases[0] - the compile phase and the execution phase. During the compile phase your Ruby code is processed:
> 
> r1 = package "ruby1.8-dev"  
> r1.run\_action(:install)
> 
> So this gets evaluated and the resource is created and the package installed. The mysql cookbook uses this 'trick' to ensure the mysql gem can be installed and later used in the mysql cookbook's library in the same Chef client run.
> 
> The build-essential and ruby cookbooks do not do this (the Opscode Ruby cookbook installs the ruby dev package, so you can use that). They create the package resources during the compile phase as normal but Chef doesn't actually run the package installation until the execution phase. You should modify your local copy of the build-essential recipe to have the following block for the package installation:

Thanks a lot, seems I got it. Are there other cookbooks exploiting the  
similar idea?

Dmitry
