Ruby On Rails 3 and Webrick

Hi,

Thanks for taking a look at this.

I started a beginner's tutorial on RoR through lynda.com. I followed
the instructions to the letter. Everything was working so far until I
got to accessing Webrick. When I typed in "rails server" to begin
work, I got this error message below.

/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle:
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/
mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
(LoadError)
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/
mysql2.bundle
  Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/
lib/mysql2/mysql2.bundle

  from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/
runtime.rb:68:in `require'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/
runtime.rb:68:in `require'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/
runtime.rb:66:in `each'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/
runtime.rb:66:in `require'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/
runtime.rb:55:in `each'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/
runtime.rb:55:in `require'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in
`require'
  from /Users/macuser/Sites/simplecms/config/application.rb:7
  from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:
28:in `require'
  from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:
28
  from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:
27:in `tap'
  from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:
27
  from script/rails:6:in `require'
  from script/rails:6

I'm using a

- iMac
- Ruby 1.87
- Gem 1.7.2

I have been exposed to very little Rails and looking to learn how to
fix this. Your help would be greatly appreciated.

Thanks in advance for your attention and help if possible.

/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle:
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/
mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
(LoadError)
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/
mysql2.bundle
  Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/
lib/mysql2/mysql2.bundle

Have you installed the mysql server and mysql rubygem?

Thanks for your help.

Yes. I doubled checked through the command line and it lists that it's
there.

I'm lost.

please post the result of typing

gem list

** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.6, 2.3.5, 2.2.2, 1.3.6)
actionpack (3.0.6, 2.3.5, 2.2.2, 1.13.6)
actionwebservice (1.2.6)
activemodel (3.0.6)
activerecord (3.0.6, 2.3.5, 2.2.2, 1.15.6)
activeresource (3.0.6, 2.3.5, 2.2.2)
activesupport (3.0.6, 2.3.5, 2.2.2, 1.4.4)
acts_as_ferret (0.4.3)
arel (2.0.9)
builder (2.1.2)
bundler (1.0.12)
capistrano (2.5.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
dnssd (0.6.0)
erubis (2.6.6)
fastthread (1.0.1)
fcgi (0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
highline (1.5.0)
hpricot (0.6.164)
i18n (0.5.0)
libxml-ruby (1.1.2)
mail (2.2.15)
mime-types (1.16)
mongrel (1.1.5)
mysql2 (0.2.7)
needle (1.3.0)
net-scp (1.0.1)
net-sftp (2.0.1, 1.1.1)
net-ssh (2.0.4, 1.1.4)
net-ssh-gateway (1.0.0)
polyglot (0.3.1)
rack (1.2.2, 1.0.1)
rack-mount (0.6.14)
When I ran gem list, this is what I got.

rack-test (0.5.7)
rails (3.0.6, 2.3.5, 2.2.2, 1.2.6)
railties (3.0.6)
rake (0.8.7, 0.8.3)
RedCloth (4.1.1)
ruby-openid (2.1.2)
ruby-yadis (0.3.4)
rubygems-update (1.7.2)
rubynode (0.1.5)
sqlite3-ruby (1.2.4)
termios (0.9.4)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.26)
xmpp4r (0.4)

if you are under *nix environtment try installing this packages, use the brew for mac

sudo apt-get install libmysql-ruby libmysqlclient-dev

Here's where this noob gets nailed.

I tried installing the suggested sudo and got command not found. Then
I looked for the brew for mac and I'm just not getting it.

Radhames, thanks for your help and patience. If others have
suggestions of what I'm missing here, please add your voice. All help
is appreciated.

By noob, I mean me. I'm the noob. Sorry for any confusion.

By noob, I mean me. I’m the noob. Sorry for any confusion.

Brew for Mac
https://github.com/mxcl/homebrew

The command not found is referring to apt-get which is not on Mac (hence his pointing you to Brew).

B.

oh i see, *nix system often have package manager, that is programs that connect to a repository, where there is the source code for you OS, then the package manager download the source code and compiles it for your OS version. The most popular Package manager are : Aptitude, apt-get, YUM, Macports, fink, homebrew, among others , and i have never used the windows ones from which i only know of Cygwin. As a simple example Apple’s app store is kind of like a package manager. Ubuntu comes with with apt-get, in mac i use homebrew. In mac there is not apt-get so thats why you get the error. You have to pass the proper package manager according to your OS, mac does not comes with any so you have to install homebrew.

I have the same issues above, I've installed Homebrew. Now I cant get it
to do the sudo app-get part. I understand that Mac does not have this
functionality. What options do I have instead?

Thanks for any help.

Another noob

David F. wrote in post #994133:

I have the same issues above, I've installed Homebrew. Now I cant get it
to do the sudo app-get part. I understand that Mac does not have this
functionality. What options do I have instead?

Explain this.

1. Did you really mean "apt-get" instead of "app-get." I have no idea
what app-get is, never heard of it if it does exist.

2. What do you mean by "can't get it to do the sudo app-get part." What
happens? Do you get errors? What are they?

3. What operating system are you using? The apt-get command only works
for certain Linux distributions. Other platforms use different package
managers with different commands. RedHat for example uses rpm (RedHat
Package Manager) by default, instead of apt-get (Debian/Ubuntu).

4. If you happen to be on a Mac then there are several choices for these
types of package managers. The Mac doesn't ship with any of them because
the Mac has a native package installer system using the built-in
Installer services provided by Mac OS X. These packages are called dpkg
(Darwin Package, where Darwin is the low level UNIX OS of Mac OS X).
Other package managers for OS X have been created by the open source
community, which include Macports, Fink, Homebrew, etc. IMHO Homebrew is
the only one worth using. I have never liked how intrusive the other
solutions can be on my system. Homebrew is light weight and
non-intrusive, not to mention full of awesomeness. But, that is a matter
of opinion.

It's Strange that I cam after all this time with the same error coming
out when I try to run the Webrick server..

\KAMAL$ rails server
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle:
dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle,
9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found -
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9
  from
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
`require'
  from
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in
`require'
  from
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
`each'
  from
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in
`require'
  from
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
`each'
  from
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in
`require'
  from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler.rb:132:in
`require'
  from
/Users/ahmedkamal/Documents/railswork/simple_cms/config/application.rb:7
  from
/Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:53:in
`require'
  from
/Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:53
  from
/Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:50:in
`tap'
  from
/Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:50
  from script/rails:6:in `require'
  from script/rails:6

Have you tried all the things mentioned previously in the thread?

Googling for
rails Library not loaded: libmysqlclient.18.dylib
shows numerous hits that might be the same problem. Have a look at
those and see if it helps.

Colin