Link to home
Start Free TrialLog in
Avatar of max7
max7

asked on

Ruby on Rails installation fail on OS X Lion

Greetings,

I've installed Ruby and Rails on OS X Lion and I've got a few problems that make me wonder if I shouldn't just start over again (trouble is, not sure how I would *start over*).

I'm running ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]

Here is a list of gems installed:

*** LOCAL GEMS ***

aasm (3.0.2, 2.2.0)
abstract (1.0.0)
actionmailer (3.2.1, 2.3.14)
actionpack (3.2.1, 2.3.14)
activemodel (3.2.1)
activerecord (3.2.1, 2.3.14)
activeresource (3.2.1, 2.3.14)
activesupport (3.2.1, 2.3.14)
addressable (2.2.6)
after_commit (1.0.10)
airbrake (3.0.9, 3.0)
akami (1.0.0)
archive-tar-minitar (0.5.2)
arel (3.0.0)
Ascii85 (1.0.1)
authlogic (3.1.0, 2.1.1)
awesome_nested_set (2.1.2, 1.4.4)
aws-s3 (0.6.2)
bluecloth (2.2.0, 2.1.0)
braintree (2.13.4, 2.13.1)
bson (1.5.2, 1.5.1)
bson_ext (1.5.2, 1.5.1)
builder (3.0.0)
bundler (1.0.22)
childprocess (0.3.1)
columnize (0.3.6, 0.3.5)
crack (0.3.1, 0.1.8)
cucumber (1.1.4, 1.1.3)
daemons (1.1.8, 1.1.4)
diff-lcs (1.1.3)
email_spec (1.2.1, 0.6.5)
erubis (2.7.0, 2.6.6)
ezcrypto (0.7.2)
factory_girl (2.5.2, 2.3.2)
faraday (0.7.6, 0.7.5)
ffi (1.0.11, 0.6.3)
forgery (0.5.0)
gdata (1.1.2)
geokit (1.6.5, 1.6.0)
gherkin (2.7.7, 2.6.8)
glennfu-faster_csv (1.5.5.1)
gyoku (0.4.4)
haddock (0.2.2)
haml (3.1.4, 3.1.2)
hike (1.2.1)
hoe (2.13.1, 2.12.4)
hpricot (0.8.6, 0.8.4)
httparty (0.8.1, 0.7.8)
httpi (0.9.5)
i18n (0.6.0, 0.4.2)
icalendar (1.1.6)
journey (1.0.1)
json (1.6.5, 1.5.4, 1.4.6)
kgio (2.7.2, 2.0.0)
koala (1.3.0, 1.2.1)
linecache (0.46, 0.43)
log4r (1.1.10)
macaddr (1.5.0)
mail (2.4.1)
mario (0.1.3, 0.0.6)
metaclass (0.0.1)
mime-types (1.17.2)
mocha (0.10.4, 0.10.0)
mongo (1.5.2, 1.3.1)
multi_json (1.0.4)
multi_xml (0.4.1)
multipart-post (1.1.4)
mutter (0.5.3)
mysql (2.8.1)
mysql2 (0.3.11, 0.2.17, 0.2.7)
net-scp (1.0.4)
net-sftp (2.0.5)
net-ssh (2.3.0, 2.2.2, 2.0.24)
newrelic_rpm (3.3.1, 3.3.0)
nokogiri (1.5.0, 1.4.7)
nori (1.0.2)
pdf-reader (1.0.0, 0.10.1)
polyglot (0.3.3)
rack (1.4.1, 1.1.2)
rack-cache (1.1, 1.0.2)
rack-protection (1.2.0)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.1, 2.3.14)
railties (3.2.1)
raindrops (0.8.0)
rake (0.9.2.2, 0.8.7)
rbx-require-relative (0.0.5)
rdoc (3.12, 3.9.2)
redis (2.2.2)
redis-namespace (1.1.0, 1.0.3)
resque (1.19.0)
resque-lock (1.0.0)
ri_cal (0.8.8)
riddle (1.5.1, 1.4.0)
right_aws (3.0.0, 2.1.0)
right_http_connection (1.3.0)
rmagick (2.13.1, 2.12.2)
rspec (2.8.0, 1.3.1)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
rspec-mocks (2.8.0)
rspec-rails (2.8.1, 1.3.3)
ruby-debug (0.10.4)
ruby-debug-base (0.10.4)
ruby-rc4 (0.1.5)
rubygems-update (1.8.16, 1.8.15)
sanitize (2.0.3, 1.2.1)
savon (0.9.7, 0.7.9)
Selenium (1.1.14)
sendgrid_toolkit (1.1.0, 1.0.4)
sinatra (1.3.2, 1.2.6)
sitemap_generator (3.0.0, 2.1.0)
spork (0.9.0, 0.8.5)
sprockets (2.1.2)
SystemTimer (1.2.3)
systemu (2.4.2, 2.4.1)
term-ansicolor (1.0.7, 1.0.6)
test-unit (2.4.7, 1.2.3)
thinking-sphinx (2.0.11, 1.4.6)
thor (0.14.6)
tilt (1.3.3)
timecop (0.3.5)
toadhopper (2.0)
treetop (1.4.10)
ttfunk (1.0.3)
tzinfo (0.3.31)
unicorn (4.2.0, 3.0.1)
uuid (2.3.5, 2.3.3)
vagrant (0.9.7, 0.6.9)
vagrant-rake (0.1.0)
vegas (0.1.11, 0.1.8)
virtualbox (0.9.2, 0.7.9)
vpim (0.695)
wasabi (2.0.0)
webrat (0.7.3)
will_paginate (3.0.3, 2.3.16)
xml-simple (1.1.1)

