All threads / Using Vagrant for Rails Development Discussion

Ask A Question


You’re not receiving notifications from this thread.

Using Vagrant for Rails Development Discussion

Chris Oliver asked in General

Trying to install the librarian-chef plugin first produces an error about not being able to find the vmware-workstation plugin (or rather gem). Installing the vbguest plugin first fixed the issue.

Thanks! I'll be sure to update that.

Carlo DiCelico ·

Awesome post! I had a ton of trouble installing the plugins, though. In case anyone else has the same issue, where installing plugins fails and you see a bunch of stuff about nokogiri, let me save you some Googling. Just see for the cure!

Ouch, that's kind of nasty. I hope they get that fixed soon. Thanks for sharing the link!

Nice and simple, great tutorial. Any idea how I can do this behind a proxy (that requires auth).... I live in a corporate environment :(

That's a good question. I would imagine you could set a system proxy on your OS and your network traffic would flow through there. Hopefully that would take care of routing all the downloads through there without having to configure a proxy inside the Vagrant guest machine too.

I tried setting http_proxy & https_proxy in the vagrant users .bashrc and even in /etc/environment, no luck. Then I discovered Ubuntu will blat any env vars when executing any command under sudo (EG: sudo apt-get update). That can be stopped by editing /etc/sudoers.


Still no luck, eventually I stumbled across this fantastic vagrant plugin:

That works perfectly, in my vagrant file I use the host's http_proxy & https_proxy environment variables (if present) when calling this plugin inside the Vagrantfile. No messy passwords or settings needing to be stored in the Vagrantfile. Nice.

One minor issue I am having now is timeout. When I run this on my home network which is not so fast, most things work, but it can be hit and miss, depending on network performance. Any idea where that can be overridden with chef solo?

Joel Taylor ·

Perhaps I'm missing something, but is there a reason you didn't include Rails in the Cheffile?

That's what Bundler is for. Your version of Rails is application specific, so you let Bundler manage it with your app's Gemfile.

Joel Taylor ·

That makes perfect sense - thanks!

Gruff Davies ·

I'm stuck at starting rails server. I get the same message as Dave upthread (The program 'rails' can be found in the following packages etc.) but no idea how to proceed. His solution didn't fix anything for me. I read you comment about bundler, so I tried " sudo gem install bundler" and then "sudo gem install bundler" which seemed to be working but broke trying to install bcrypt. I'm not even sure I should have been going this route?

If you used rbenv and have installed the Rails gem, make sure to run

rbenv rehash

This will make the "rails" executable visible to your terminal by putting a stub in your PATH.

Gruff Davies ·

Thanks. I hadn't installed the rails gem. I assumed that would be done by this. Trying that now after a fresh start. EDIT: Actually, I just realised, all I had to do was run 'bundle' once the VM was up and I was in my project directory. Bundle didn't exist last time I did any rails dev years ago so I handle understood your comment about being able to use it. Everything makes sense now. THANKS!

Yep! :) Glad you got it working!

I'm stuck at this part when I run 'vagrant up'. I'm on Windows Environment.. Help?

Is it actually causing you problems? I know the "stdin: is not a tty" seems to be more of a warning than an actual problem according to this

I haven't run this on Windows yet however, so keep me posted if things don't work after finishing the tutorial. This is a very long thread but someone mentions the error and you might find a solution in here:

Same error here, did you manage to solve it?

Anthony Candaele ·

I'm having the same issue, and I'm on a Mac X (Mavericks) environment. Not sure if it's doing something and if I should wait.

Anthony Candaele ·

I should have been patient, it's ok now :)

This is interesting. I use VMware's Workstation for my vm, but haven't tried these tools. So are you suggesting a different vm for each dev/production project, and this is the quick way to set up the environment for each? I've just been running a bunch of projects in one vm. Reasons I shouldn't do that?

This is going to setup a separate VM for each mainly for the purpose that everyone working on the project starts with a clean machine. If you don't run into any problems with your setup, you don't really need this. The trouble comes in when you need to share your machine setup with say 50 other developers. Then you need something like this so everyone can spin up a development environment without any trouble.

Any resources on setting up one Vagrant/Rails box to learn and work with multiple projects?

The goal is really to use a separate Vagrant box for each project. The reason for that is that each time you can be sure you have everything separated out nicely and you can trust that you don't have some accidental dependencies you forgot about it or weren't aware of.

Yes, I totally understand the need (especially in a team environment). Forgive me for not understanding the vagrant part (newb) but this sounds like I'd be downloading and storing a version of Ubuntu for each project.

My only experience with Vagrant is with Laravel's Homestead box where I have multiple projects within my Code directory. Composer then pulls down the packages/gems for each project.

That's a good question. I think it downloads the primary image once and clones it for each project. You should be able to run "ls -la" to determine the directory size and see just how much it's taking up. I'd guess it's a couple GB for each project.

For personal projects, Vagrant isn't really necessary so I wouldn't really say you need it for that. Mostly just like team environments like you mentioned.

I'd guess there is a way of sharing the Vagrant VM, but I'm not sure off the top of my head.

I have been trying to figure out how vagrant works for a few hours. Just bumped into your article. This was very helpful and well explained. Thanks! I will be modifying the Chef portion to use, but other than that it was spot on for me.

Thanks. Keep it up.

I failed at step first: setup vagrant plugins. Here is an error i get:

Thanks for wanting to use Vagrant! Unfortunately, this is not the way
to install Vagrant anymore. We now make installers for the various operating
systems Vagrant supports.
Vagrant is no longer distributed as a RubyGem. Please download the latest
version for your operating system from the URL below. If you still wish
to use the RubyGem version, you can manually install version 1.0.7. Note that
the RubyGem version hasn't been updated in over a year and will no longer
receive any updates.

Prior to installing Vagrant using the installer, make sure you uninstall
all your Vagrant gems, since they sometimes conflict.
If you want to learn more about why we don't distribute using RubyGems
anymore, please read this:

Did you install Vagrant from the rubygem before? I linked to the installer and make sure you remove the Vagrant gem.

Nice article. Will you consider to add docker for this tutorials?

What was your schedule for the docker tutorial?

Brendan Vinson ·

Really interested in the docker tutorial as well.

jesterfraud ·

So there's a nasty gotcha if you're using Windows 8.1, which I believe is tied to having installed the Windows Phone dev tools - this will enabled Hyper-V by default which will silently ruin any attempts you make to run a x64 VirtualBox VM, or so I've experienced. I just had SSH time out, and then a black screen when I attempted to boot with GUI.

This post details a way to get around that:

Not ideal, I might see if I can get this to use a x86 machine instead, if possible, and be sure to test on a x64 before production.

If you don't actually do any WP development, you can alternatively uninstall the Hyper-V components from your system, and be problem free.

Dave Kaplan ·

Thanks for posting this Chris. I got all the way to the end and when I run `rails server` I get this error:

[email protected]:/vagrant$ rails server
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Ask your administrator to install one of them

I ran `rbenv rehash` and then tried `rails server` again and everything works!

One other thing I learned through working this post: I have vmware_fusion as a Vagrant provider plugin, so I need to specify virtualbox when I `vagrant up --provider=virtualbox`

Great article!

Joel Collins ·

isn't there a cart before the horse problem here? You can't run rails new projectname until you have rails installed?

Kartik Danidhariya ·

i get same problem i run rbenv rehash ant then tried 'rails server'
but it still return
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Ask your administrator to install one of them
pls help i am new for vagrant and ROR
Thanks in advance!!!

Daniil Garmoshka Kucherenko ·

# After vagrant installed & provisioned, run inside vm:

cd /vagrant

gem install bundler
gem install rails -v 4.2.1
rbenv rehash

Samar Singh ·

Do I need to do something else If I am using Puma ? I followed the procedure first got the error "

The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Ask your administrator to install one of them

Then I did

gem install bundlergem install rails -v 4.2.1
rbenv rehash

Now I am getting the following Error :
=> Booting Puma

=> Rails 4.2.4 application starting in development on http://localhost:3000

=> Run `rails server -h` for more startup options

=> Ctrl-C to shutdown server


/home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/less-rails-2.7.0/lib/less/rails/railtie.rb:19:in `block in <class:railtie>': undefined method `register_preprocessor' for nil:NilClass (NoMethodError)

from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'

Александр Пурхало ·

1. sudo gem install bundler
2. bundle
3. bin/rails server -b

This should help you to deal with this problem.

Gruff Davies ·

I've added a port forward to my host 3306 to 23360 in the vagrant file so I can access MySQL using Toad. I had to manually grant `root`@`%` privileges in mysql in order for that to work. Can I chnage the chef.json to do that automatically?

I'm not sure if you can do that with the typical json. The database recipe should let you do that, but you'll likely need to write some calls to it instead of defining json.

Gruff Davies ·

Thanks Chris. I decided it wasn't good practice in the end and instead I'm using putty with a tunnel to ssh into my VM, just as I would in production. I think it's better to keep the environments as close as possible. And this method is much less painful to set up and it's more secure.

Cool, it's always good to have consistency like that between development and production so I'm definitely with you there.

If this is your first time setting up rails with vagrant or you don't have any rails app, you need to installl rail gem 'gem install rails' and make rails executable 'rbenv rehash' before run 'rails server'. to check your rails is installed, run 'rails -v'

Gruff Davies ·

One gotcha worth pointing out here that I got stung by: there's a bug in the current upgrade of Vagrant. Apparently several: So if you're already using vagrant, it's best to uninstall it and install fresh which fixed things for me. I also upgraded VirtualBox but this was straightforward.

Camilo Rivera ·


FYI, I was getting the following error this morning:

NoMethodError: mysql_service[default] (mysql::server line 20) had an error: NoMethodError: undefined method `sensitive' for Chef::Resource::Execute

Apparently, this bug was introduced with the latest version of the mysql cookbook (v5.5.4 as of today).

If this ever happens to anyone, you can just specify the previous version in the Cheffile as follows:

cookbook 'apt'
cookbook 'build-essential'
cookbook 'mysql', '5.5.3'
cookbook 'vim'

After this, I just entered the vagrant provision command and everything worked like a charm.


Awesome find! Thanks for sharing this.

John Nadeau ·

Thanks, I just ran into this today!

Bishisht Bhatta ·

vagrant plugin install vagrant-librarian-chef

fails on my machine. I have posted full details on stackoverflow(

hope to get some solution from you guys.

Anthony Candaele ·

I have a question about this line in the Vagrantfile:

mysql: {
server_root_password: ''

does this mean that this setup doesn't work with Postgres?



You'll have to swap the MySQL instructions with Postgres ones. This tells Chef how to setup a MySQL server inside the Vagrant box, so you'll need to do the same for Postgres. I'm not sure of all the differences off the top of my head but a quick google search for postgres + chef should find you exactly whaty ou need.

Anthony Candaele ·

thanks Chris, I'll give Vagrant a go on my next Rails project.

Anthony Candaele ·

in my Vagrantfile, I changed the lines:

chef.add_recipe "mysql::server"
chef.add_recipe "mysql::client"


chef.add_recipe "postgresql::server"
chef.add_recipe "postgresql::client"

then I changed the line:

mysql: {
server_root_password: ''


postgresql: {
:version => "9.3",
:password => {
:postgres => "foo"

and long and behold, it works!

Anthony Candaele ·

I followed the instructions in this tutorial and everything ran successfully. Then I ran the 'vagrant up' and 'vagrant ssh' command. However, I don't seem to have a /vagrant directory. I have a .vagrant directory with in it a 'machines' directory.
Am I missing something?

Anthony Candaele ·

oops, seems I can cd into '/vagrant', it's all good.

Yeah, /vagrant is inside the VM, not on your local machine.

Anthony Candaele ·

I just ran into an issue with Launchy, which won't open a page in the browser, when on a virtual machine:

Failure/Error: save_and_open_page
Unable to find a browser command. If this is unexpected, Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at

not being able open a page in the browser when testing with Capybara is kind of a show stopper for me : (

Kartik Danidhariya ·

my os is ubuntu 12.04 64 bit
i am successfully install Vagrant
After when i try to install virtual box using this
sudo dpkg -i virtualbox-4.3_4.3.20-96996~Ubuntu~precise_i386.deb
it gives following error

Selecting previously unselected package virtualbox-4.3:i386.
(Reading database ... 185893 files and directories currently installed.)
Unpacking virtualbox-4.3:i386 (from virtualbox-4.3_4.3.20-96996~Ubuntu~precise_i386.deb) ...
dpkg: dependency problems prevent configuration of virtualbox-4.3:i386:
virtualbox-4.3:i386 depends on libdevmapper1.02.1 (>= 2:1.02.20).
virtualbox-4.3:i386 depends on libpython2.7 (>= 2.7).
virtualbox-4.3:i386 depends on libvpx1 (>= 1.0.0).
virtualbox-4.3:i386 depends on psmisc.
dpkg: error processing virtualbox-4.3:i386 (--install):
dependency problems - leaving unconfigured
Processing triggers for ureadahead ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for shared-mime-info ...
Processing triggers for desktop-file-utils ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for gnome-menus ...
Errors were encountered while processing:

how can i solve ,thanks in advance!!!

Kartik Danidhariya ·

when i give vagrant up it sows following error

==> default: Recipe Compile Error
==> default: ================================================================================
==> default:
==> default: Chef::Exceptions::RecipeNotFound
==> default: --------------------------------
==> default: could not find recipe server for cookbook mysql
==> default:
==> default: [2014-12-24T12:22:59+00:00] ERROR: Running exception handlers
==> default: [2014-12-24T12:22:59+00:00] ERROR: Exception handlers complete
==> default: [2014-12-24T12:22:59+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2014-12-24T12:22:59+00:00] ERROR: could not find recipe server for cookbook mysql
==> default: [2014-12-24T12:23:00+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Pls help i am new for ROR and vagrant,
Thanks in advance!!!

I got a same errors like above error messages, but i can't find the solution.

Did you find a way to solve it?

semicircle21 ·

I got this too, and fixed with this:
change the mysql line in Cheffile:

cookbook 'apt'
cookbook 'build-essential'
cookbook 'mysql', '5.5.3'


semicircle21 ·

..just in case someone, run into this error:

undefined method `rbenv_rehash' for #<chef::provider::package::rbenvrubygems:0x000000049c8340>

Here's the solution:
Change the 'rbenv' line in the Cheffile:

cookbook 'rbenv', git: '


I'm new to rails too, and I thought it's a rbenv / chef related problem,

then I found this in Github:

It seems the chef-rbenv is out of date. And, the newest fork is the RayMangum's one.

This is a good guide:-) But after I run `vagrant up`, I got these errors:

➜ MY_RAILS_PROJECT vagrant up
/Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/util/which.rb:32: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Installing Chef cookbooks with Librarian-Chef...
[default] Destroying VM and associated drives...
[default] Running cleanup tasks for 'chef_solo' provisioner...
/Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:800:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:800:in `block in connect'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/timeout.rb:55:in `timeout'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/timeout.rb:100:in `timeout'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:800:in `connect'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:756:in `do_start'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /Users/jingqiangzhang/.vagrant.d/gems/gems/librarian-chef-0.0.4/lib/librarian/chef/source/site.rb:353:in `block in http_get'

My ruby version is:

ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Chris Bloom ·

You may want to try setting `config.ssh.forward_agent = true` in your Vagrantfile. I was unable to checkout anything from github via bundler without that. It may be related to the error you're seeing.

Guogengrui ·

I am sad to get the same error. could you tell me how to solve it . ths!

...except Vagrant-librarian-chef doesn't work on Windows 7 (at least it didn't work for me) causing me to have to look elsewhere to get Rails up and running


Chris Bloom ·

I am getting to the point with the number of apps that I work on and the diversity of environments that I need to maintain that Brew and RVM alone no longer cut it. I was hoping that the combination of Vagrant, VirtualBox, Librarian, and Chef would be the answer, but I've been struggling with these steps over the last week to setup VMs for two different projects and I'm about ready to give up and look elsewhere.

The main issue is that I keep running into conflicts/errors in the Chef recipes. It took me the better part of 3 days to successfully provision a VM using this method with Postgres 8 and PostGIS 1.5. Granted those are both deprecated versions , but that's what I needed for one particular project that we maintain. You state towards the end of the article that I should be able to just run `vagrant provision` if I change the Vagrantfile or the Cheffile and it will reprovision the box, but it's been my experience that once I run `vagrant up` the Chef recipes won't run again until I destroy the VM and start over. If I try to reprovision it just tells me that the server is already setup and Chef never runs again. Since each fresh start takes anywhere from 45 minutes to an hour and a half, that all adds up when I have to keep starting over every time there's a new error.

In my last attempt I ran into a bug with Ubuntu 14 and Chef 12 ( that took me a while to figure out. Since there's no way (that I've found) to specify what version of Chef gets installed on the VM during provisioning, the only way around it was to downgrade to Ubuntu 12 instead.

And now I'm stuck trying to get the default MySQL recipe to run but it keeps telling me "You must supply a name when declaring a package resource", and I see no way to do that in the instructions for the MySQL cookbook.

I've never had much luck with Chef in general. I generally just need to setup very simple servers, and Chef seems like too much overhead for that task. The alternative of setting things up manually is just as tedious though, so I'm at a crossroads.

Chris Bloom ·

I should have RTFM as far as specifying a version of Chef to install on the server:

Chris Bloom ·

In case anyone else runs into the issues I kept running into:

Chef doesn't run again on `vagrant provision` if you install RVM. See and for possible fixes, or don't use RVM. If you do use RVM, you'll also need to figure out a way to get around the issue with RVM updates and PGP keys in subsequent provisioning runs, detailed at

For my MySQL problem, I had to code dive into the mysql recipe files to discover that the mysql cookbook is not configured to install the version of MySQL I needed on the version of Ubuntu I was using, so I had to downgrade Ubuntu yet again to 10.04. Frustrating that they wouldn't provide a table of supported installs.

It looks like nodejs-cookbook is deprecated, here's what the readme says:
Important notice: this repository has been deprecated and the development of the nodejs cookbook has been moved here:

If you do not need chef, this will work in 5 minutes ;)
and it is, unlike this tutorial, up-to-date!

This is not for rails development, it's for developing rails itself.

Jon Thomas ·

I also had to specify a version for mysql, but after I did that it worked perfect.

Jon Thomas ·

When I use vagrant up, it puts me in the user directory "~", and I can run ruby -v and get the correct output. However, when I cd to /vagrant, and run ruby -v it says "rbenv: version `ruby-1.9.3-p551' is not installed". Why can't I use the ruby command outside of the user directory with this setup?

Finally a working cookbook for rbenv:

cookbook 'rbenv', git: '

Finally a working cookbook for rbenv:
cookbook 'rbenv', git: '

Łukasz Antkowiak ·

why such tutorials always ends when the most important part begins? Am I supposed to install my dev tools on guest (it may not be full blown ide, I think that configured vim still counts), or still use it on my host? If tools still should be on host, how did you debug your app?

There is basically no difference in your workflow other than SSHing in for running the server. Like I mentioned, the folder is shared between the host and the VM guest. You have to install all the tools inside the VM to run the app, but since it's shared you can edit in either place. You debug your app exactly like normal through the terminal. It just happens to be inside SSH to the VM, but there is almost no difference.

Siddhartha Majji ·

Hello there! after installing the bundler, I'm getting an error message that
thanks in advance!

Ryan Carter ·

Chris, great tutorial. Thanks. Got me up and running quick. Question for you though. If I wanted to add java, git, nginx, and others, I would include their cookbook in Cheffile, then config in vagrantfile, correct?

Yeah that should do it. You can sometimes use the apt packages for those or if you want to customize the install (like get the latest version) then cookbooks usually make the most sense.

So do I have to run virtualbox and vagrant in production server as well?

Nope, this is mainly just to emulate production on your development machine.

Hi, everything works great except for bundler is not getting installed when the vm is provisioned. I navigate to my directory and then run bundle install and get this message:

The program 'bundle' is currently not installed. To run 'bundle' please ask your administrator to install the package 'bundler'

I modified the following from the Vagrantfile listed in this tutorial to use ruby 2.1.3 and added docker to pull and run redis:

# Install Ruby 2.1.3 and Bundler

# Set an empty root password for MySQL to make things simple

chef.json = {

rbenv: {

user_installs: [{

user: 'vagrant',

rubies: ["2.1.3"],

global: "2.1.3",

gems: {

"2.1.3" => [

{ name: "bundler" }





mysql: {

server_root_password: ''




config.vm.provision "docker" do |d|

d.pull_images "redis" "redis"




Does anyone know why bundler isn't being installed and how to configure the vagrant file so that it does get installed? I've already tried rbenv rehash before running bundle install, and get the same "bundler not installed" message. This isn't the biggest issue, because I can run gem install bundler, but I'm attempting to automate the deployment process of our ruby dev environments as much as possible.. so finding the solution would be great!

Any help appreciated, thanks!

I ran into the same problem recently. Couldn't figure out what was wrong but maybe the gem had updated and it no longer recognized the option. You can install it manually and things work fine. Would love if someone finds a good solution for this.

Any progress with this? I am new to Vagrant and am just trying to provision a solid, reusable setup for multiple developers and I am just completely stuck on this. I'm not sure how to write the script to install bundler manually. Which gem was updated??

I haven't had the time to find any solution to that recently. Hopefully someone can leave a comment if they find a solution!

David Darke ·

Yeah have the same problem with this :( would love a solution!

how to install it manually?

baconinja ·

I was getting this error no matter what ... "The program bundle is not currently installed". However, here is the combination that fixed it for me.
1. Locate the version of Bundler used in project I wanted to Vagrant
2. Downgraded Vagrant to match the version
3. Run rbenv rehash AFTER the bundler install
4. Bundle project and make money

Mincă Daniel Andrei ·

Mine loops through "Connection timeout...Retrying..."

Rovin Varshney ·

Thanks. Really helpful vagrant tutorial

ukritdane ·

Thanks for sharing this information. I have not come across this issue while working on Rail development. But i hope this blog will help the one who are looking for this information.I have bookmarked this Blog.

everytime I try to run bundle, it says "Could not locate Gemfile or .bundle/ directory"
I've already made sure bundler was installed and rails 4.2, since i know some people were having problems with that, any idea whats wrong?

nvm got it fixed, but still can't access the forwarded port

Carlton Smith III ·

How did you fix it?

I ended up just using a vagrant box that was already set up, sorry I can't help more.

Runy Calmera ·

I'm getting this information when I put in the first comment. Is this still the way to use Vagrant with Ruby on Rails development?


Vagrant is no longer distributed as a RubyGem. Please download the latest

version for your operating system from the URL below. If you still wish

to use the RubyGem version, you can manually install version 1.0.7. Note that

the RubyGem version hasn't been updated in over a year and will no longer

receive any updates.

Prior to installing Vagrant using the installer, make sure you uninstall

all your Vagrant gems, since they sometimes conflict.

If you want to learn more about why we don't distribute using RubyGems

anymore, please read this:

Sounds like you installed the vagrant rubygem before. You'll want to uninstall that and download it from vagrant's website instead.


um just to be clear, the _code/landingpage_ folder is empty...?!

It is weird. When I ssh inti vagrant and run pwd I see `/home/vagrant` but when I run ls I don't see any files.If I run `ls /vagrant' I see all my files though that are being synced.

This boggled my mind for at least 4 or 5 hours.

If I `cd /vagrant` and `ls` I'll see all my files. But if I run `pwd` from there I am in `/vagrant`.

Is anyone else confused why vagrant would create a folder in my home folder `/home/vagrant` but actually sync with `/home`??

So happy now that I have figured this out!!! :D

Carlton Smith III ·

Do I need to have rails set up on my main machine also for this to work? Everything seems fine until I run 'bundle' and it says, "The program 'bundle' is currently not installed..." - I see that someone else has this issue as well, but I don't see a workable solution. I'm just wondering if this is happening because I don't have rails installed on my windows machine. I was hoping I could avoid doing that for this solution.

Carlton Smith III ·

I found the problem. I had installed the vagrant plugins on a previous attempt and didn't realize I needed to do it again. After installing the plugins again and provisioning everything worked as it should.

Excuse me, why yesterday with "bin/rails s" with webrick (and also Puma) I can open the localhost:3000 and today (with nothing changed) I can't and have to start with "bin/rails s -b" ???

Runy Calmera ·

Hi thanks for the tutorial. I can't get bundle installed. I get this: Could not locate Gemfile or .bundle/ directory

Have anymore gotten this problem?


Runy Calmera ·

What I don't understand is this. If I'm making an app called testapp and then also work on another app called testapp2. Do I need to go in the /vagrant directory and then put there rails new testapp and rails new testapp2? So do these rails apps go IN the vagrant folder?

My set up is as follows:

I created a folder called railsprojects
I did vagrant init from within this folder railsprojects.

I had NO rails apps installed in this folder.

So I went to this folder railsprojects
Then I did vagrant up
And then vagrant ssh.

And now I want to start creating rails apps. I have many rails apps to create and they all use the same virtual machine.

In which folder should I run the rails new testapp comment?

Many thanks.


German Mendoza ·

Where is my synced folder, I have created a project in vagrant, but I can not find in my local system, somebody help me please!!!.

German Mendoza ·

Thanks for information.

But I want create in my local host a url as

how can I do this?

I m getting error like these. May be i miss something?

The box you're attempting to add doesn't support the provider
you requested. Please find an alternate box or use an alternate
provider. Double-check your requested provider to verify you didn't
simply misspell it.

If you're adding a box from HashiCorp's Atlas, make sure the box is

Name: ubuntu/trusty64
Requested provider: ["vmware_desktop", "vmware_fusion", "vmware_workstation"]

Awesome tutorial!
Do the other developers on the same team who don't have Vagrant yet have to install plugins as well?

John Roberson ·

Can someone please clarify what the Vagrantfile should look like if you wanted rails to be installed automatically on vagrant up? :-) Thanks for the tutorial btw! I've got it up and running. I just want to be able to automate it further for future use and still have a bit to learn about Chef and Vagrant.

C Lokesh Reddy ·

I followed the whole post and successfully configured everything. But when I've restarted the system and opened vagrant linux terminal in the folder and run following command 'cd /vagrant' & 'ls', I'm not able to see the files in the directory. It happened to me 3 times and every time I had to do all the process again copying all my progect files into other folder and all commands of vagrant, all updates of ubuntu and rails again every time. Someody please help why is the link between vagrant getting vanished once the system is restarted?

Fritz Rodriguez Jr. ·

Hey Chris! As always my man! Thanks for another great screencast. After going through the tutorial notes, I couldn't get the server up and running. Then I checked out the video and you mentioned using 'rails server -b' to start the rails server and it worked. Might want to include that in the documentation

Also, there is another resource I found that might be helpful...

Take care and thanks again...Best!

Intruder7s ·

Thanks for your guide! I am kinda stuck though!

1. Right after the installation of Vagrant and then VB, what is the next step? I just opened a cmd and went from there. Didn't know what else to do.

2. Since I am in Windows 7 x64 I am getting the "'touch' is not recognized as an internal or external command, operable program or batch file." message. Any workarounds ?


Edit for anyone wondering.

1. I am using Cygwin with some extra plugins to implement commands like top, diff and a few others. It is the best option when working in Windows and want to do simple stuff.

2. Using Cygwin I can use the touch command.
However since "touch" is not availiable in windows, this tutorial should instuct the user to use this command. So if you are having trouble in this step of the tutorial, when instructed to "touch Cheffile" simply create a file at the specific folder you are working on and name it Cheffile.

Łukasz Siwiński ·

Thanks for this tutorial Chris. Works fine for me, but I've encountered 1 problem during `vagrant up` on my Windows 10 x64 Box:

%userprofile%/.vagrant.d/gems/gems/vagrant-vbguest-0.11.0/lib/vagrant-vbguest/download.rb:23:in `unlink': Permission denied @ unlink_internal - %userprofile%/.vagrant.d/tmp/VBoxGuestAdditions_5.0.10.iso (Errno::EACCES)

This post on stackoverflow help me to solve it

But I think that's just a "workaround" of some real problem that was reported here: and here: https://openedx.atlassian.n... too.

I am getting the error "ERROR: You must specify at least one cookbook repo path". Will come back if I figure it out. The only changes I have made to Chris' code is making it Postgres instead of MySQL.

I hadn't run the line `vagrant plugin install vagrant-librarian-chef-nochef`. I have done that although now Chef installation takes so long I stopped it. 1hr + so I don't think that classifies for 'This can take a while.`

superiorpaper ·

This might really become useful and really helpful for them to have especially that people might need to know on how are they going to use some certain kind of tools that will surely guide them with their work or will going to help them in promoting something for their work.

Jorge Anzola ·

I'm getting this error after "vagrant up"

from C:/Users/JorgeAnzola/.vagrant.d/gems/gems/librarian-chef-nochef-0.2.0/lib/librarian/chef/source/site.rb:354:in `block in http_get'

folloewd by a bunch of code lines. Does any one knows how to solve it?

Rahmat Awalludin ·

when "vagrant plugin install vagrant-librarian-chef-nochef", i get error "Could not find gem 'vagrant-librarian-chef-nochefvagrant (>= 0) ruby' in any of the gem sources listed in your Gemfile or available on this machine."

Ryan R Wilkins ·

Even after I assign I am still unable to get my localhost to work on chrome.

"This site can’t be reached

localhost refused to connect.

allenak ·

Make sure you use = "stable"

So you don't accidentally get an unstable build that doesn't work with your vagrant setup.

Following these instructions I've been hit with this error:

[2016-06-22T22:33:38+00:00] INFO: HTTP Request Returned 404 Not Found: Parent not found: chefzero://localhost:8889/nodes

The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.

chef_server_url "chefzero://localhost:8889"

I'm very new to all this and not sure what would need changed to fix it?!

Any help/hand holding would be great!

I struggled with this for a while, finding multiple stack overflow and github issues saying to specify a version of specify the channel to be stable. Finally figured out I had missed this step. Hope it helps someone
vagrant plugin install vagrant-librarian-chef-nochef

Lifesaver! Thanks.

How to change the Vagrantfile to install Ruby 2.3.1, which is not downloadable as a binary?

Since we're using rbenv, it should compile Ruby instead of downloading it as a binary. You should be able to change the version numbers, although I haven't tried it with 2.3.1 yet.

Unfortunately, I don't know how to tell it to go for compiling. It fails when not being able to download. :(
As I want to use Rails 5, I need this more recent Ruby version.

What's the error you're getting?

==> default: [2016-09-20T21:56:22+00:00] ERROR: rbenv_ruby[2.3.1 (vagrant)] (vagrant) (rbenv::user line 45) had an error: Mixlib::ShellOut::ShellCommandFailed: rbenv_script[rbenv download 2.3.1 (vagrant)] (/var/chef/cache/cookbooks/rbenv/providers/ruby.rb line 81) had an error: Mixlib::ShellOut::ShellCommandFailed: script[rbenv download 2.3.1 (vagrant)] (/var/chef/cache/cookbooks/rbenv/providers/script.rb line 38) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of "bash" "/tmp/chef-script20160920-6143-1sxflk7" ----
==> default: STDOUT: Download and extract ruby 2.3.1 from the RVM repository
==> default: STDERR: cannot be reached
==> default: Cannot find a built version of '2.3.1' compiled for your current system: Ubuntu x86_64 (14.04)
==> default: ---- End output of "bash" "/tmp/chef-script20160920-6143-1sxflk7" ----
==> default: Ran "bash" "/tmp/chef-script20160920-6143-1sxflk7" returned 1
==> default: [2016-09-20T21:56:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Welp, yeah looks like they stopped compiling for 14.04 because it's fairly old now. Looks like they got up to 2.2.1

Ubuntu 16.04 LTS does have 2.3.1

I would probably recommend changing your Vagrantfile to use "ubuntu/xenial64" instead of 14.04 trusty which should work. I'm going to update the tutorial to use the newer Ubuntu LTS as well because 14.04 is too old.

Try the newer Ubuntu and see if that works?

Chris Olin ·

It's been awhile since this guide was posted. In an effort to help those that come across it, here's a link to a more modern Vagrantfile based off of this guide. Hope it helps.

Also, the official Vagrant image for xenial64 doesn't include a 'vagrant' user. See for more info. There's a workaround in the Vagrantfile I linked to that references this bug.

Thanks Chris! I'm going to try updating the tutorial this weekend using your notes. It's been a while since I've updated this. 🤘

Chris Olin ·

Even still, this guide was invaluable for someone like me who had never used Vagrant, Chef, or Ruby before. I kept referring to it and the comments more than anything else.

Awesome to hear! Appreciate the updates notes and I should definitely do a screencast on this as well. :D

Chris Olin ·

Also worth noting, Found that immensely helpful since this Vagrant box is intended to be used by many people and we want to automate as much as possible.

Looks like it's working fine. For vagrant 1.9.3 you have to add , (host_ip: "localhost") to the line :forwarded_port, guest: 3000, host: 3000, at least on Windows machines due to

Dima Danko ·

Тупорылые авторы статей - после
vagrant up

- пишет:

[email protected]'s password:

и всё блять, какой блять пасворд? долбаебы напишут а людям непонятно. вы хоть проверяли ваш код перед тем как людям предоставлять.

LacosteNYC ·

Nice job. But if I change anything in Vagrant file (i.e. add docker, change default ruby version) I get this notice on subsequent
`vagrant up` commands.
==> default: Installing Chef cookbooks with Librarian-Chef...
==> default: The cookbook path '/Users/lacoste/dev/testvagrant/site-cookbooks' doesn't exist. Ignoring...
Same when I try to run `vagrant provision`. So it looks likes whatever chef is doing only works on initial provision, or am I missing something? Thanks!

Matt Yale ·

Add a site-cookbooks folder to your directory

Gerald Nah ·

HI there, im having this problem after running vagrant up.

Followed all steps from copying both Vagrant and Cheffile into the same directory

C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:21:in `initialize': The requested address is not valid in its context. - connect(2) for "" port 3000 (Errno::EADDRNOTAVAIL)
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:21:in `new'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:21:in `block in is_port_open?'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `block in catch'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:103:in `timeout'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:19:in `is_port_open?'

Hey I keep getting `NoMethodError: undefined method `include_default_source' for Custom resource ruby_rbenv_gem from cookbook ruby_rbenv`

Error executing action `install` on resource '[2.4.0::bundler (ubuntu)] (ubuntu)'

I don't use rbenv on my local machine. Does that matter for installing it on vb?

Ziyan Junaideen ·

For me it worked for 2.4.0 but not 2.2.7 which is a requirement for an old project of mine... any clue what caused it?

*** ALERT *** If you want a simple vagrant install that is Rails 5, ruby 2.4, and postgres. WITHOUT ansible or Cheffile. Listen here.
While this post was great at some point, it no longer is helpful without doing some troubleshooting. (This guide gave me outdated dependencies and errors that drove me nuts). Download the rails-dev-box and follow their simple instructions. The shell script file does everything without spitting 100's of lines of code. It just works.

Once again, not hating on this guide, I just found a much simpler one.


After I fire the command `vagrant provision`
I get this error

==> default: executable=/opt/chef/bin/chef-solo
==> default: Running handlers:
==> default: [2017-07-17T12:19:39+00:00] ERROR: Running exception handlers
==> default: Running handlers complete

==> default: [2017-07-17T12:19:39+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 0 resources updated in 01 seconds
==> default: [2017-07-17T12:19:39+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2017-07-17T12:19:39+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2017-07-17T12:19:39+00:00] ERROR: 412 "Precondition Failed"
==> default: [2017-07-17T12:19:39+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the

I m new to this vagrant, i googled it but was not able to get the right answer to this problem
pls help

Peter Blackledge ·

On Windows 10 I'm trying to install Rails on Vagrant on drive D:. After creating the Cheffile and Vagrantfile as directed, the 'vagrant up' command fails with error message: 'D:/vboxes/gems/2.3.4/gems/librarian-chef-nochef-0.2.0/lib/librarian/chef/source/site.rb:309:in `unpack_package!': The package archive has too many children! (RuntimeError)' followed by dozens more file and command errors.
There are a few online discussions - going back several years - about this 'too many children' Chef error. Some possible solutions are proposed, most beyond my technical know-how, and no definite resolution that I can see.
Can anyone point to a reliable answer?

I'm working through this now. Looks like this issue was closed long ago but has reemerged. Will try to come back with a fix if I figure it out... which I will probably forget to do once I have figured it out :P

Ended up chasing errors most of the day. Windows + Vagrant + Chef for ruby 2.4 and rails 5.1 was not worth the hassle for me as I will be the only dev on this project. Ended up using Vagrant then ssh'ing in and DIY server provision by following the usual GoRails guide ->

Peter Blackledge ·

Glad it's not just me :(

I gave up Chef as not worth the effort and followed a Daniel Kehoe (@rails_apps) recipe to install RoR on a Vagrant Linux VM.

I too have battled with this for ages, using vagrant et al on Ubuntu 17.10. Kept getting the "too many children" error. I discovered that many thought the problem was with "archive-tar-minitar" gem, which used to be true but has been fixed by giving Vagrant a new dependency on "minitar" instead - see here.  So that line of research proved fruitless, however, inspired by Chris' debugging adventures, I dug deeper. The error message located the problem at ~/.vagrant.d/gems/2.3.3/gems/librarian-chef-nochef-0.2.0/lib/librarian/chef/source/site.rb:309. So I had a look and found the following:
303             # Cookbook files, as pulled from Opscode Community Site API, are
304             # embedded in a subdirectory of the tarball. If created by git archive they
305             # can include the subfolder `pax_global_header`, which is ignored.
306             subtemps = temp.children
307             subtemps.empty? and raise "The package archive was empty!"
308             subtemps.delete_if{|pth| pth.to_s[/pax_global_header/]}
309             subtemps.size > 1 and raise "The package archive has too many children!"

I tracked down the first package to fail (system) and examined the value of subtemps to find that there was a second child subdirectory, but its name did not match the 'pax_global_header' string. It was 'PaxHeader'.
I added in a line to delete that..
308             subtemps.delete_if{|pth| pth.to_s[/pax_global_header/]}
309(new)        subtemps.delete_if{|pth| pth.to_s[/PaxHeader/]}
... and Hey Presto! the 'vagrant up' command now completes and we are up and running.

Ah! WAIT... that's not quite true. So much junk lying around from previous attempts that it masked the error in my thinking. PaxHeader may seem to be something useful, so a re-think is required. I'll update you all when I unravel it :)
Khashayar Yo ·

Hi There, i get the following error can you please help
/Users/khashayaryousefi/.vagrant.d/gems/2.3.4/gems/librarian-chef-nochef-0.2.0/lib/librarian/chef/source/site.rb:309:in `unpack_package!': The package archive has too many children! (RuntimeError)

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,665+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.