Home>

The code below is the description when the rails db:create command is executed on the terminal.

rooter:portfolio apple$rails db:create
rails aborted!
LoadError: dlopen(/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 0x0009): dependent dylib'/usr/local/opt/[email protected]/lib/ libmysqlclient.20.dylib' not found for'/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle'-/Library/Ruby/Gems/2.6.0/gems /mysql2-0.5.3/lib/mysql2/mysql2.bundle
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<main>'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'/Users/apple/create/portfolio/config/application.rb:7:in `<main>'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49:in `require_relative'
/Users/apple/create/portfolio/Rakefile:4:in `<main>'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:318:in `block in load'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:318:in `load'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:22:in `block in perform'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
/Library/Ruby/Gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<main>'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'/Library/Ruby/Gems/2.6.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/Library/Ruby/Gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/Users/apple/create/portfolio/bin/rails:9:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/apple/create/portfolio/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)


Looking at this sentence, the contents of the dependency were displayed, so I wonder if the reason is that the version of MYsql in the gem of the application I am creating this time is different from the version of MYsql set by the Linux command. think.
The version of Mysql created this time has gem'mysql2' set, and mysql is used in the Linux command.

Also, I wonder if the path setting may be the cause, I set the arbitrary path before myself, and Mysql5.7 in the following display is not set, so,

rooter:portfolio apple$echo $PATH
/usr/local/opt/[email protected]/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/[email protected]/bin:/ usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/usr /local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Please professor,

  • Answer # 1

    In this case it is written first
    '/usr/local/opt/[email protected]/lib/libmysqlclient.20.dylib' not found
    I'm getting an error that dylib is missing to run mysql2.
    Since mysql2 is a gem, it doesn't matter that the version notation is different from mysql. Is it different from when you gem installed mysql2 and the version of mysql?

    I think that you can get more appropriate advice from people by writing the OS and other environments.
    It says Linux, but it's not a Linux dir name, so... Is it a Mac?