ruby - rails server (4.0.0) cannot start - Error: LoadError:8 lib/mysql2.rb:8:in `require': libmysqlclient.so.18 -
i cannot start rails server. error shows:
$ rails server /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2a.rb:8:in `require': libmysqlclient.so.18: cannot open shared object file: no such file or directory - /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.so (loaderror) /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require' /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:132:in `require' /home/marslo/study/codes/ruby/railsbegin/config/application.rb:7:in `<top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require' /usr/local/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap' /usr/local/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>' bin/rails:4:in `require' bin/rails:4:in `<main>'
but! mysql2.so can fuond !!!:
$ ls -al /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.so -rwxr-xr-x 1 root root 131k oct 7 00:31 /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.so
i'v installed mysql from source code. , installed at:
$ whereis mysql mysql: /usr/local/mysql
i tried install mysql2 gem --with-mysql-config
, works fine:
$ sudo gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config building native extensions. take while... installed mysql2-0.3.13 1 gem installed installing ri documentation mysql2-0.3.13... installing rdoc documentation mysql2-0.3.13...
here database.yml:
development: adapter: mysql2 encoding: utf8 database: railsbegin_development pool: 5 username: root password: passwd host: localhost socket: /tmp/mysql.sock
here databases:
mysql> show databases; +------------------------+ | database | +------------------------+ | information_schema | | railsbegin_development | | mysql | | performance_schema | | test | +------------------------+ 5 rows in set (0.00 sec)
here bundle install:
$ bundle install using rake (10.1.0) using i18n (0.6.5) using minitest (4.7.5) using multi_json (1.8.1) using atomic (1.1.14) using thread_safe (0.1.3) using tzinfo (0.3.37) using activesupport (4.0.0) using builder (3.1.4) using erubis (2.7.0) using rack (1.5.2) using rack-test (0.6.2) using actionpack (4.0.0) using mime-types (1.25) using polyglot (0.3.3) using treetop (1.4.15) using mail (2.5.4) using actionmailer (4.0.0) using activemodel (4.0.0) using activerecord-deprecated_finders (1.0.3) using arel (4.0.0) using activerecord (4.0.0) using coffee-script-source (1.6.3) using execjs (2.0.2) using coffee-script (2.2.0) using thor (0.18.1) using railties (4.0.0) using coffee-rails (4.0.0) using hike (1.2.3) using jbuilder (1.5.1) using jquery-rails (3.0.4) using json (1.8.0) using mysql2 (0.3.13) using bundler (1.3.5) using tilt (1.4.1) using sprockets (2.10.0) using sprockets-rails (2.0.0) using rails (4.0.0) using rdoc (3.12.2) using sass (3.2.12) using sass-rails (4.0.0) using sdoc (0.3.20) using turbolinks (1.3.0) using uglifier (2.2.1) bundle complete! use `bundle show [gemname]` see bundled gem installed.
i don't know what's wrong it. can me? in advance!!
============
update 1
i've uninstalled mysql2 , reinstalled 0.3.11:
$ sudo gem install mysql2 -v 0.3.11 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-mysql-lib=/usr/local/mysql/lib --with-mysql-bin=/usr/local/mysql/bin fetching: mysql2-0.3.11.gem (100%) building native extensions. take while... installed mysql2-0.3.11 1 gem installed installing ri documentation mysql2-0.3.11... installing rdoc documentation mysql2-0.3.11...
and update gemfile:
gem 'mysql2', '~> 0.3.11'
and bundle install again, but 0.3.13 still installed!:
$ bundle install fetching gem metadata https://rubygems.org/........... fetching gem metadata https://rubygems.org/.. resolving dependencies... using rake (10.1.0) using i18n (0.6.5) using minitest (4.7.5) using multi_json (1.8.1) using atomic (1.1.14) using thread_safe (0.1.3) using tzinfo (0.3.37) using activesupport (4.0.0) using builder (3.1.4) using erubis (2.7.0) using rack (1.5.2) using rack-test (0.6.2) using actionpack (4.0.0) using mime-types (1.25) using polyglot (0.3.3) using treetop (1.4.15) using mail (2.5.4) using actionmailer (4.0.0) using activemodel (4.0.0) using activerecord-deprecated_finders (1.0.3) using arel (4.0.0) using activerecord (4.0.0) using bundler (1.3.5) using coffee-script-source (1.6.3) using execjs (2.0.2) using coffee-script (2.2.0) using thor (0.18.1) using railties (4.0.0) using coffee-rails (4.0.0) using hike (1.2.3) using jbuilder (1.5.1) using jquery-rails (3.0.4) using json (1.8.0) installing mysql2 (0.3.13) using tilt (1.4.1) using sprockets (2.10.0) using sprockets-rails (2.0.0) using rails (4.0.0) using rdoc (3.12.2) using sass (3.2.12) using sass-rails (4.0.0) using sdoc (0.3.20) using turbolinks (1.3.0) using uglifier (2.2.1) bundle complete! use `bundle show [gemname]` see bundled gem installed.
here gem list:
$ gem list | grep mysql2 mysql2 (0.3.13, 0.3.11)
by way, owner of mysql (installed source code) mysql:
$ ls -al total 160k -rw-r--r-- 1 mysql mysql 18k sep 10 15:38 copying -rw-r--r-- 1 mysql mysql 2.5k sep 10 15:38 readme -rw-r--r-- 1 mysql mysql 87k sep 10 15:38 install-binary drwxr-xr-x 2 mysql mysql 4.0k oct 1 23:51 docs/ drwxr-xr-x 3 mysql mysql 4.0k oct 1 23:51 include/ drwxr-xr-x 3 mysql mysql 4.0k oct 1 23:51 lib/ drwxr-xr-x 10 mysql mysql 4.0k oct 1 23:52 mysql-test/ drwxr-xr-x 28 mysql mysql 4.0k oct 1 23:52 share/ drwxr-xr-x 2 mysql mysql 4.0k oct 1 23:52 scripts/ drwxr-xr-x 4 mysql mysql 4.0k oct 1 23:52 sql-bench/ drwxr-xr-x 4 mysql mysql 4.0k oct 1 23:52 man/ drwxr-xr-x 3 mysql mysql 4.0k oct 1 23:52 support-files/ -rw-r--r-- 1 mysql mysql 943 oct 1 23:55 my.cnf drwxr-xr-x 2 mysql mysql 4.0k oct 1 23:57 bin/ drwxr-xr-x 6 mysql mysql 4.0k oct 7 01:04 data/
however, owner of ruby root.
is because of permission problem?
====================
update 2
install mysql2 version: 0.3.11, --platform=ruby:
$ sudo gem uninstall mysql2 $ sudo gem install mysql2 -v 0.3.11 --platform=ruby -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-mysql-lib=/usr/local/mysql/lib --with-mysql-bin=/usr/local/mysql/bin $ rm -rf gemfile.lock $ bundle install
mysql variables can found by:
$ mysqladmin variables
and, install nodejs:
$ sudo apt-get install nodejs
and, works!!
$ rails server => booting webrick => rails 4.0.0 application starting in development on http://0.0.0.0:3000 => run `rails server -h` more startup options => ctrl-c shutdown server [2013-10-07 21:08:06] info webrick 1.3.1 [2013-10-07 21:08:06] info ruby 1.9.3 (2013-06-27) [i686-linux] [2013-10-07 21:08:06] info webrick::httpserver#start: pid=3676 port=3000
do not forgot start mysql server:
$ sudo service mysql start
====================
update 3
nodejs installation centos:
$ sudo yum groupinstall 'development tools' $ mkdir nodjs && cd $_ $ wget http://nodejs.org/dist/node-latest.tar.gz --2013-10-12 16:01:53-- http://nodejs.org/dist/node-latest.tar.gz resolving nodejs.org... 165.225.133.150 connecting nodejs.org|165.225.133.150|:80... connected. http request sent, awaiting response... 200 ok length: 13633041 (13m) [application/octet-stream] saving to: “node-latest.tar.gz” 100%[============================================================================>] 13,633,041 513k/s in 36s 2013-10-12 16:02:31 (375 kb/s) - “node-latest.tar.gz” saved [13633041/13633041] $ tar xzf node-latest.tar.gz $ cd node-v0.10.20/ $ ./configure $ make $ sudo make install
===================
note
- this not related permission problem
- delete gemfile.lock first before running bundle install if updated in gemfile
add gemfile gem 'mysql2', '~> 0.3.11'
, try bundling again.
Comments
Post a Comment