Can anybody please help me to resolve this error.I am tring to work with mysql and ROR
modified the gem file as "gem mysql" and database.yml file
copied the libmysql.dll(from mysql-connector-c-6.1.5-winx64 folder) file to rubu193/bin folder.
typed gem install mysql and it installed succefully.
typed bundle install
but when i typed rake db:create,it gave the following error.
Error:
LoadError: cannot load such file -- mysql/mysql_api
c:/Site/book/config/application.rb:7:in `<top (required)>'
c:/Site/book/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
please help to resolve this error.
Related
I'm trying to run the rake secret command when I get this error:
rake aborted!
NameError: uninitialized constant Mysql2::Client::SECURE_CONNECTION
/Users/myuser/dev/myapp/config/application.rb:7:in `<top (required)>'
/Users/myuser/dev/myapp/config/Rakefile:5:in `require'
/Users/myuser/dev/myapp/config/Rakefile:5:in `<top (required)>'
I've got the latest version of mysql and the gem mysql2. Has anyone else stumbled upon this issue recently? Most posts on this topic I've found here are some five years old and doesn't fix this problem.
Answering my own question here. This problem was caused by a mismatch between the mysql2 gem version (0.3.18) and the version specified in the gemfile (0.3.16).
This question already has answers here:
Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)
(10 answers)
Closed 8 years ago.
I installed MySQL using Homebrew (brew install mysql), and then ran $ gem install mysql2 . I'm on a Mac running OSX 10.9.4.
I changed directories into the root of my app, and then try to run the rake db:migrate command, and got this error:
Levine_iMac$ rake db:migrate
rake aborted!
LoadError: dlopen(/Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in require'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in <top (required)>'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in <top (required)>'
(See full trace by running task with --trace)
Levine_iMac$
I tried adding something to my .bash_profile, as described here, but that did not work.
I tried a sudo command as described here, but that did not work.
I then tried updating my Ruby version from 2.1.1.. to 2.1.2.., and now I am getting this error when I run rake:db migrate
Levine_iMac$ rake db:migrate
rake aborted! cannot load such file -- bundler/setup /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:1:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in '<top (required)>' (See full trace by running task with --trace) Levine_iMac$ bundle install rbenv: bundle: command not found The 'bundle' command exists in these Ruby versions:
2.1.1
Levine_iMac$
Any ideas on how to remedy this? Thanks.
Well, what are you exactly expecting to happen when you run rake db:migrate? Is some next step going to materialize for you? If you are able to answer this question, you will understand why what you're doing doesn't make sense.
I'll elaborate:
rake db:migrate only works in the context of an existing rails application. Running 'gem install mysql2' will get that library for you on your computer (this command is executed by itself, it doesn't actually have anything to do with Rails itself, or need a Rails app for context). So, there's no linear connection between the two.
rails new myapp
add 'gem mysql2' in the Gemfile
bundle
rake db:create
Or, alternatively:
rails new myapp -d mysql
I'm a ruby on rails beginner, and I'm trying to run a rails app on my local mac. I have set up the environment and MySQL database, and it was all smoothie until the last setup step: db:migrate rake. I got the following error:
cannot load such file -- bundler/setup
/Users/snailwalker/vietnam/snailwalker/config/boot.rb:7:in `<top (required)>'
/Users/snailwalker/vietnam/snailwalker/config/application.rb:2:in `<top (required)>'
/Users/snailwalker/vietnam/snailwalker/Rakefile:5:in `<top (required)>'
What am I missing?
cannot load such file -- bundler/setup
Most probably the reason of this issue is that you don't have bundler. You should install bundler then try to run migrations again.
gem install bundler
bundle install
bundle exec rake db:migrate
Hope it'll help you.
I'm running Rails 4.0.3 on Ruby 2.0.0 on Windows 7, and have installed the DevKit (all x64).
I've installed the mysql2 gem using subst X: "C:\Program Files\MySQL\MySQL Server 5.6" and then gem install mysql2 --platform=ruby -- --with-mysql-dir=X:, and it installed fine. I then created a new app with rails new mysql_testy which ran fine, but when I run rails server I get the following error:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in 'require': 193: %1 is not a valid Win32 application. - C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in 'require'
from C:/Users/Liam/Ruby/mysql_testy/config/application.rb:7:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in 'tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in '<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'`
Do you guys have any idea what's happening?
Not sure if you figured it out yet, but I was having the same issue. I installed the 32 bit sql connector, copied the libmysql.dll file from it and pasted it into Ruby/bin folder. Opened a new command prompt and was able to connect to the server.
Before this step though you may have to reinstall a fresh MySQL2 gem pointing to the path of the connector: gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\mysql-connector-c-6.1.5-win32\lib" --with-mysql-include="C:\mysql-connector\mysql-connector-c-6.1.5-win32\include" --with-mysql-dir="C:\mysql-connector"'
Hope this helps
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/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/imran/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
Does anyone know how i can fix this?? Thanks in advance ;-)
now i'm getting this?
dyld: lazy symbol binding failed: Symbol not found:
_mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info Referenced from:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap
may be this post is similiar with your problem :
Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem
Try this:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
Put this in your .profile (or .bashrc) and type this command
my_term> source .profile
replace '/usr/local/mysql/lib/' by where you MySQL client is installed
Updated MySQL again from installer (say, mysql-5.5.10-osx10.6-x86_64).
Then MySQL2 gem:
$ sudo gem install mysql2 --
--with-mysql-config=/usr/local/mysql-5.5.10-osx10.6-x86_64/bin/mysql_config
It worked for me.
For permanent fix, try to create a soft link by command -
sudo ln -s /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/lib/libmysqlclient.16.dylib
http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html
I also had this problem and any suggestions I found here or in other questions didn't get me anywhere, but running as root did (with sudo rails s). I guess that when running as root, it uses the right path to the mysql library, but changing it with install_name_tool as described in one of the links here doesn't work, too. As long as I don't find the issue, I need to start my rails app with sudo.