Save 36% for Black Friday! Learn more

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Using Vagrant for Rails Development Discussion

Chris Oliver asked in General
Kartik Danidhariya 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!!!

Reply

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

Did you find a way to solve it?

Reply

..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: 'https://github.com/RayMangu...
`

Explanation:

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

then I found this in Github:

https://github.com/RayMangu...

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

Reply

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:

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

Reply

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.

Reply

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

Reply

...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

Reply

vagrant-librarian-chef-nochef

Reply

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 (https://github.com/opscode/... 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.

Reply

I should have RTFM as far as specifying a version of Chef to install on the server: https://docs.vagrantup.com/...

Reply

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 https://github.com/opscode/... and https://github.com/opscode/... 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 https://github.com/fnichol/....

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.

Reply

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: https://github.com/redguide...

Reply

If you do not need chef, this will work in 5 minutes ;)
https://github.com/rails/ra...
and it is, unlike this tutorial, up-to-date!

Reply

Thanks for sharing!

Reply

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

Reply

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

Reply

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?

Reply

Finally a working cookbook for rbenv:

cookbook 'rbenv', git: 'https://github.com/john-tel...

Reply

Finally a working cookbook for rbenv:
cookbook 'rbenv', git: 'https://github.com/john-tel...

Reply
Łukasz Antkowiak Ł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?

Reply

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.

Reply
Siddhartha Majji Siddhartha Majji

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

Reply
Ryan Carter 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?

Reply

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.

Reply

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

Reply

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

Reply

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: ''

}

}

end

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

d.pull_images "redis"

d.run "redis"

end

end

-------------

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!

Reply

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.

Reply

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

Reply
Mincă Daniel Andrei Mincă Daniel Andrei

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

Reply
Rovin Varshney Rovin Varshney

Thanks. Really helpful vagrant tutorial

Reply

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.

Reply

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?

Reply

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

Reply
Carlton Smith III Carlton Smith III

How did you fix it?

Reply
Join the discussion
Create an account Log in

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

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

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