# Sudo gem install mysql problem

**URL:** <https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408>\
**Category:** ruby-talk\
**Created:** [5 May 2010 13:41 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408 "2010-05-05T13:41:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pen\_Ttt](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@Pen\_Ttt](https://rubytalk.org/u/Pen_Ttt)\
**Post date:** [5 May 2010 13:41 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/1 "2010-05-05T13:41:27Z")

</div>

today i have installed ubuntu10.04.  
pt@pt-laptop:~$ ruby -v  
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
pt@pt-laptop:~$ gem -v  
1.3.5  
pt@pt-laptop:~$ sudo gem install mysql  
Building native extensions. This could take a while...  
ERROR: Error installing mysql:  
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb  
extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
from extconf.rb:10

Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
for inspection.  
Results logged to  
/var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out

how to sovle the problem?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Rich\_McGrath](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rich\_McGrath](https://rubytalk.org/u/Rich_McGrath)\
**Post date:** [5 May 2010 13:45 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/2 "2010-05-05T13:45:46Z")

</div>

try sudo gem install mysql -- --with-mysql-dir= \*Put Location Mysql  
directory here.\*  
I.E.  
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql  
sudo gem install mysql --  
--with-mysql-config=/usr/local/mysql/bin/mysql\_config

Rich

> **···**
>
> On Wed, May 5, 2010 at 9:41 AM, Pen Ttt \<myocean135@yahoo.cn\> wrote:
> 
> > today i have installed ubuntu10.04.  
> > pt@pt-laptop:~$ ruby -v  
> > ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
> > pt@pt-laptop:~$ gem -v  
> > 1.3.5  
> > pt@pt-laptop:~$ sudo gem install mysql  
> > Building native extensions. This could take a while...  
> > ERROR: Error installing mysql:  
> > ERROR: Failed to build gem native extension.
> > 
> > /usr/bin/ruby1.8 extconf.rb  
> > extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
> > from extconf.rb:10
> > 
> > Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
> > for inspection.  
> > Results logged to  
> > /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out
> > 
> > how to sovle the problem?  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Luis\_Lavena1](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Luis\_Lavena1](https://rubytalk.org/u/Luis_Lavena1)\
**Post date:** [5 May 2010 16:30 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/3 "2010-05-05T16:30:08Z")

</div>

You need a full Ruby installation, from the path "/var/lib" looks like  
you're running Ubuntu.

Please install ruby-dev package and try again.

Also, you need mysql and libmysql-dev packages to compile.

> **···**
>
> On May 5, 10:41 am, Pen Ttt \<myocean...@yahoo.cn\> wrote:
> 
> > today i have installed ubuntu10.04.  
> > pt@pt-laptop:~$ ruby -v  
> > ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
> > pt@pt-laptop:~$ gem -v  
> > 1.3.5  
> > pt@pt-laptop:~$ sudo gem install mysql  
> > Building native extensions. This could take a while...  
> > ERROR: Error installing mysql:  
> > ERROR: Failed to build gem native extension.
> > 
> > /usr/bin/ruby1.8 extconf.rb  
> > extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
> > from extconf.rb:10
> > 
> > Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
> > for inspection.  
> > Results logged to  
> > /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out
> > 
> > how to sovle the problem?
> 
> --  
> Luis Lavena

---

<div class="post-metadata">

**Author:** ![lyn](https://avatars.discourse-cdn.com/v4/letter/l/67e7ee/32.png) [@lyn](https://rubytalk.org/u/lyn)\
**Post date:** [18 May 2010 06:35 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/4 "2010-05-18T06:35:05Z")

</div>

I was getting the exact same error - I can get sudo gem install mysql  
to load only after running sudo apt-get install ruby-dev but then  
rails app reports wrong wrong gem version and asks me to 2.2.3 back  
from 2.2.5 sudo gem install -v=2.2.3 rails run app and web brick  
starts and displays default page go to generators scaffold works then  
rake db migrate you should get a password error alter user name and  
password for all environments and I am hoping that works

> **···**
>
> On May 5, 11:41 pm, Pen Ttt \<myocean...@yahoo.cn\> wrote:
> 
> > today i have installed ubuntu10.04.  
> > pt@pt-laptop:~$ ruby -v  
> > ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
> > pt@pt-laptop:~$ gem -v  
> > 1.3.5  
> > pt@pt-laptop:~$ sudo gem install mysql  
> > Building native extensions. This could take a while...  
> > ERROR: Error installing mysql:  
> > ERROR: Failed to build gem native extension.
> > 
> > /usr/bin/ruby1.8 extconf.rb  
> > extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
> > from extconf.rb:10
> > 
> > Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
> > for inspection.  
> > Results logged to  
> > /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out
> > 
> > how to sovle the problem?  
> > --  
> > Posted viahttp://www.ruby-forum.com/.

---

<div class="post-metadata">

**Author:** ![Rich\_McGrath](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rich\_McGrath](https://rubytalk.org/u/Rich_McGrath)\
**Post date:** [5 May 2010 16:35 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/5 "2010-05-05T16:35:11Z")

</div>

This Doc might help.

[https://help.ubuntu.com/community/RubyOnRails](https://help.ubuntu.com/community/RubyOnRails)

\<[https://help.ubuntu.com/community/RubyOnRails&gt;Rich](https://help.ubuntu.com/community/RubyOnRails&gt;Rich)

> **···**
>
> On Wed, May 5, 2010 at 12:30 PM, Luis Lavena \<luislavena@gmail.com\> wrote:
> 
> > On May 5, 10:41 am, Pen Ttt \<myocean...@yahoo.cn\> wrote:  
> > \> today i have installed ubuntu10.04.  
> > \> pt@pt-laptop:~$ ruby -v  
> > \> ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
> > \> pt@pt-laptop:~$ gem -v  
> > \> 1.3.5  
> > \> pt@pt-laptop:~$ sudo gem install mysql  
> > \> Building native extensions. This could take a while...  
> > \> ERROR: Error installing mysql:  
> > \> ERROR: Failed to build gem native extension.  
> > \>  
> > \> /usr/bin/ruby1.8 extconf.rb  
> > \> extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
> > \> from extconf.rb:10  
> > \>  
> > \> Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
> > \> for inspection.  
> > \> Results logged to  
> > \> /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out  
> > \>  
> > \> how to sovle the problem?
> > 
> > You need a full Ruby installation, from the path "/var/lib" looks like  
> > you're running Ubuntu.
> > 
> > Please install ruby-dev package and try again.
> > 
> > Also, you need mysql and libmysql-dev packages to compile.
> > 
> > --  
> > Luis Lavena
> 
> --  
> Rich McGrath  
> Tech Lead for Bitmob.com  
> rich.mcgrath@bitmob.com  
> [www.Bitmob.com](http://www.Bitmob.com)  
> [www.twitter.com/Bitmobrich](http://www.twitter.com/Bitmobrich)

---

<div class="post-metadata">

**Author:** ![lyn](https://avatars.discourse-cdn.com/v4/letter/l/67e7ee/32.png) [@lyn](https://rubytalk.org/u/lyn)\
**Post date:** [18 May 2010 05:55 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/6 "2010-05-18T05:55:07Z")

</div>

I've been scratching my head all afternoon as you suggested sudo apt-  
get install ruby-dev and then running sudo gem install mysql worked  
sort of I got a whole lot of definition errors but I'm closer than I  
was

> **···**
>
> On May 6, 2:29 am, Luis Lavena \<luislav...@gmail.com\> wrote:
> 
> > On May 5, 10:41 am, Pen Ttt \<myocean...@yahoo.cn\> wrote:
> > 
> > \> today i have installed ubuntu10.04.  
> > \> pt@pt-laptop:~$ ruby -v  
> > \> ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
> > \> pt@pt-laptop:~$ gem -v  
> > \> 1.3.5  
> > \> pt@pt-laptop:~$ sudo gem install mysql  
> > \> Building native extensions. This could take a while...  
> > \> ERROR: Error installing mysql:  
> > \> ERROR: Failed to build gem native extension.
> > 
> > \> /usr/bin/ruby1.8 extconf.rb  
> > \> extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
> > \> from extconf.rb:10
> > 
> > \> Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
> > \> for inspection.  
> > \> Results logged to  
> > \> /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out
> > 
> > \> how to sovle the problem?
> > 
> > You need a full Ruby installation, from the path "/var/lib" looks like  
> > you're running Ubuntu.
> > 
> > Please install ruby-dev package and try again.
> > 
> > Also, you need mysql and libmysql-dev packages to compile.
> > 
> > --  
> > Luis Lavena

---

<div class="post-metadata">

**Author:** ![James10](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@James10](https://rubytalk.org/u/James10)\
**Post date:** [18 May 2010 17:52 UTC](https://rubytalk.org/t/sudo-gem-install-mysql-problem/58408/7 "2010-05-18T17:52:09Z")

</div>

As much as this might not be what you want to hear, I've always eventually given up on trying to use apt on ubuntu for ruby related stuff. Something funky's up with their debs.

Instead, I install ruby from source and then use the various scripts inside the source tarball to install almost everything else I need. It's much simpler in the long run, though you'll have to do upgrades by hand.

> **···**
>
> On May 18, 2010, at 12:35 AM 5/18/10, lyn wrote:
> 
> > On May 5, 11:41 pm, Pen Ttt \<myocean...@yahoo.cn\> wrote:
> > 
> > > today i have installed ubuntu10.04.  
> > > pt@pt-laptop:~$ ruby -v  
> > > ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]  
> > > pt@pt-laptop:~$ gem -v  
> > > 1.3.5  
> > > pt@pt-laptop:~$ sudo gem install mysql  
> > > Building native extensions. This could take a while...  
> > > ERROR: Error installing mysql:  
> > > ERROR: Failed to build gem native extension.
> > > 
> > > /usr/bin/ruby1.8 extconf.rb  
> > > extconf.rb:10:in `require': no such file to load -- mkmf (LoadError)  
> > > from extconf.rb:10
> > > 
> > > Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1  
> > > for inspection.  
> > > Results logged to  
> > > /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out
> > > 
> > > how to sovle the problem?  
> > > --  
> > > Posted viahttp://www.ruby-forum.com/.
> > 
> > I was getting the exact same error - I can get sudo gem install mysql  
> > to load only after running sudo apt-get install ruby-dev but then  
> > rails app reports wrong wrong gem version and asks me to 2.2.3 back  
> > from 2.2.5 sudo gem install -v=2.2.3 rails run app and web brick  
> > starts and displays default page go to generators scaffold works then  
> > rake db migrate you should get a password error alter user name and  
> > password for all environments and I am hoping that works
