Gem :: load error while migrating from MySQL to MongoDB - mysql

I am trying to migrate the Mysql DB to MongoDB using tool Mongify by referring the
documentation :
i have seen , there are few posts already present regarding such migration but they mentioned issues with rails application and some dependencies on rails. however, in my case , it is just simple migration without rails.
Environment details:
windows enterprise 7
Mysql community server : 5.7
Mongo db server : 4.0
ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) [i386-mingw32]
Mysql c Connector (32 bit)
mysql server and mongo db server are working fine as a service.
rubygems environment details as follows :
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby25/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: C:/Users/irfan.sayed/.gem/ruby/2.5.0
- RUBY EXECUTABLE: C:/Ruby25/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby25/bin
- SPEC CACHE DIRECTORY: C:/Users/irfan.sayed/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby25/lib/ruby/gems/2.5.0
- C:/Users/irfan.sayed/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\windows\system32
- C:\windows
- C:\windows\System32\Wbem
- C:\Program Files (x86)\Microsoft Application Virtualization Client
- C:\Program Files\PuTTY\
- C:\apache-maven-3.5.2-bin\apache-maven-3.5.2\bin
- "C:\Program Files\Java\jdk1.8.0_151\bin"
- C:\Program Files\Git\cmd
- C:\HashiCorp\Vagrant\bin
- C:\windows\System32\WindowsPowerShell\v1.0\
- C:\windows\System32\WindowsPowerShell\v1.0\
- C:\Ruby25\bin
- C:\Program Files\MySQL\MySQL Server 8.0\bin
- C:\Program Files\MongoDB\Server\4.0\bin
locally installed Gems are as follows :
activemodel (5.2.1, 4.2.10)
activerecord (5.2.1, 4.2.10)
activerecord-mysql2-adapter (0.0.3)
activesupport (5.2.1, 4.2.10)
arel (9.0.0, 6.0.4)
awesome_print (1.8.0)
backports (3.11.3)
bigdecimal (default: 1.3.4)
bson (1.12.5)
bson_ext (1.12.5)
builder (3.2.3)
bundler (1.16.3)
byebug (10.0.2)
cmath (default: 1.0.0)
coderay (1.1.2)
concurrent-ruby (1.0.5)
coolline (0.5.0)
csv (default: 1.0.0)
cucumber (3.1.2)
cucumber-core (3.2.0)
cucumber-expressions (6.0.1)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
date (default: 1.0.0)
dbm (default: 1.0.0)
did_you_mean (1.2.0)
diff-lcs (1.3)
etc (default: 1.0.0)
fcntl (default: 1.0.0)
fiddle (default: 1.0.0)
fileutils (default: 1.0.2)
gdbm (default: 2.0.0)
gherkin (5.1.0)
highline (1.7.8)
i18n (0.9.5, 0.7.0)
io-console (default: 0.4.6)
ipaddr (default: 1.2.0)
jazz_fingers (5.0.0)
json (default: 2.1.0)
metaclass (0.0.4)
method_source (0.9.0)
minitest (5.11.3, 5.10.3)
mocha (1.6.0)
mongify (1.3.2)
mongo (1.12.5)
multi_json (1.13.1)
multi_test (0.1.2)
mysql (2.9.1 x86-mingw32)
mysql2 (0.5.2 x86-mingw32)
net-telnet (0.1.1)
openssl (default: 2.1.0)
pg (1.0.0 x86-mingw32)
power_assert (1.1.1)
pry (0.11.3)
pry-byebug (3.6.0)
pry-coolline (0.2.5)
psych (default: 3.0.2)
rake (12.3.1, 12.3.0, 11.3.0)
rdoc (default: 6.0.1)
rspec (2.99.0)
rspec-collection_matchers (1.1.3)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
rspec-mocks (2.99.4)
scanf (default: 1.0.0)
sdbm (default: 1.0.0)
sqlite3 (1.3.13 x86-mingw32)
stringio (default: 0.0.1)
strscan (default: 1.0.0)
test-unit (3.2.7)
thread_safe (0.3.6)
tzinfo (1.2.5)
unicode_utils (1.4.0)
watchr (0.7)
webrick (default: 1.4.2)
xmlrpc (0.3.0)
yard (0.9.15)
zlib (default: 1.0.0)
bundle install and bundle update commands are just working fine. all the dependencies are gems are resolved properly and available in default folder of ruby.
database.config file used as below :
sql_connection do
adapter "mysql2"
host "localhost"
username "root"
password "<password>"
database "abc"
end
mongodb_connection do
host "localhost"
database "db"
end
however getting following error :
mongify check database.config
Traceback (most recent call last):
10: from C:/Ruby25/bin/mongify:23:in `<main>'
9: from C:/Ruby25/bin/mongify:23:in `load'
8: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/bin/mongify:17
:in `<top (required)>'
7: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/cl
i/application.rb:28:in `execute!'
6: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/cl
i/command/worker.rb:68:in `execute'
5: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/cl
i/command/worker.rb:99:in `check_sql_connection'
4: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/da
tabase/sql_connection.rb:56:in `has_connection?'
3: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mongify-1.3.2/lib/mongify/da
tabase/sql_connection.rb:40:in `setup_connection_adapter'
2: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activerecord-4.2.10/lib/acti
ve_record/connection_handling.rb:50:in `establish_connection'
1: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activerecord-4.2.10/lib/acti
ve_record/connection_adapters/connection_specification.rb:174:in `spec'
C:/Ruby25/lib/ruby/gems/2.5.0/gems/activerecord-4.2.10/lib/active_record/connect
ion_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'mys
ql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your
Gemfile (and ensure its version is at the minimum required by ActiveRecord). (G
em::LoadError)
not able to understand what is still missing. is the issue with MySQL adapter OR some version compatibility issue
EDIT : further update per suggestion from matthewd
i edited Gemfile and added following line
s.add_development_dependency('mysql2', '~> 0.4.10')
ran the bundle update --force , bundle install --force but it was still installing the 0.5.x version of mysql2 gem only
so i manually installed mysql2 gem of version 0.4.10 using following command
gem install mysql2 -v 0.4.10
but now it is giving following error
11: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10-x86-mingw32/li
b/mysql2.rb:31:in `<top (required)>'
10: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `require'
9: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:240:in `load_dependency'
8: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `block in require'
7: from C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59
:in `require'
6: from C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59
:in `require'
5: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10-x86-mingw32/li
b/mysql2/mysql2.rb:2:in `<top (required)>'
4: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `require'
3: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:240:in `load_dependency'
2: from C:/Ruby25/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/act
ive_support/dependencies.rb:274:in `block in require'
1: from C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59
:in `require'
C:/Ruby25/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': Co
uld not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that
the adapter in config/database.yml is valid. If you use an adapter other than 'm
ysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the
Gemfile. (LoadError)

The error message is misleading: you're using a version of the mysql2 gem that's too new for Active Record 4.2.10 (the latest version mongify supports).
The simplest solution is to explicitly use an older version of mysql2 by including a version constraint in your Gemfile entry:
gem "mysql2", "< 0.5"

Finally it is resolved. it has the issue with ruby version and 32 bit libraries. ruby 2.3 was properly tested and works fine with mongify gem. i was using latest version of ruby and was the issue.

Related

server address changed after set url

I ran set-url and now i'm not able to serve my page anymore.
I'm still not sure if that is the reason
before: Server address: http://127.0.0.1:4000 - > it was working
now : Server address: http://127.0.0.1:4000 /carlashub.github.io// - >broken
ERROR `/' not found.
This is the command i'm running to serve :
bundle exec jekyll serve -- watch --baseurl ""
I also tried to remove the base url from the config.yml and run $ jekyll serve --baseurl '/' this is the output :
HP#carlas MINGW64 /c/xampp/htdocs/carla201 (gh-pages)
WARN: Unresolved specs during Gem::Specification.reset:
eventmachine (>= 0.12.9)
listen (~> 3.0)
rouge (< 4, >= 1.7)
rb-fsevent (>= 0.9.4, ~> 0.9)
rb-inotify (>= 0.9.7, ~> 0.9)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated public_suffix 3.0.3, but your Gemfile requires public_suffix 3.0.1. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:31:in `block in setup'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:26:in `map'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:26:in `setup'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.16.2/lib/bundler.rb:107:in `setup'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/jekyll-3.8.5/lib/jekyll/plugin_manager.rb:50:in `require_from_bundler'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/jekyll-3.8.5/exe/jekyll:11:in `<top (required)>'
from C:/RailsInstaller/Ruby2.2.0/bin/jekyll:23:in `load'
from C:/RailsInstaller/Ruby2.2.0/bin/jekyll:23:in `<main>'

Can't use a gem because json 2.1.0 is activated, but the gem requires 1.8.6

I've been trying to figure out how to get the slack-ruby-client gem to work in my Ruby script, but I'm having issues when it comes to json, apparently.
Here's what I'm getting:
[user:ubuntu:~/Documents]$ irb 4:43PM/07.08
2.5.1 :001 > require 'slack-ruby-client'
Traceback (most recent call last):
11: from /home/user/.rvm/rubies/ruby-2.5.1/bin/irb:11:in `<main>'
10: from (irb):1
9: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
8: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
7: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
6: from /home/user/.rvm/gems/ruby-2.5.1/gems/slack-ruby-client-0.11.1/lib/slack-ruby-client.rb:13:in `<top (required)>'
5: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:90:in `require'
4: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:90:in `each'
3: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:91:in `block in require'
2: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/specification.rb:1434:in `activate'
1: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/specification.rb:2315:in `check_version_conflict'
Gem::LoadError (can't activate json-1.8.6, already activated json-2.1.0)
2.5.1 :002 > exit
I cannot uninstall json v2.1.0 for whatever reason. Although it says it uninstalled successfully when running gem uninstall json v2.1.0, it still shows up when I look at the list of gems and search for json.
[user:ubuntu:~/Documents]$ gem uninstall json -v 2.1.0 4:45PM/07.08
Successfully uninstalled json-2.1.0
[user:ubuntu:~/Documents]$ gem list | grep -i json 4:47PM/07.08
json (default: 2.1.0, 1.8.6)
multi_json (1.13.1, 1.11.2)
and then the error still persists. I've tried to manually install 1.8.6 to see if it would override the default, but nothing.
Any suggestions would be greatly appreciated.
Attempt #1
[user:~/Documents]$ gem uninstall json 2:52PM/07.09
You have requested to uninstall the gem:
json-1.8.6
activesupport-4.2.4 depends on json (>= 1.7.7, ~> 1.7)
activesupport-4.2.3 depends on json (>= 1.7.7, ~> 1.7)
rdoc-4.2.0 depends on json (~> 1.4)
sdoc-0.4.2 depends on json (>= 1.7.7, ~> 1.7)
sdoc-0.4.1 depends on json (>= 1.7.7, ~> 1.7)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Successfully uninstalled json-1.8.6
[user:ubuntu:~/Documents/rubyscript]$ bundle install 2:56PM/07.09
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 1.16.2
Fetching json 1.8.6
Installing json 1.8.6 with native extensions
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
[user:ubuntu:~/Documents/rubyscript]$ irb 2:56PM/07.09
2.5.1 :001 > require 'slack-ruby-client'
Traceback (most recent call last):
11: from /home/user/.rvm/rubies/ruby-2.5.1/bin/irb:11:in `<main>'
10: from (irb):1
9: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:39:in `require'
8: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
7: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:135:in `require'
6: from /home/user/.rvm/gems/ruby-2.5.1/gems/slack-ruby-client-0.11.1/lib/slack-ruby-client.rb:13:in `<top (required)>'
5: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:90:in `require'
4: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:90:in `each'
3: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:91:in `block in require'
2: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/specification.rb:1434:in `activate'
1: from /home/user/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/specification.rb:2315:in `check_version_conflict'
Gem::LoadError (can't activate json-1.8.6, already activated json-2.1.0)
2.5.1 :002 > exit
[user:ubuntu:~/Documents/rubyscript]$ cat Gemfile 2:56PM/07.09
source 'https://rubygems.org'
gem 'json', '=1.8.6'
Please try
bundle exec rspec
or
bundle exec rake spec
Hope this helps!
First, try uninstalling the gem altogether for all versions:
gem uninstall json
Then install the specific version required, also make sure your Gemfile specifies a specific version for the gem:
gem 'json', '=1.8.6'
This should fix the issue
bundle exec rspec solved for me... in my case I was trying to run rspec in a docker container. Ruby 2.6

no such file to load -- mysql (LoadError) - ruby gems

I'm a newbie to ruby, trying to connect mysql servcer through Ruby for cucumber and getting the following error while running cukes.
error: no such file to load -- mysql (LoadError)
But installed mysql gem and here is my gem list and also has libmysql.dll under ruby_home\bin path
addressable (2.2.8)
builder (3.0.0)
bundler (1.1.4)
childprocess (0.3.3)
cucumber (1.2.1)
diff-lcs (1.1.3)
ffi (1.0.11, 1.0.9 x86-mingw
gherkin (2.11.1 x86-mingw32)
headless (0.2.2)
json (1.7.3)
libwebsocket (0.1.4)
minitest (1.6.0)
multi_json (1.3.6)
mysql (2.8.1 x86-mingw32)
mysql2 (0.3.11 x86-mingw32)
net-ldap (0.3.1)
rake (0.8.7)
rdoc (2.5.8)
rspec (2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
rspec-mocks (2.10.1)
rubygems-update (1.8.24)
rubyzip (0.9.9)
selenium-webdriver (2.24.0)
titleize (1.2.1)
watir-webdriver (0.6.1)
Any idea whats going on...
What version of Ruby are you running mate? If you're running 1.8 you need to add "require 'rubygems'" before your "require 'mysql'. If not then try requiring the gem in a non-explicit way. Something like this:
require_relative "rubygems"
require_relative "mysql"
If you want to give it a quick test use this code below..:
require "rubygems"
require "mysql"
begin
# connect to the MySQL server
db = Mysql.real_connect("localhost", "username", "password")
# get server version string and display it
puts "Server version: " + db.get_server_info
rescue Mysql::Error => e
puts "Error code: #{e.errno}"
puts "Error message: #{e.error}"
puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
ensure
# disconnect from server
db.close if db
end
If all goes well you should see your mysql version..

version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1

Hi i am using rails version 3.0.7 when i run rails generate model task name:string i m getting following warning
WARNING: This version of mysql2 (0.3.2) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `establish_connection': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/railtie.rb:59
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/base.rb:1904
from /home/sun/railsapp/dog/vendor/plugins/attribute_fu/init.rb:1
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/plugin.rb:81
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
from /home/sun/railsapp/dog/config/environment.rb:5
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:103:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:103:in `require_environment!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:16
from script/rails:6:in `require'
from script/rails:6
when i try to install activerecord-mysql2-adapter by :gem install activerecord-mysql2-adapter
ERROR: Could not find a valid gem 'activerecord-mysql2-adapter' (>= 0) in any repository
please help me
thanks
The problem is because you are trying to install the latest version of mysql2 which is incompatible with rails 3.0.x version
SO, in your Gemfile change the line for mysql2 gem for this:
gem 'mysql2', '< 0.3'
then bundle command
and then when the new mysql2 gem file ( i think is 0.2.7 ) you will solve the problem.
if still not working try this too:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Users/YOUR_USER_NAME/.rvm/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
gem 'mysql2', '< 0.3' is the only way on Rails 3.0.7 (before 3.1)
UPDATE: sorry, that was not the case also, did't work either, there is a better way:
vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.2/lib/active_record/connection_adapters$[rails307]$ ls
em_mysql2_adapter.rb mysql2_adapter.rb
take mysql2_adapter.rb file from mysql2 gem version 0.2.x and copy it to the above location
now it works for me with just gem 'mysql2' in Gemfile
After trying the solution offered by #eveevans I was still having version issues. Then reading the suggestion by #rubyconvict, I thought instead about using the -v option for gem rather than pushing files about.
Here's what I found eventually resolved my struggle with the dreaded "version of mysql2 (0.3.2)" message on DreamHost:
# in mysql, create example_app & example_app_test ...
# ... for the purposes of this example only, production == development db
rails new example_app --database=mysql --freeze
cd example_app
vim config/database.yml
# change settings for host, user, password ...
# ... database for test (example_app_test) ...
# ... & database for production & development (example_app)
vim Gemfile
# gem 'mysql2', '< 0.3'
gem uninstall mysql2 # if installed: gem list -d mysql2
gem install mysql2 -v 0.2.7
rake db:migrate
From there, I can move onto other RoR fun, like perhaps modifying routes (vim config/routes.rb ... however your mileage may vary).
WARNING: Please use the 0.2.x
releases if you plan on using it in
Rails <= 3.0.x
so in short just use the latest in the 0.2.x branch for the mysql2 gem.

rails mysql adapter error

I'm having trouble finding a solution to this problem. I'm getting the error
Please install the mysql adapter: 'gem install activerecord-mysql-adapter'
when I specify either ruby-mysql or mysql2 in my Gemfile. This has only happened since I've upgraded to Rails 3.1.0-rc1. I'm running OSX 10.6, Ruby 1.9.2.
cody$ rails c
/Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.) (RuntimeError)
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:68:in `establish_connection'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:60:in `establish_connection'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/railtie.rb:69:in `block (2 levels) in <class:Railtie>'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/base.rb:2135:in `<top (required)>'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc1/lib/active_record/railtie.rb:34:in `block in <class:Railtie>'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `call'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `block in load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `each'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/railtie.rb:177:in `load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application.rb:115:in `block in load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application/railties.rb:8:in `each'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application/railties.rb:8:in `all'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/application.rb:115:in `load_console'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:26:in `start'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands/console.rb:8:in `start'
from /Users/cody/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Here is the gem env output
cody$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.3]
- INSTALLATION DIRECTORY: /Users/cody/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/cody/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/cody/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/cody/.rvm/gems/ruby-1.9.2-p180
- /Users/cody/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
You'll have to change your config/database.yml to use the mysql2 adapter instead of mysql.
So replace:
adapter: mysql
With:
adapter: mysql2
I had to enforce the use of mysql2 gem version 0.2.7 and while trying to upgrade my rails 3.0.7 app to 3.1.0.rc1, I also noticed ,that you'll need the following new gems in your Gemfile, too:
gem 'mysql2', '< 0.3' # as stated above
# Asset template engines
gem 'json'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
# other required things for rails 3.1
gem 'jquery-rails'
gem 'mustang' # this is ONE execjs backend of many, and the only one that worked for me.
Tell me if that worked for you.
Fixed the problem by updating the gemfile for my app to identify mysql2 as part of the bundle.
To do this, navigate to the root of your app, run open gemfile
Add the line gem 'mysql2', '< 0.3.7' directly below the gem line for rails.
While in terminal at the root of your app, run bundle install
Run bundle show mysql2 to verify the bundle worked. You should be good to go with the adapter now.
My environment is Rails 3.1, MySql 5.5, Ruby 1.9.2.
I created a Rails project on windows and moved it to a machine running Fedora. I solved this problem by renaming the "Gemfile.lock" to "old_Gemfile.lock". Of course, you must still specify the adapter as 'mysql2' and include the appropriate gem in your gemfile.