Diesel trying to load libmysqlclient.23.dylib instead of libmysqlclient.21.dylib
I'm trying to run database commands from diesel, and I get the following error on the same commands.
dyld[4867]: Library not loaded: /opt/homebrew/opt/mysql/lib/libmysqlclient.23.dylib
Referenced from: <3B1A2FEC-563A-3887-B019-710B9BD71A9B> /Users/vagnerwentz/.cargo/bin/diesel
Reason: tried: '/opt/homebrew/opt/mysql/lib/libmysqlclient.23.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/mysql/lib/libmysqlclient.23 .dylib' (no such file), '/opt/homebrew/opt/mysql/lib/libmysqlclient.23.dylib' (no such file)
[1] 4867 abort diesel migration list
I noticed that when I do a ls /opt/homebrew/opt/mysql-client@8.0/lib
and also for ls /opt/homebrew/opt/mysql@8.0/lib
I see that I have the versions with the ending 21.dylib
instead of 23.dylib
as in the error.
I have already uninstalled both mysql and mysql-client, and I have already installed libmysqclient from the MySQL website for version 8 on ARM64 architecture and I still get the same error.
Answers
It seems like the diesel
CLI tool is looking for a specific version of the libmysqlclient
library (version 23) which is not available on your system. Since you have installed version 21 of the library, it's unable to find it and throws an error.
To resolve this issue, you can try one of the following approaches:
- Symlink the existing library: If you have version 21 of
libmysqlclient
installed anddiesel
requires version 23, you can create a symbolic link to make it appear as version 23. You can do this by running the following command:
ln -s /opt/homebrew/opt/mysql-client@8.0/lib/libmysqlclient.21.dylib /opt/homebrew/opt/mysql-client@8.0/lib/libmysqlclient.23.dylib
This command creates a symbolic link named libmysqlclient.23.dylib
that points to libmysqlclient.21.dylib
. Make sure to replace the paths with the correct ones on your system.
-
Reinstall diesel with correct dependencies: If
diesel
explicitly requires version 23 oflibmysqlclient
, you may need to reinstalldiesel
or its dependencies to ensure compatibility with the available version of the library. -
Check for environment variables: Sometimes, environment variables like
LD_LIBRARY_PATH
orDYLD_LIBRARY_PATH
can influence which library is loaded. Ensure that these variables are not pointing to an incorrect location.
After trying one of these approaches, you can attempt to run diesel
again and see if the issue is resolved. If you continue to encounter issues, you may need to further troubleshoot or seek assistance from the diesel
community or support channels.