You will need Crystal installed for local development. Make sure to install all of Crystal’s dependencies for your system.
Lucky supports Crystal >= 1.10.0
, <= 1.12.1
Follow the Installing Crystal instructions page for your specific system.
crystal -v
Should return between 1.10.0
and 1.12.1
Installation instructions from the Homebrew website
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Installation instructions from the Homebrew website
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install openssl
Add the following line to your shell configuration file. This will let Crystal know where to find OpenSSL.
You can run
echo $SHELL
in your terminal if you’re not sure whether you are using ZSH, Bash or Fish.
For ZSH (the default as of macOS Catalina):
macOS (Apple Silicon)
echo 'export PKG_CONFIG_PATH=/opt/homebrew/opt/openssl/lib/pkgconfig' >>~/.zshrc
macOS (Intel)
echo 'export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig' >>~/.zshrc
For Bash:
macOS (Apple Silicon)
echo 'export PKG_CONFIG_PATH=/opt/homebrew/opt/openssl/lib/pkgconfig' >>~/.bash_profile
macOS (Intel)
echo 'export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig' >>~/.bash_profile
For Fish:
macOS (Apple Silicon)
echo 'set -gx PKG_CONFIG_PATH /opt/homebrew/opt/openssl/lib/pkgconfig' >> ~/.config/fish/config.fish
macOS (Intel)
echo 'set -gx PKG_CONFIG_PATH /usr/local/opt/openssl/lib/pkgconfig' >> ~/.config/fish/config.fish
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.
These are additional dependencies you will need in order to boot your Lucky application.
apt-get install libc6-dev libevent-dev libpcre2-dev libpng-dev libssl-dev libyaml-dev zlib1g-dev
apt-get install libc6-dev libevent-dev libpcre2-dev libpcre3-dev libpng-dev libssl-dev libyaml-dev zlib1g-dev
dnf install glibc-devel libevent-devel pcre2-devel openssl-devel libyaml-devel zlib-devel libpng-devel
Please see the requirements to install Crystal on Windows first.
If you’re using Scoop on Windows, you can install the Lucky CLI using our Scoop package.
scoop bucket add lucky https://github.com/luckyframework/scoop-bucket
scoop install lucky
Once the required dependencies above are installed, set up Lucky for your system.
brew install luckyframework/homebrew-lucky/lucky
Let’s make sure the Lucky CLI installed correctly:
lucky -v
This should return 1.2.0
git clone https://github.com/luckyframework/lucky_cli
cd lucky_cli
git checkout v1.2.0
We call packages/libraries in Crystal “shards”. Let’s install the shards that Lucky CLI needs:
shards install --without-development
shards build --production
This will let you use lucky
from the command line.
cp bin/lucky /usr/local/bin
Or anywhere else you deem fit
Let’s make sure the Lucky CLI installed correctly:
lucky -v
This should return 1.2.0
You can skip this if you don’t need database. Many sites (including this one) have no need for a database. In some cases, your data comes from a 3rd party API, or maybe you need a custom database engine other than PostgreSQL.
You can skip this if you plan to use Lucky with a Postgres docker container. Please note that a docker-compose configuration (with Postgres included) is provided out of the box when you start your project with
lucky init
.
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 pg_hba.conf
file is updated.
We recommend adding this entry right after the postgres
user entry:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
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 build APIs.
node -v
yarn -v
Node should return greater than v11. Yarn should return greater than 1.x.
You can skip this if you only plan to only build APIs.
Lucky uses Chromedriver for Testing HTML. The Chromedriver utility will be installed for you once you start running your tests; however, it requires the Chrome browser to be installed on your machine. If you don’t already have it installed, you can install it directly from Google.
You can also use an alternative chrome-like browser (e.g. Brave, Edge, etc…). See the Flow guides for customization options.