Installation instructions from the Homebrew website
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install openssl
You’ll need to 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.
apt-get install libc6-dev libevent-dev libpcre2-dev libpng-dev libssl1.0-dev libyaml-dev zlib1g-dev
apt-get install libc6-dev libevent-dev libpcre2-dev libpcre3-dev libpng-dev libssl1.0-dev libyaml-dev zlib1g-dev
dnf install glibc-devel libevent-devel pcre2-devel openssl-devel libyaml-devel zlib-devel libpng-devel
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
asdf
so it uses the .crystal-version
file to determine which version to use:echo "legacy_version_file = yes" >>~/.asdfrc
asdf
.asdf install crystal 0.36.1
asdf list crystal
asdf global crystal 0.36.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.
crystal -v
Should return at least 0.36.1
Once the required dependencies above are installed, set up Lucky for your system.
brew tap luckyframework/homebrew-lucky
brew install lucky
Let’s make sure the Lucky CLI installed correctly:
lucky -v
This should return 0.26.0
git clone https://github.com/luckyframework/lucky_cli
cd lucky_cli
git checkout v0.26.0
We call packages/libraries in Crystal “shards”. Let’s install the shards that Lucky CLI needs:
shards install
crystal build src/lucky.cr
This will let you use lucky
from the command line.
mv lucky /usr/local/bin
Let’s make sure the Lucky CLI installed correctly:
lucky -v
This should return 0.26.0
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 runninglucky dev
. You can modify theProcfile.dev
to start other processes like running background jobs.
For WSL users on Windows, Overmind is not recommended due to compatibility issues.
Lucky uses Postgres for its database. Install Postgres (macOS/Others)
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
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.
First open a new session to reload your terminal, then:
psql --version
Should return psql (PostgreSQL) 10.x
or higher.
You can skip this if you only plan to only build APIs.
node -v
yarn -v
Node should return greater than v11. Yarn should return greater than 1.x.