Ошибка Gem :: load при миграции с MySQL на MongoDB

0

Я пытаюсь перенести Mysql DB в MongoDB с помощью инструмента Mongify, обратившись к документации:

я видел, что в отношении такой миграции уже есть несколько сообщений, но они упомянули проблемы с приложением rails и некоторыми зависимостями от рельсов. однако в моем случае это просто простая миграция без рельсов.

Информация об окружающей среде:

  • оконное предприятие 7

  • Сервер сообщества Mysql: 5.7

  • Сервер Mongo db: 4.0

  • ruby: ruby 2.5.1p57 (2018-03-29 версия 63029) [i386-mingw32]

  • Разъем Mysql c (32 бит)

Сервер mysql и сервер mongo db отлично работают как служба.

Подробности об окружающей среде rubygems:

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

локально установленные драгоценные камни:

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 и bundle update команд bundle update работают нормально. все зависимости - это драгоценные камни, которые правильно разрешены и доступны в папке по умолчанию рубина.

файл database.config используемый ниже:

sql_connection do
  adapter   "mysql2"
  host      "localhost"
  username  "root"
  password  "<password>"
  database  "abc"
end

mongodb_connection do
  host      "localhost"
  database  "db"
end

однако получить следующую ошибку:

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)

не в состоянии понять, что до сих пор отсутствует. проблема с адаптером MySQL или проблема с совместимостью с версией

EDIT: дальнейшее обновление за предложение от matthewd

я отредактировал Gemfile и добавил следующую строку

s.add_development_dependency('mysql2', '~> 0.4.10')

bundle update --force, bundle install --force но он все еще устанавливал версию mysql2 версии 0.5.x только для того, чтобы вручную установить gem mysql2 версии 0.4.10, используя следующую команду

gem install mysql2 -v 0.4.10

но теперь он дает следующую ошибку

        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)
Теги:
mongify

2 ответа

0

Наконец, он разрешен. это проблема с рубиновой версией и 32-разрядными библиотеками. ruby 2.3 был надлежащим образом протестирован и отлично работает с драгоценным камнем. Я использовал последнюю версию ruby и был проблемой.

0

Сообщение об ошибке вводит в заблуждение: вы используете версию драгоценного камня mysql2 которая слишком новая для Active Record 4.2.10 (поддерживается последняя версия mongify).

Самое простое решение - явно использовать более старую версию mysql2, включив ограничение версии в запись Gemfile:

gem "mysql2", "< 0.5"
  • 0
    спасибо @matthewd. я обновил ответ в соответствии с вашим предложением. все еще получаю новую ошибку. пожалуйста предложите
  • 0
    Изменения, которые вы описываете, не соответствуют вышеперечисленным. Вам нужно добавить строку, которую я показал, в файл с именем Gemfile .
Показать ещё 6 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню