Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installed activerecord-mysql2-adapter, but mongify could not load it #138

Open
britaramsay opened this issue Jun 4, 2017 · 5 comments
Open

Comments

@britaramsay
Copy link

Hi! Thanks for great library!!

I run mongify check database.config, but it said Could not load 'active_record/connection_adapters/mysql2_adapter'

Could you please help me?

OS: Windows 10
Ruby version: 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]

database.config:

sql_connection do
  adapter   "mysql2"
  host      "localhost"
  username  "root"
  password  "PASSWORD"
  database  "DB_NAME"
  port       "3306"
end

mongodb_connection do
  host      "localhost"
  database  "mean-qwikcut-app"
end

local gem:

*** LOCAL GEMS ***

activemodel (5.1.1, 4.2.8)
activerecord (5.1.1, 4.2.8)
activerecord-mysql2-adapter (0.0.3)
activesupport (5.1.1, 4.2.8)
arel (8.0.0, 6.0.4)
bigdecimal (default: 1.3.0)
blunder (0.0.1)
bson (1.12.5)
bson_ext (1.12.5)
builder (3.2.3)
concurrent-ruby (1.0.5)
did_you_mean (1.1.0)
highline (1.7.8)
i18n (0.8.4)
io-console (default: 0.4.6)
json (default: 2.0.2)
minitest (5.10.1)
mongify (1.3.1)
mongo (1.12.5)
mysql2 (0.4.6 x64-mingw32)
net-telnet (0.1.1)
openssl (default: 2.0.3)
power_assert (0.4.1)
psych (default: 2.2.2)
rake (12.0.0)
rdoc (default: 5.0.0)
test-unit (3.2.3)
thread_safe (0.3.6)
tzinfo (1.2.3)
xmlrpc (0.2.1)

Error message:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6-x64-mingw32/lib/mysql2.rb:23: warning: previous definition of LoadLibrary was here
C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': Could 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 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6-x64-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6-x64-mingw32/lib/mysql2.rb:31:in `<top (required)>'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:4:in `<top (required)>'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:50:in `establish_connection'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mongify-1.3.1/lib/mongify/database/sql_connection.rb:40:in `setup_connection_adapter'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mongify-1.3.1/lib/mongify/database/sql_connection.rb:56:in `has_connection?'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:99:in `check_sql_connection'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:68:in `execute'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in `execute!'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mongify-1.3.1/bin/mongify:15:in `<top (required)>'
        from C:/Ruby24-x64/bin/mongify:22:in `load'
        from C:/Ruby24-x64/bin/mongify:22:in `<main>'

Not sure if this information helps you, but when I change mysql2 to mysql, I get :in rescue in spec': Specified 'mysql' for database adapter, but the gem is not loaded. Then, when I run gem install mysql, it could not build the gem native extension.

If you need more information, please let me know! I really want to import

@anlek
Copy link
Owner

anlek commented Jun 5, 2017

Hey @britaramsay,
Sorry to hear you're having an issue. I'd assume this is a Windows issue and I currently don't have access to a machine that I could test on. Try running an earlier version of Ruby (2.2 maybe) and see if that fixes the problem. Also, uninstall Rails 5.1 (by running gem uninstall rails and select version 5.1).

Good luck,
Andrew

@ghost
Copy link

ghost commented Jun 30, 2017

@anlek thanks for the solution of reverting to ruby 2.2. You are right Ruby 2.4 was culprit.

I had same problem as @britaramsay on windows 10 with Ruby 2.4...what a pain on windows to get ruby app running...I am not ruby developer but experience in software development help.

@ghost
Copy link

ghost commented Jun 30, 2017

I get following date related error when I run following command
" mongify process database.config database_transition.rb"
what should I change date type of mysql column in database_transition.rb?

Thanks for your help.

C:/Ruby22/lib/ruby/gems/2.2.0/gems/bson-1.12.5/lib/bson/bson_c.rb:20:in serialize': Date is not currently supported; use a UTC Time instance instead. (BSON::InvalidDocument) 00:00:00 from C:/Ruby22/lib/ruby/gems/2.2.0/gems/bson-1.12.5/lib/bson/bson_c.rb:20:in serialize'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:65:in block in batch_write_incremental' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:57:in catch'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:57:in batch_write_incremental' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection.rb:1184:in batch_write'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection.rb:411:in insert' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/database/no_sql_connection.rb:101:in insert_into'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:36:in block (2 levels) in copy_data' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/database/sql_connection.rb:86:in block in select_rows'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/core_ext/range/each.rb:7:in each' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/activesupport-4.2.9/lib/active_support/core_ext/range/each.rb:7:in each_with_time_with_zone'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/database/sql_connection.rb:84:in select_rows' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:29:in block in copy_data'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:28:in each' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:28:in copy_data'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:14:in process' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:72:in execute'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in execute!' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/bin/mongify:15:in <top (required)>'
from C:/Ruby22/bin/mongify:23:in load' from C:/Ruby22/bin/mongify:23:in

'

@ghost
Copy link

ghost commented Jul 1, 2017

I changed mysql field to timestamp to overcome date issue.

It looks like it has created all the tables & rows in mongodb with following error message

" mongify process database.config database_transition.rb"

C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/db.rb:610:in rescue in command': Database command 'update' failed: Unknown option to update command: multi (Mongo::OperationFailure) from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/db.rb:606:in command'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:314:in block in send_write_command' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/functional/logging.rb:55:in block in instrument'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/functional/logging.rb:20:in instrument' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/functional/logging.rb:54:in instrument'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection_writer.rb:313:in send_write_command' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection.rb:1104:in send_write'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongo-1.12.5/lib/mongo/collection.rb:497:in update' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/database/no_sql_connection.rb:145:in remove_pre_mongified_ids'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/processor_common.rb:116:in block in remove_pre_mongified_ids' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/processor_common.rb:114:in each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/processor_common.rb:114:in remove_pre_mongified_ids' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/translation/process.rb:18:in process'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:72:in execute' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in execute!'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/mongify-1.3.1/bin/mongify:15:in <top (required)>' from C:/Ruby22/bin/mongify:23:in load'
from C:/Ruby22/bin/mongify:23:in `

'

@robertangeles
Copy link

Hi ghost. What version of mongoDB are you using?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants