Lucky Logo

# MacOS requirements

# 1. Install Homebrew

Installation instructions from the Homebrew website

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

# 2. Install OpenSSL

brew install openssl

# 3. Configure SSL for Crystal

You’ll need to add tell Crystal how to find OpenSSL by adding an export to your ~/.bash_profile or ~/.zshrc.

You can run echo $SHELL in your terminal if you’re not sure whether you are using ZSH or Bash.

For ZSH (the default as of macOS Catalina):

echo 'export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig' >>~/.zshrc

For Bash:

echo 'export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig' >>~/.bash_profile

If you get an error like this: “Package libssl/libcrypto was not found in the pkg-config search path” then be sure to run this step so that Crystal knows where OpenSSL is located.

# Linux requirements

# Debian (Ubuntu should be similar)

apt-get install libc6-dev libevent-dev libpcre2-dev libpng-dev libssl1.0-dev libyaml-dev zlib1g-dev

# Fedora (28)

dnf install glibc-devel libevent-devel pcre2-devel openssl-devel libyaml-devel zlib-devel libpng-devel

# Crystal v0.35.1

# 1. Install Crystal

Using asdf version manager:

We recommend using a version manager to make sure the correct version of Crystal is used with Lucky.

asdf plugin-add crystal https://github.com/asdf-community/asdf-crystal.git
  • Set up asdf so it uses the .crystal-version file to determine which version to use:
echo "legacy_version_file = yes" >>~/.asdfrc
  • Install Crystal with asdf.
asdf install crystal 0.35.1
  • See which version of crystal was installed
asdf list crystal
  • Set global version of crystal to that version (0.35.1 is used as an example)
asdf global crystal 0.35.1

Or, install Crystal without a version manager

If you can’t get asdf installed or don’t want to use a version manager, you can install Crystal without a version manager.

# 2. Check installation

crystal -v

Should return at least 0.35.1

# Install Lucky CLI on macOS

Once the required dependencies above are installed, set up Lucky for your system.

# 1. Add the Lucky tap to Homebrew

brew tap luckyframework/homebrew-lucky

# 2. Install the Lucky CLI with Homebrew

brew install lucky

# 3. Check installation

Let’s make sure the Lucky CLI installed correctly:

lucky -v

This should return 0.24.0

# Install Lucky CLI on Linux

# 1. Clone the CLI repo

git clone https://github.com/luckyframework/lucky_cli

# 2. Change into the newly cloned directory

cd lucky_cli

# 3. Check out the latest released version

git checkout v0.24.0

# 4. Install shards

We call packages/libraries in Crystal “shards”. Let’s install the shards that Lucky CLI needs:

shards install

# 5. Build the CLI

crystal build src/lucky.cr

# 6. Move the generated binary to your path

This will let you use lucky from the command line.

mv lucky /usr/local/bin

# 7. Check installation

Let’s make sure the Lucky CLI installed correctly:

lucky -v

This should return 0.24.0

# Process manager

Lucky uses a process manager to watch assets and start the server in development.

Install one of these process managers: Overmind (recommended), Heroku CLI (great if you plan to use Heroku to deploy), forego, or foreman.

By default Lucky creates a Procfile.dev that defines what processes should be started when running lucky dev. You can modify the Procfile.dev to start other processes like running background jobs.

# Postgres database

# 1. Install Postgres

Lucky uses Postgres for its database. Install Postgres (macOS/Others)

# 1a. (macOS only) Ensure Postgres CLI tools installed

If you’re using Postgres.app on macOS make sure Postgres CLI tools are installed

sudo mkdir -p /etc/paths.d &&
  echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp

There are other installation methods available in Postgres CLI tools docs

# 1b. (Linux only) Password-less logins for local development

Homebrew installed PostgreSQL on macOS are configured by default to allow password-less logins. But for Linux, if you wish to use PostgreSQL without a password, you’ll need to ensure your user is added to the pg_hba.conf file with trust method specified. We recommend adding this entry right after the postgres user entry:

local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             your_username   127.0.0.1/32            trust  # Add this line

your_username is the local user you’re logging into the DBMS with. Change as appropriate.

Visit PostgreSQL Authentication Methods to learn more more about available authentication methods and how to configure them for PostgreSQL.

Restart the postgresql service to activate the configuration changes.

# 2. Ensure Postgres CLI tools installed

First open a new session to reload your terminal, then:

psql --version

Should return psql (PostgreSQL) 10.x or higher.

# Chromedriver (optional)

You can skip this if you only plan to only build APIs.

If you want to test your frontend using LuckyFlow you will need Chromedriver, see the Testing HTML and Interactivity guide for details and installation.

# Node and Yarn (optional)

You can skip this if you only plan to only build APIs.

# 1. Install

# 2. Check installation

node -v
yarn -v

Node should return greater than v11. Yarn should return greater than 1.x.

See a problem? Have an idea for improvement? Edit this page on GitHub