Skip to content

Commit

Permalink
removed asdf not to overcomplicate things and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
jarodtaylor committed Sep 17, 2024
1 parent e26b50d commit d633f80
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 96 deletions.
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.8.0
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.4
2 changes: 0 additions & 2 deletions .tool-versions

This file was deleted.

123 changes: 29 additions & 94 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ This is currently using Rails 7.2.
## Prerequisites

The local develpment setup documents assume you're using a Mac and using [Homebrew](http://brew.sh). We'll be using a couple of tools to setup your environment. You can skip this section and install the dependencies in your own way. That said, the following things will be required.

- Ruby 3.1+
- Node 18 (LTS) or newer
- Yarn 1.x (classic)
Expand All @@ -17,122 +15,59 @@ The local develpment setup documents assume you're using a Mac and using [Homebr

## Local Development Setup (optional)

If you already meet the requirements above, you can jump straigh to the Getting Started section.

<details>

<summary>Install Ruby and NodeJS with asdf</summary>

### Install asdf (optional)

> [!NOTE]
> This project leverages [.tool-versions](https://asdf-vm.com/manage/configuration.html#tool-versions) for managing Ruby and NodeJS versions. If you'd prefer to use `rbenv` and `rvm`, you can skip this step and install the appropriate Ruby and NodeJS versions on your own, just make sure you install the right versions shown in [this repo's .tool-versions](https://github.com/jarodtaylor/ror-vite-tailwind/blob/main/.tool-versions).
There are homebrew versions of asdf but it's highly recommended to use their [official installation method](https://asdf-vm.com/guide/getting-started.html#official-download).

```
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
```

You'll need to update your `.zshrc` as described on the [asdf docs](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf)). Most Mac users are using zsh so you'd want to read the directions under the ZSH & Git section.

```
. "$HOME/.asdf/asdf.sh"
fpath=(${ASDF_DIR}/completions $fpath)
autoload -Uz compinit && compinit
```

> [!WARNING]
> if you are using a custom compinit setup, make sure you read the directions for ZSH & Git on [asdf the installation docs](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf).
#### Install asdf plugins
This will allow us to add different versions of Ruby and Node in both your global and local project `.tool-version` files.
<summary>Install Dependencies</summary>

##### Add Ruby plugin
```
asdf plugin add ruby
```

##### Add NodeJS plugin
```
asdf plugin add nodejs
```
### Ruby
```
brew install ruby
```

### Install Ruby and NodeJS versions
Now that we have asdf setup with both the Ruby and NodeJS plugins, you can install the appropriate versions.
### Node
```
brew install node
```

#### Ruby
```
asdf install ruby latest
```
> [!NOTE]
> If you run into an issue regarding ruby-build and `libyaml` you may need to install it using `brew install libyaml`.
### Postgresql
```
brew install postgresql@15
```

#### NodeJS
```
asdf install nodejs latest
```
### Redis
```
brew install
```

### Set your global .tool-versions to use Ruby and NodeJS
#### Ruby
```
asdf global ruby latest
```
#### NodeJS
```
asdf global nodejs latest
```
### Yarn
You can install Yarn with homebrew, but it's not necessary. Just install it with npm.
```
npm install --global yarn
```

</details>

<details>

<summary>Make sure Postgres & Redis are running</summary>

### Get Postgres and Redis running
If you don't already have postgres and redis installed, install them with homebrew.
```
brew install postgresql@15 redis
```
### Postgresql

Then you can start the services
```
brew services start postgresql@15 && brew services start redis
brew services start postgresql@15
```

</details>

<details>

<summary>Install Yarn</summary>
### Redis

Assuming you already have NodeJS installed and the latest version set up globally, add the yarn package.
```
npm install --global yarn
brew services start redis
```

</details>

## Getting started
> [!WARNING]
> If you followed the local development setup and installed `ruby` with `asdf` and Postgresql with homebrew, you will get an error, because the `pg` gem is trying to compile native extensions but can't find the necessary PostgreSQL client libraries or `pg_config`. The issue is caused by `asdf` not being able to locate the `pg_config` from your Homebrew installation.
To fix this you need to install `libpq` with homebrew and then link the `pg_config` to your environment.
```
brew install libpq
```
Two options for linking the `pg_config`.

#### Option one
```
brew link --force libpq
```

#### Option two (recommended)
For a more permanent fix, so this isn't seen for any other postgresql libs you may add, add the following to your `.zshrc` file.
```
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"
```


### bin/setup

Expand Down

0 comments on commit d633f80

Please sign in to comment.