Getting Lucky With Crystal in Homestead
I’m going to open this post with an apology for anyone who’s corporate firewall gets triggered by this URL, but I just couldn’t resist the title.
A few days ago a random internet stranger (Rid) showed up in the Larachat Slack #homestead-dev room. This is about the best real time chat support for Homestead. Rid proceeds to ask about building something like Homestead for the framework he was working on called Lucky for the Crystal programming language. After we chatted about Vagrant and Docker I mentioned that it wouldn’t be too difficult to get supported in Homestead. Rid shared some helpful URLs and I was off to the races.
The next base box version of Homestead will have this preinstalled, but if you want to start getting Lucky with Crystal in Homestead right away…
Make sure you’re running Homestead v7.5.0.
In your “Homestead.yaml” file add a folder and site mapping for your Crystal or Lucky project:
folders: - map: ~/sample to: /home/vagrant/sample sites: - map: crystal.test to: /home/vagrant/sample/ type: "crystal"
Open up your “after.sh” file in Homestead and add the following lines:
sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys 09617FD37CC06B54 sudo echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list sudo apt-get update sudo apt-get install -y crystal libssl1.0-dev wget https://github.com/luckyframework/lucky_cli/archive/v0.10.0-rc3.tar.gz tar -zxvf v0.10.0-rc3.tar.gz cd lucky_cli-0.10.0-rc3 crystal deps crystal build src/lucky.cr --release --no-debug sudo mv lucky /usr/local/bin/. cd rm -rf lucky_cli-0.10.0-rc3 rm -rf v0.10.0-rc3.tar.gz curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
Then run “vagrant provision”. If you run into errors start fresh by running “vagrant destroy && vagrant up”.