rails on M2: dyld[...]: missing symbol called
Asked Answered
S

2

5

I upgraded my Rails project from 5 to 6 and now Rails commands throw this error on my M2 mac:

dyld[...]: missing symbol called

It looks like some sort of problem with Node and mysql gem. When I create new project with SQLite, everything runs fine:

% rbenv versions
* 3.1.2 
% rails -v                    
Rails 6.1.7.3
% rails new test
% rails s

But when I do the same with mysql db, the installation ends on webpacker install:

% rails new test2 -d mysql
...
Bundle complete! 17 Gemfile dependencies, 81 gems now installed.
  run  bundle binstubs bundler
  rails  webpacker:install
dyld[25919]: missing symbol called

I have the lastest mysql2 gem version:

gem "mysql2", '~> 0.5.5'

I tried all the other tricks that I found: reinstalling node, yarn, switch to x64 node version, removing node_modules.. all of it. No success so far

Swab answered 10/6, 2023 at 17:40 Comment(1)
This post has a great explanation of this common problem on M1, M2, or M3 Macs. rubyonmac.dev/…Outsell
S
10

Ok, I found a solution. It was indeed problem with mysql2 gem. Standard installation of this gem doesn't work for mysql installed by homebrew.

If you installed the gem previously and it causes problems, uninstall this specific version first:

gem uninstall mysql2 -v 0.5.5

Then install it again, but with these settings:

gem install mysql2 -v '0.5.5' -- --with-mysql-config=$(brew --prefix mysql)/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/include

Istead of 0.5.5, fill in the version of the gem you need to install. I used 0.5.5 as it's the latest version at this moment. "brew --prefix ..." will add paths to specific files automatically.

I realize this was very specific problem. Sadly, the "missing symbol called" could mean anything. If you see the same error, I would recommend finding a version of your app that works and comparing the differencies between them. It could mean trying it on a different machine, deleting some gems, trying different versions.. That should point you in the right direction.

Swab answered 12/6, 2023 at 13:56 Comment(2)
In case you installed specific version of mysql with homebrew, then don't forget to specify that in the command. For example, in case of [email protected] the command would be gem install mysql2 -v '0.5.5' -- --with-mysql-config=$(brew --prefix [email protected])/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/includeAccentor
I install mysql2 0.5.6 with above command but still failed to start application. gem install mysql2 -v '0.5.6' -- --with-mysql-config=$(brew --prefix [email protected])/bin/mysql_config --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/includeSaturday
I
0

I was also getting this error and was using pg gem (for postgresql).

Initially I was using an old version of the pg gem 1.1.4, so I:

  • Changed my gemfile from gem 'pg' ~> '1.14' to gem 'pg'
  • Uninstalled the gem gem uninstall pg
  • Deleted Gemfile.lock
  • Then reran bundle install

Now I got the migrations working fine. Hope it helps for others

Instep answered 4/3 at 1:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.