Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/doug-oliveira/apple-arm-rails-environment-setup

Setup Instructions for Rails environment on Mac M1/M2 🍎
https://github.com/doug-oliveira/apple-arm-rails-environment-setup

m1-mac m2 rails ruby rubyonrails setup

Last synced: 18 days ago
JSON representation

Setup Instructions for Rails environment on Mac M1/M2 🍎

Awesome Lists containing this project

README

        

# Mac Arm setup

- Add code bellow to .zshrc

```
export PATH=$HOME/bin:/usr/local/bin:$PATH

# for intel x86_64 brew
alias axbrew='arch -x86_64 /usr/local/homebrew/bin/brew'

# Homebrew
export PATH=$HOME/bin:/usr/local/homebrew/bin:$PATH
export PATH=$HOME/bin:/usr/local/homebrew/sbin:$PATH

# openssl
export PATH="/usr/local/homebrew/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/usr/local/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/usr/local/homebrew/opt/[email protected]/lib/pkgconfig"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/homebrew/opt/[email protected]"

# rbenv
export RBENV_ROOT=$(axbrew --prefix rbenv)
export PATH=$RBENV_ROOT/bin:$PATH
eval "$(arch -x86_64 rbenv init -)"
export PATH="/usr/local/homebrew/opt/postgresql@10/bin:$PATH"
```

- Install brew compatible with x86 version
Reference post ->
https://medium.com/mkdir-awesome/how-to-install-x86-64-homebrew-packages-on-apple-m1-macbook-54ba295230f
------
## Rbenv install
```
axbrew install rbenv
```
## Openssl Setup

- Install [email protected] via brew

```
axbrew install rbenv/tap/[email protected]
rbenv rehash
```
- Check installation
```
echo $(axbrew --prefix [email protected])
/usr/local/homebrew/opt/[email protected]
```
---
- Install command line tols for xCode
https://developer.apple.com/download/all/
```
axbrew install readline
# check installation
echo $(axbrew --prefix readline)
/usr/local/homebrew/opt/readline
```

```
axbrew install ruby-build
axbrew install libyaml
axbrew install gmp
axbrew install zlib
```
- Install Ruby 💎

```
RUBY_CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(axbrew --prefix [email protected])" arch -x86_64 rbenv install 2.1.3
```
```
rbenv global 2.1.3
```

- Check bundler version of the project.
```
gem install bundler -v 1.13.0
```
-----
## Install Redis
```
axbrew install redis
axbrew services start redis
```
## Postgresql 🐘
```
axbrew install postgresql@10
```

```
echo 'export PATH="/usr/local/homebrew/opt/postgresql@10/bin:$PATH"' >> ~/.zshrc
```

```
axbrew services list
```

```
axbrew services start postgresql@10
```
```
axbrew install libpq
```

```
echo $(axbrew --prefix libpq)
```

```
ARCHFLAGS="-arch x86_64" sudo gem install pg -v 0.17.0 -- --with-pg-config=/usr/local/homebrew/opt/postgresql@10/bin/pg_config --with-pq-dir="/usr/local/homebrew/opt/libpq"
```
----
## Rubyracer (older rails projects)
```
axbrew install v8-315
```
```
gem install therubyracer -v '0.12.2' -- --with-v8-dir=/usr/local/homebrew/opt/[email protected]
```
- Therubyracer gem adds a JavascriptRuntime to the rails project, which is mainly used to precompile assets. however, it currently depends on lib v8 to work, but its installation has been discontinued because it depends on phyton 2.

A workaround for this problem was to comment out therubyracer in the project's Gemfile and add JavascriptRuntime via node.

Reference post -> https://www.rubyonmac.dev/how-to-install-therubyracer-on-m1-m2-apple-silicon-mac
```
axbrew install nvm
nvm install version
```
```
npm install
```
----
The End! 👏👏👏