It was unclear to me that I explicitly needed Elasticsearch in order for certain tests to run locally. We should specify that in the docs. Also added a note about installing `wget`, which is required to install Elasticsearch in our docs.
6.9 KiB
| title |
|---|
| macOS |
Installing DEV on macOS
Installing prerequisites
Ruby
- If you don't already have a Ruby version manager, we highly recommend rbenv. Please follow their installation guide.
- With the Ruby version manager, install the Ruby version listed on our badge.
(i.e. with rbenv:
rbenv install 2.6.5)
Yarn
Please refer to their installation guide.
PostgreSQL
DEV requires PostgreSQL version 9.4 or higher. The easiest way to get started is to use Postgres.app. Alternatively, check out the official PostgreSQL site for more installation options.
For additional configuration options, check our PostgreSQL setup guide.
ImageMagick
DEV uses ImageMagick to manipulate images on upload.
You can install ImageMagick with brew install imagemagick.
Redis
DEV requires Redis version 4.0 or higher.
We recommend using Homebrew:
brew install redis
you can follow the post installation instructions, we recommend using
brew services to start Redis in the background:
brew services start redis
You can test if it's up and running by issuing the following command:
redis-cli ping
Elasticsearch
DEV requires Elasticsearch version 7 or higher.
We recommend installing from archive on Mac. The following directions were
taken from the Elasticsearch docs themselves,
so check those out if you run into any issues or want further information. Make
sure to download the OSS version of Elasticsearch, elasticsearch-oss.
Please note that you will need wget in order to proceed with this installation
(brew install wget).
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.5.2-darwin-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-7.5.2-darwin-x86_64.tar.gz.sha512
shasum -a 512 -c elasticsearch-oss-7.5.2-darwin-x86_64.tar.gz.sha512
tar -xzf elasticsearch-oss-7.5.2-darwin-x86_64.tar.gz
cd elasticsearch-7.5.2/
To start elasticsearch:
./bin/elasticsearch
To start elasticsearch as a daemonized process:
./bin/elasticsearch -d
Installing DEV
-
Fork DEV's repository, e.g. https://github.com/thepracticaldev/dev.to/fork
-
Clone your forked repository in one of two ways:
- e.g. with HTTPS:
git clone https://github.com/<your-username>/dev.to.git - e.g. with SSH:
git clone git@github.com:<your-username>/dev.to.git
- e.g. with HTTPS:
-
Install bundler with
gem install bundler -
Set up your environment variables/secrets
-
Take a look at
Envfileto see all theENVvariables we use and the fake default provided for any missing keys. -
The backend guide will show you how to get free API keys for additional services that may be required to run certain parts of the app.
-
For any key that you wish to enter/replace, follow the steps below. At a minimum, you'll need to get your own free Algolia credentials to get your development environment running.
- Create
config/application.ymlby copying from the provided template (i.e. with bash:cp config/sample_application.yml config/application.yml). This is a personal file that is ignored in git. - Obtain the development variable and apply the key you wish to enter/replace. i.e.:
GITHUB_KEY: "SOME_REAL_SECURE_KEY_HERE" GITHUB_SECRET: "ANOTHER_REAL_SECURE_KEY_HERE" - Create
-
If you are missing
ENVvariables on bootup, the envied gem will alert you with messages similar to'error_on_missing_variables!': The following environment variables should be set: A_MISSING_KEY.. -
You do not need "real" keys for basic development. Some features require certain keys, so you may be able to add them as you go.
-
-
Run
bin/setup
Possible error messages
Error:
__NSPlaceholderDate initialize] may have been in progress in another thread when fork() was called
Solution: Run the command export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
(or set -x OBJC_DISABLE_INITIALIZE_FORK_SAFETY YES in fish shell)
Error: User does not have CONNECT privilege.
Solution: Complete the steps outlined in the PostgreSQL setup guide.
Error:
rbenv: version '<version number>' is not installed (set by /Path/To/Local/Repository/.ruby-version)
Solution: Run the command rbenv install <version number>
Error: ruby-build: definition not found: <version number> when rbenv was
installed via brew.
ruby-build: definition not found: <version number>
See all available versions with `rbenv install --list`.
If the version you need is missing, try upgrading ruby-build:
Solution: Run the following to update ruby-build,
brew update && brew upgrade ruby-build. After that, rerun
rbenv install <version number> and that version will get installed.
Error:
== Preparing database ==
Sorry, you can't use byebug without Readline. To solve this, you need to
rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
install libreadline-dev` and then reinstall your Ruby.
rails aborted!
LoadError: dlopen(/Users/<username>/.rbenv/versions/2.6.5/lib/ruby/2.6.0/x86_64-darwin18/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.<some version number>.dylib
Solution: Run
ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.<some version number>.dylib
from the command line then run bin/setup again. You may have a different
version of libreadline, so replace <some version number> with the version that
errored.
Error:
PG::Error: ERROR: invalid value for parameter "TimeZone": "UTC"
: SET time zone 'UTC'
Solution: Restart your Postgres.app, or, if you installed PostgreSQL with Homebrew, restart with:
brew services restart postgresql
If that doesn't work, reboot your Mac.
Error:
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
[...]
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Solution: You may encounter this when installing PostgreSQL with the
Postgres.app. Try restarting the app and reinitializing the database. If that
doesn't work, install PostgreSQL with Homebrew instead:
brew install postgresql
If you encountered any errors that you subsequently resolved, please consider updating this section with your errors and their solutions.