Open in new window


Finally, here are the issues that occur when I run ruby script/console from a terminal:

* message appears:

"Sphinx cannot be found on your system. You may need to configure the following settings in your config/sphinx.yml file: ..."

one resource I found suggested that I needed to install Sphinx but even after doing an install of it, I still get this message

*I receive multiple instances of this message:

"NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. Gem.source_index called from /Library/Ruby/Gems/1.8/gems/vagrant-0.6.9/lib/vagrant/plugin.rb:33"

one resource suggested I do gem update bundler or gem pristine --all --no-extensions but neither one worked and I still get these messages

*The final and perhaps worst error I receive:

/Library/Ruby/Gems/1.8/gems/mysql2-0.2.17/lib/mysql2/client.rb:44:in `connect':Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

One thing I noticed in most Ruby install recipes for OS X Lion (like this one: http://bit.ly/zs0VoP), when it comes to MySQL, they assume you need to install it as explained here:


5. Install Mysql

# brew install mysql

one-line command:

# mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Thing is, I skipped this part of the install because I had already installed MySQL server before for use with another application.  I wonder if this is where my problems begin but I can't be sure.

So I would love to have some guidance on how to clean this up ... or if it makes more sense to start from scratch that's fine too but I'm not sure how to got about that since I have so many things installed already.

Max
Avatar of ahoffmann
ahoffmann
Flag of Germany image

> connect':Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

hmm, this message clearly tells you what your ruby script expects: connecting to a running mysql database using the socket '/tmp/mysql.sock'
hence either your mysql is not running, or you configured it to be connected with another socket (see /etc/my.cnf or /etc/mysql/my.cnf or /opt/local/etc/my.cnf or ...), or your ruby installation has a different configuration
my assumtion: mysql is not running
Avatar of max7
max7

ASKER

Thanks for the response, ahoffmann!  I greatly appreciate it.

First thing, I cleaned up all the deprecated messages, they are gone so I have a little good news.

Sphinx message still appears though

As for the mysql error:

>>>this message clearly tells you what your ruby script expects: connecting to a running mysql database using the socket '/tmp/mysql.sock'

True, but mysql.sock does not live in /tmp on this Mac.  In fact, I looked in the most likely places for mysql.sock and cannot find it at all.

What I do find is mysqld.sock (note the d ) and that's located here:  /var/run/mysqld/mysqld.sock

Also, this is the socket assignment in /etc/my.cnf which I believe is the .cnf file for the operating instance of MySQL server for this computer.  One solution I found suggested creating a my.cnf and putting it in /usr/local/etc/my.cnf ... so I did this but it did not help either.

Based on this, I put in my database.yml the same socket assignment (/var/run/mysqld/mysqld.sock) which is what most every solution says to do.  But nothing changes and ruby still looks for /tmp/mysql.sock and again, this does not exist.  Shouldn't this have resolved the issue and pointed ruby to the correct path for mysqld.sock?

So to sum up, my ruby script is looking for /tmp/mysql.sock but that file does not seem to exist at all on my computer and certainly not in the location.  What I do have is a mysqld.sock but all my attempts to make it see that file have failed.

>>>my assumtion: mysql is not running

I can say for sure that an instance MySQL server is running.  I have a GUI console for MySQL on my Mac and it shows it as running and I also use to run the db for another application that uses PHP on this machine as well.

What's next?
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops, typo:
 s/mack/Mac/
Avatar of max7

ASKER

>>>Without digging into your system (ruby, mysql, whatever), I'd simply do:
  ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock

Ok ... but the fact that I can't find /tmp/mysql.sock won't matter you think?
well, it's your local configuration for accessing mysql which is setup in another way than ruby expects, my suggested link fixes this quick&dirty ;-)
BTW, you also may check ~/.my.cnf
Avatar of max7

ASKER

>>>well, it's your local configuration for accessing mysql which is setup in another way than ruby expects, my suggested link fixes this quick&dirty ;-)

Ok, sounds good.  Two questions in regards to this:

*How do I remove the symlink, if this doesn't work?  (simple to do I'm sure, I just don't know)
*Shouldn't including a socket assignment in database.yml have taken care of this issue?
rm /tmp/mysql.sock

> Shouldn't including a socket assignment in database.yml ...
sorry I don't know these tools/libs, so you may test it yourself
Avatar of max7

ASKER

Assuming I did this correctly, it didn't work.  Here's the terminal response:

Maxs-MacBook-Pro:myProject max$ cd /tmp
Maxs-MacBook-Pro:tmp max$ ls -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
ls: /tmp/mysql.sock: No such file or directory
0 /var/run/mysqld/mysqld.sock

Open in new window


Did I do something wrong?
i wrote

   ln -s ...

not

   ls -s ...

(I personaly realy see it, but I was told that some computers are build to use a mouse for copy&pasting text :-))
Avatar of max7

ASKER

Oooops!  You see, I knew I did something wrong :)

Good news is, we've made progress:

/Library/Ruby/Gems/1.8/gems/mysql2-0.2.17/lib/mysql2/client.rb:44:in `connect':Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)

So now, do I include the password in my database.yml?  If so how?
either your database is not setup to be access by user root @ localhost (see mysql.user and mysql.host database), or your application (ruby script) is configured with the wrong credentials, in particular without a password for user root
Avatar of max7

ASKER

>>>either your database is not setup to be access by user root @ localhost

root @ localhost is correct

>>>or your application (ruby script) is configured with the wrong credentials, in particular without a password for user root

Understood ... so my question is: where do I configure the correct credentials?  I thought it would be database.yml ... if not there, then where?
hmm, I don't know your application, and have no crystal ball handy ;-)
You need to get used to your application in particular how to setup a proper configuration. Applications come with a INSTALL.txt or README.txt or similar usually. Maybe it's worth to have a look at them.
Sorry, if you do not post the relevant parts of your code, it will be hard to help (except some answers who solved the same problems herself:).
Avatar of max7

ASKER

>>>hmm, I don't know your application, and have no crystal ball handy ;-)

Gee, I thought all you experts had crystal balls at your side! ;)

Seriously though, from the little I know about setting up Ruby on Rails and from reading the solutions around the web, database.yml is the goto file for Ruby to find the relevant db info it needs i.e. host, socket, password, etc.

That's why I was perplexed when I assigned the socket to the correct path for mysqld.sock and yet it seem to ignore it.

So I guess what I'm saying is, my application shouldn't be any different with regards to the config of a standard ruby app in which it uses database.yml for db info.

Here's a thought: is there anyway to see if my ruby script is looking to the database.yml as I think it should be or if not, where it is looking?
> .. file for Ruby  ..
ruby is just the language, well we use it as term for a bunch of libraries aka framework too, but the connection to the database must be configured in the script you finally start

Anyway, if database.yml is the proper configuration file, then you need to adapt the lines:

username:
password:
host:
port:

with proper values. Simply use the credentials you configured in mysql and it should work.
can you connect to your database using
  mysql -h localhost -u root -p
Avatar of max7

ASKER

>>>can you connect to your database using
  mysql -h localhost -u root -p

Yes I can, thankfully! :)

>>>Anyway, if database.yml is the proper configuration file ...

I'm pretty sure it is and I did notice something in it:

development:
  adapter: mysql2
  database: my_webapp
  username: root
  password: pass1234
  mongo:
    database: my_app
    capsize: <%= 10.megabytes %>
    host: localhost
    port: 27017
    socket: /var/run/mysqld/mysqld.sock

Open in new window


mongo (whatever that is) handles the socket assignment, something I did not note before.  perhaps if I moved socket assignment out of mongo and placed it above within the standard development block, it might work normally and without the need for a symlink?  I give it a shot later

Also, after adding the proper db password to database.yml, I received the following response:


/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:143:in `initialize':Errno::ENOENT: No such file or directory - /Users/max/Documents/workspace_osx/my_webapp/config/magento.yml

So is it safe to assume that I've successfully connected to the database and that I now need to find magento.yml?
seems so
congrats
Avatar of max7

ASKER

Thanks very much for slogging through that, greatly appreciate your time!