Skip to content

Instantly share code, notes, and snippets.

@gabrielhpugliese
Last active April 19, 2022 14:37
Show Gist options
  • Save gabrielhpugliese/5855677 to your computer and use it in GitHub Desktop.
Save gabrielhpugliese/5855677 to your computer and use it in GitHub Desktop.
Tutorial for running Meteor in Windows using Vagrant

Tutorial: Meteor in Windows using Vagrant

BEFORE YOU CONTINUE:

  • Now, Meteor runs in any Windows without any line of this tutorial. Just download the Meteor binary! Yay!!
  • mrt is no longer used with Meteor 1.0

These days some people were discussing at meteor-talk group about running Meteor at Windows and I’ve recommended them using Vagrant. It’s a very developer-friendly piece of software that creates a virtual machine (VM) which let you run any operating system wanted and connect to it without big efforts of configuration (just make the initial installation and you have it working).

Many packages (I've tested) for running Meteor+Vagrant fails because Meteor writes its mongodb file and also other files inside local build folder into a shared folder between the Windows host and the Linux guest, and it simply does not work. So I've put my brain to work and found a solution: do symlinks inside the VM (but do not use ln. Use mount so git can follow it). It’s covered on steps 8 to 15.

If you have no idea what I’m talking about, I’ve made a tutorial to install Ubuntu Precise x86 through Windows command-line with Meteor very simple to follow:

Requirements

Steps on Windows command-line:

  1. Go to Start Menu > Type cmd > SHIFT + ENTER (to login as Administrator)
  2. cd C:\path\to\your\vagrant+meteor\project\folder
  3. set PATH=%PATH%;C:\Program Files (x86)\Git\bin (Append git binaries to path so vagrant can run ssh)
  4. vagrant init precise32 http://files.vagrantup.com/precise32.box (To install Ubuntu 10.04 x86)
  5. Edit the Vagrantfile with your preferred editor and add those four lines anywhere inside the Vagrant.configure(“2”) block:
config.vm.provision :shell, :path => "meteor.sh"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provider "virtualbox" do |v|
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
  1. vagrant up (It will download box, configure meteor and get it up)
  2. vagrant ssh (It will connect on the VM and expose its command-line)

Now that you are inside the VM command-line, you can use it as your server:

Steps on Ubuntu command-line:

  1. cd /vagrant (This is by default shared with the host)
  2. mrt create ~/meteorapp
  3. mrt create meteorapp && cd meteorapp && rm -rf .meteor && mkdir .meteor/ (Check your Windows folder you’ve created. It will be there!)
  4. Input these lines:
sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/
echo “sudo mount --bind /home/vagrant/meteorapp/.meteor/ /vagrant/meteorapp/.meteor/” >> ~/.bashrc && source ~/.bashrc
mrt run
  1. Go to http://localhost:3000 in Windows browser and see it running! :)

The point here is to use the .meteor folder of your app pointing to another place inside the VM (run ls -la .meteor/ on command-line and you will see the symbolic link), so Meteor uses the VM folder, not Windows folder, and won’t have permissions problems. You will also need to do all git flow inside Ubuntu command-line, because Windows can’t follow those links.

Hints:

  • Make sure you do version control INSIDE THE VM, so the software can follow the symlink.
  • To halt a vagrant VM: vagrant halt
  • To restart a vagrant VM without running all Meteor installation again: vagrant reload --no-provision or just remove the shell path you’ve put on Vagrantfile on line 10.
  • To destroy a VM: vagrant destroy

That’s it. There's a project that does it automatically in win.meteor.com

Hope you like it,

Gabriel Pugliese

@gabrielsapo

@gabrielpugliese-luizalabs

I have updated the "Before you continue" section. Meteor has a installer for Windows now!

@kodybrown
Copy link

Thanks for the tutorial. I installed the Windows version. But, the Windows version of Meteor does not allow calling meteor run android-device.. I checked into port forwarding and it is doable, although may present some headaches. Anyway, I am wondering if anyone has gotten the Vagrant method working and with running / connecting to an Android device.

@dstollie
Copy link

dstollie commented Aug 3, 2015

Just wanted to use vagrant on my windows machine, tried the vagrant file above and saw it was some kind of outdated so I changed it to something more up-to-date and noob friendly:

#!/bin/bash

sudo apt-get update

#1. Install git and curl
sudo apt-get install -y git curl
#2. Update the os
sudo apt-get update
#3. Go to the local user directory
cd /usr/local
#4. Download NodeJS
sudo wget http://nodejs.org/dist/v0.10.11/node-v0.10.11-linux-x86.tar.gz
#5. Unpack and install NodeJS
sudo tar -xvzf node-v0.10.11-linux-x86.tar.gz --strip=1
#6. Remove the tar.gz file
rm -f node-v0.10.11-linux-x86.tar.gz
#7. And last but not least, install meteor itself
curl https://install.meteor.com | sudo sh
#8. Oh yeah, run the meteor help command to let meteor do soem startup stuff
meteor --help

@forgetso
Copy link

Thanks a lot for the symlink tip!

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