iroddis / asdf-mysql

A MySQL Plugin for asdf
GNU General Public License v2.0
19 stars 8 forks source link

Issue on M1 MacOS version 12.2.1 (21D62) #26

Closed Stratus3D closed 2 years ago

Stratus3D commented 2 years ago
mysql_install_db --datadir=$HOME/mysql                             
/Users/~/.asdf/lib/commands/command-exec.bash: line 28: /Users/~/.asdf/installs/mysql/5.7.38/bin/mysql_install_db: cannot execute binary file
/Users/~/.asdf/lib/commands/command-exec.bash: line 28: /Users/~/.asdf/installs/mysql/5.7.38/bin/mysql_install_db: Undefined error: 0

I tried executing /Users/~/.asdf/installs/mysql/5.7.38/bin/mysql_install_db directly but got the same error.

Output from asdf info:

asdf info
OS:
Darwin m1mbp 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

SHELL:
zsh 5.8 (x86_64-apple-darwin21.0)

ASDF VERSION:
v0.10.2-7e7a1fa

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/Users/~/.asdf

ASDF INSTALLED PLUGINS:
clojure                      https://github.com/halcyon/asdf-clojure.git master 0b1b2bb
elasticsearch                https://github.com/lowski/asdf-elasticsearch.git master 543f0b5
elixir                       https://github.com/asdf-vm/asdf-elixir.git master d08f506
erlang                       https://github.com/asdf-vm/asdf-erlang.git master 98139db
lua                          https://github.com/Stratus3D/asdf-lua.git master d99f76c
mysql                        git@github.com:iroddis/asdf-mysql.git master a5bde02
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master b2d06a7
postgres                     https://github.com/smashedtoatoms/asdf-postgres.git master ce9d3c6
python                       https://github.com/danhper/asdf-python.git master 57ef777
rebar                        https://github.com/Stratus3D/asdf-rebar.git master a556d0c
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 36117f5
yarn                         https://github.com/twuni/asdf-yarn.git main 376c540

Any idea what might be causing this?

iroddis commented 2 years ago

That's a bug. The script uses pre-built binaries where possible, and it's downloaded one that's not compatible with M1.

M1 (arm64) binaries are only available from 8.0.26 and later, but that check isn't applied properly. I'll fix it now, but if you require an earlier MySQL, it'll need to be built from scratch. I'll work on adding support for that.

Stratus3D commented 2 years ago

Thanks for the quick response. Getting the tools I need setup on this M1 Mac has turned into much more hassle than I expected. I'd love to have this plugin support Arm64 but I'm going to explore other methods for install MySQL 5.7 on this machine. Thanks!

iroddis commented 2 years ago

No problem! Welcome to M1 land; I just switched over myself.

The fix for the supported pre-built binaries has been pushed, but it looks like building from source is non-trivial. It's not a rabbit hole I want to run down at the moment, but if anyone out there looking at this issue wants to submit a PR, I'd be happy to merge it.

Homebrew has a mysql@5.7 formula, but it doesn't allow you to choose specific versions.

bskinner commented 2 years ago

I'm not sure this is isolated to being an Apple Silicon problem. I'm running into the same issue on an x86-64 2018 Mac Mini running macOS 12.4. It looks like the plugin is installing the Linux binaries as

file ${HOME}/.asdf/installs/mysql/5.7.38/bin/mysql

is reporting the type as

ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=2a249cd436a903acbfe7631581e738b69f5e1c9f, with debug_info, not stripped

If I install the mysql@5.7 formula using brew, and check the type of the mysql binary (file /usr/local/opt/mysql-client@5.7/bin/mysql), I get

/usr/local/opt/mysql-client@5.7/bin/mysql: Mach-O 64-bit executable x86_64
iroddis commented 2 years ago

That's really strange. I don't have an Intel Mac to test on. Can you send me the output of the following commands, please?

ProteanDev commented 2 years ago

Hi, I am having the same issue with Intel MacOS x64 bit and the commands outputs these: uname -s Darwin uname -m x86_64

However I notice this is only happening on MySQL 5.7 installation

iroddis commented 2 years ago

Yup, I see the issue. There are no binary releases for macs prior to 8.0.27. Building from source seems to be problematic, and typical of MySQL there's no solution or easily applied work around.

I've updated the plugin to throw an error when trying to install an earlier version on OSX.

If someone would like to submit a PR to support builds, I've started the work on the osx_build branch, but got stuck on the above bug. The section of code that needs work is install:95.

iroddis commented 2 years ago

After commit d2ed9cb, this seems to be working again. The M1/M2 macs can run amd64 binaries, so the new code will install arm64 if it's available, otherwise it will install amd64.