LoadError when using heroku db:push - ruby-on-rails

When i use "heroku db:push" to transfer my local data to heroku,i got this error message:
Sequel::AdapterNotFound -> LoadError: no such file to load -- sequel/adapters/mysql2
I already install the mysql2 gem, and i am using rvm with ruby 1.9.2 in Mac OS X Snow Leopard.

Are you using the most current version of Sequel? mysql2 support wasn't added until 3.15.0.

I'm able to use the original "mysql" gem still with rails3 instead of "mysql2" to get around this problem.

Taps is still not compatible with sequel 3.15 which has mysql2 support. So mysql2 adapter won't work heroku db:pull or db:push commands. But I got it working by using the old mysql adapter. i was facing problems because my mysql adapter wasn't configured properly. If you are on 64 bit macOSX. Try uninstalling mysql adapter and reinstalling it using:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Hope it helps.

might be old news, but make sure you are a) in the projects root folder and b) in the correct rvm gemset!

Related

How to use mysql2 0.3.16 with Ruby 1.9.3? (uninitialized constant Mysql2::Client::SECURE_CONNECTION)

I'm trying to set up my local dev environment to match my team's. I can't upgrade Ruby/Rails/mysql2 (for the time being).
I know my local MySQL config is good (enough?) because I can create a new Rails project and run it just fine. I'm getting the same error if I run rake db:create or rails s or even start IRB and run require 'mysql2'.
I've googled the hell out of this. I was initially using MariaDB as my MySQL implementation locally, so I thought that might be screwing with the mysql2 gem. So I ripped out MariaDB and finally got MySQL 5.6 working (another team version we're locked into at the moment). After successfully upgrading to MySQL 5.6, I'm confident that's 100% not the issue.
I would expect if I had the wrong password for it to complain about the config somehow, but it's always the same.
uninitialized constant Mysql2::Client::SECURE_CONNECTION
Ruby (RVM): ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
Mysql2: 0.3.16
There have been some other version-related struggles, but nothing this strong. The only thing I've encountered that I haven't actually tried is building the mysql2 gem locally.
I would expect require 'mysql2' to at least load the gem. Neither Rails nor Rake will work with the gem at all. It's almost like it's missing some internal file.
following as discussion about this error in official gem, you should update version as
From
gem 'mysql2', '0.3.16'
to
gem 'mysql2', '0.3.17'
if you still met an error after you update version to 0.3.17, i think that you should update to 0.2.24
https://github.com/brianmario/mysql2/issues/603

windows 10 ruby2.5 rails 5.1.5 cannot load such file -- sqlite3/sqlite3_native (LoadError)

environment:
windows 10 ruby2.5 rails 5.1.5
problem:
cannot load such file -- sqlite3/sqlite3_native (LoadError)
I have try gem uninstall sqlite3 and gem install sqlite3 ,any solution on web has been try ,not working,anyone could help me? I need to fix this problem,my work need to move on. Thanks.
I resolved the problem similar to you. This does work when I require sqlite3 in Ruby. However, when used in Rails, the bundler will install the native version, which doesn't work. I have to run bundle update, uninstall the native version with gem uninstall, and then edit the sqlite3 entry in the Gemfile.lock to sqlite3 (1.3.11) or (1.3.13) and now it's working.
Or sometimes it's depending on many other reasons when we search to the Google with writing same error then it's showing the huge result every other person solved this differently. So if you not resolving this with my style then you need to research and need to try every possible way.
I encountered the same problem while using Windows 10. I installed rubyinstaller-devkit-2.5.1 which I uninstalled. I downloaded rails from railsinstaller.org. It works perfectly for me. I searched almost everywhere, none of the solutions were helpful
The sqlite3 gem isn't updated for Ruby-2.5, yet, but there's a simple workaround for using sqlite on RubyInstaller-2.5. Add this to your Gemfile:
gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby"
and run bundle install.
See also the RubyInstaller FAQ.
I had this same problem, spent hours searching but none of the solutions worked for me and all everyone said was used rails installer but I already had everything installed and wasn't ready to move things around. I found a solution however it's really wonky. you have to run this almost everytime you restart your rails server.
gem uninstall sqlite3 --all
ridk exec pacman -S mingw-w64-x86_64-sqlite3
gem inst sqlite3 --platform ruby
I have also downloaded and placed the appropriate .dll and .exe files for sqlite3 from their homepage and in the ruby bin directory and added it to the windows PATH.

Rails Server not Working (LoadErrror mysql2) Windows

I am trying to run rails server command but it showing mysql2 Load Error. I will place my Error log here
I searched many places.
I tried to install from my bundle itself using "gem install mysql2 --ruby=platform" command using connector c "libmysql.dll" file pasted in ruby/bin but no use.
I actually have MySQL installed on my system long back when I was doing JDBC connections. Its SQL server version 5.0- Is that version causing this error? Or Do I need to uninstall the MySQL from my system and install Latest Version!
And a doubt for me is how is this MySQL Server 5.0 connected to Rails as I no I have no idea about it, because while installation I used Connector C 6.1 for mysql2 installation from the Command Promt!
I tried Ruby on Rails - cannot load such file -- mysql2/2.2/mysql2 (LoadError)
I also tried Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0
But I am getting the same error.
I think I have given all the details regarding versions and what I did!
I tried doing this like 50 times but no progress! I hope I will get my problem solved !Thank You!
The following below instructions can help you.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-
6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-
dir="C:\connector-6.0.2"'
Or even shorter:
gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"
im not using windows. but seems to be duplicate with posts like this (Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0)

Load Error for Ruby on Rails mysql2

Nubie at Ruby on Rails so I wanted to build a "Hello World" style of app to get familiar with RoR. The app I chose, along with tutorial on installation, was Dave Berube's "checkbook" app as in http://www.redhat.com/magazine/025nov06/features/ruby/
Yes it is from 2006 and maybe I have bumped into my errors because RoR has moved on through the years. Anyway, I get errors similar to banditKing with his app on 20th Sept., and many others; I get a persistent error as below.
When I ran RoR without creating my first app, it displayed the initial splash screen which effectively told me to "get working and create sites!" so that was a good start :-)
[running "rails generate migrate InitialSchema" to begin generating the application framework.]
/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
My environment:
RH Enterprise Linux version 6, 64-bit
[root#svr checkbookapp]# which mysql
/usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.69 Source distribution
[root#svr checkbookapp]# which ruby
/usr/local/bin/ruby
[root#svr checkbookapp]# ruby -v
ruby 2.0.0p247 (2013-06-27) [x86_64-linux]
Rails version is 4.0.0
[root#svr checkbookapp]# gem list | grep mysql
mysql (2.9.1)
mysql2 (0.3.13)
Start of my app's Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'mysql2'
...
I have added the library path to MySQL path into my .bash_profile as done by banditKing but that has not resolved this error. Have tried re-installing mysql2 gem several times and doing numerous "bundle install" operations. Downloaded and installed the connector 6.1 from the MySQL site and yum install'd the share and the development versions without any difference.
Try updating RubyGems with gem update --system. You should get something like version 2.x. There's a bug with RubyGems 1.8.x on Ruby 2.0 installing gems with c extentions (like mysql2 and nokogiri).

Lazy symbol binding failed when creating ruby db

I am trying to install ruby on rails, and everything is installed now so far, but when I try to create a database with rake db:create, I get a weird error:
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/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.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap: 5
I am working on osx mountain lion latest update. Does anyone have the right solution for me?
You might try this.
sudo gem install mysql2 — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Be sure to modify the mysql config path with the location for yours.
You can determine this with the following command.
locate mysql_config
Leverage the path given with the command above.
The messge is telling that you have linked wrong version 32 vs. 64
On OSX you can see all versions on mysql installed
cd /usr/local/
and find right config in /usr/local/mysql-xxxx/bin/mysql_config
In my case it was:
gem uninstall mysql2
sudo gem install mysql2 --
--with-mysql-config=/usr/local/mysql-5.5.27-osx10.6-x86_64/bin/mysql_config
As discussed here: https://www.ruby-forum.com/topic/1440086
There are numerous questions about this and at least as many answers that work some of the time but not others. After trying most of them I noticed that the gem was 64bit and the mysql installation was 32bit.
To fix it:
install the 64 bit mysql
set up the symbolic links in /usr/local to point to the 64 bit version
set the PATH and DYLD_LIBRARY_PATH in your profile to include the correct versions
uninstall the mysql2 gem
install the mysql2 gem
ruby now plays nicely with mysql!
I haven't included the exact code as this tends to vary with your environment.
I was having a hard time with this one.. I tried all of the answers above, so I can't really pinpoint what combination resulted in the fix. I already had mysql installed and had reinstalled from mysql's website. It finally started working after I followed the bellow.
This is on Mavericks using rails 4 and brew is installed
brew install mysql
I'm not recommending this process .. Just noting that it worked for me after hours of frustration.
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo gem uninstall mysql
gem uninstall mysql2
gem install mysql
gem install mysql2
You need to install 64 bit MySql server. Don't forget to re-install mysql gem.
I had two versions of mysql installed (32 & 64 bit) for some reason.
Make sure your $MYSQL environmental variable (most likely found in ~/.bash_profile or ~/.profile) is pointing at the 64 bit version.
Also make sure you point towards the correct the mysql install when your installing the gem as the other answers have mentioned.
I had same problem. mysql2 version was 0.4.9, downgraded it to 0.4.5 and problem solved

Resources