Skip to content

Instantly share code, notes, and snippets.

@Voronoff
Last active June 24, 2017 20:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Voronoff/2f9dc20aba2190eedc15ddc9e0c86c3f to your computer and use it in GitHub Desktop.
Save Voronoff/2f9dc20aba2190eedc15ddc9e0c86c3f to your computer and use it in GitHub Desktop.
Installing an Ubuntu VM managed with Vagrant for Crystal development on Windows

Note: Vagrant does not like spaces in Windows directory paths.

1. Install virtualbox

http://download.virtualbox.org/virtualbox/5.1.22/VirtualBox-5.1.22-115126-Win.exe from https://www.virtualbox.org/wiki/Downloads

2. Install Vagrant

https://releases.hashicorp.com/vagrant/1.9.4/vagrant_1.9.4.msi from https://www.vagrantup.com/downloads.html

Restart your computer.

3. Install git

https://git-scm.com/download/win

4. Add box

using Git Bash

vagrant box add davidallen/xenial-crystal

5. Set up the folder

mkdir xenial_crystal
cd xenial_crystal
vagrant init xenial-crystal

6. Edit Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.define "xenial-crystal" do |c|
    c.vm.box = "davidallen/xenial-crystal"
    #Make apt-get upgrade completely silent so it doesn't get stuck on selecting a drive for GRUB
    c.vm.provision :shell, inline: %(
      sudo apt-get -y update
      DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
    )
  end
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    vb.cpus = 2
    vb.memory = "1024"
  end

end

7. Create and log into the VM

vagrant up
vagrant ssh

8. Install a browser

Firefox:
sudo apt-get install firefox
Chrome:
cd /tmp
wget https://dl.google.com/linux/direct/google-chrome-stable_curr‌​ent_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get -f install

9. Open the gui

startxfce4 

or

  startxfce4&

makes it verbose

10. Use it!

The terminal comnmand to open an interactive crystal console is icr

To start a fresh Crystal project

crystal init app hello_world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment