Skip to content

Instantly share code, notes, and snippets.

@gyndav
Last active February 2, 2023 19:27
Show Gist options
  • Save gyndav/a2d55adc4daf66c7d133ce3ba25fb342 to your computer and use it in GitHub Desktop.
Save gyndav/a2d55adc4daf66c7d133ce3ba25fb342 to your computer and use it in GitHub Desktop.
Apple M1
# Ruby 3.1.3
```shell
brew install bcrypt
asdf install ruby 3.1.3
cd $UNIVERSEROOT/src/services/legacy
gem install bundler -v 2.4.3
# bundle config build.pg --with-cflags="-Wno-error=implicit-function-declaration"
bundle config --local build.nokogiri --use-system-libraries
bundle --path vendor/bundle
```

Things I wish I knew when setupping my Apple M1

Homebrew

prefix is now /opt/homebrew as opposed to Intel using $(brew --prefix) was slowing down my terminal to a degree, hence a static path approach end up loading both as still having both styles

# Zsh search path for executable
path=(
  /opt/homebrew/{bin,sbin}
	/usr/local/{bin,sbin}
	$path
)

asdf

ruby on on Apple M1

A bunch of binaries requires manual bindings as below:

brew install libffi libyaml zlib readline

export optflags="-Wno-error=implicit-function-declaration"
export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"

☁  ~  export optflags="-Wno-error=implicit-function-declaration"; export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"; export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"; export PKG_CONFIG_PATH="/opt/homebrew/opt/libffi/lib/pkgconfig"; export CONFIGURE_OPTS="--build aarch64-apple-darwin20"; asdf install ruby 2.6.0


export RUBY_CONFIGURE_OPTS="--with-zlib-dir=/opt/homebrew/opt/zlib --with-openssl-dir=/opt/homebrew/opt/openssl@1.1 --with-readline-dir=/opt/homebrew/opt/readline --with-libyaml-dir=/opt/homebrew/opt/libyaml"
export RUBY_CFLAGS="-Wno-error=implicit-function-declaration"
export CONFIGURE_OPTS="--build aarch64-apple-darwin20"
asdf install ruby 2.6.6

Now installing nokogiri requires as usual native but ffi is causing issues bundle config build.nokogiri --use-system-librarie

gem install ffi:1.14.2 -- --enable-libffi-alloc works but we are currently using 1.9.18 🤦 I fixed it since 👍🏼

References

nodejs on Apple M1

Versions < v14 aren't published for Apple M1 but are as of v16? Using Rosetta otherwise:

arch -x86_64 asdf install nodejs 14.17.5
npm install --target_arch=x64

References

https://edipox.medium.com/error-installing-pg-gem-in-macos-catalina-b1a2ba6b6264 https://stackoverflow.com/questions/36455625/postgresql-gem-install-pg-0-18-4-passes-bundle-install-fails

Ruby 2.7.6

brew install bcrypt

OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration asdf install ruby 2.7.6
cd $UNIVERSEROOT/src/services/legacy
gem install bundler -v=1.17.3
bundle config build.pg --with-cflags="-Wno-error=implicit-function-declaration"
bundle config --local build.nokogiri --use-system-libraries
bundle --path vendor/bundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment