I want to setup my new development environment for a rails app using vagrant and chef.
Goal
Clone repository (see below). Then run:
vagrant up
vagrant ssh
Finally running bundle install in app folder should work using installed ruby 2.1.2.
I already have gone through several tutorials that describe how to to this using various cookbooks and different strategies (rbenv, rvm, ruby-install, ruby-build). But although sometimes the machine could be provisioned correctly, I was never able to ssh into the machine and run bundle install without the following error message:
The program 'bundle' is currently not installed. To run 'bundle' please ask your
administrator to install the package 'bundler'
I will now present my most recent attempt based on this tutorial: http://www.gotealeaf.com/blog/chef-basics-for-rails-developers/
I have uploaded it to github here: https://github.com/denniske/vagrant-chef-ruby
After creating vagrant machine and provisioning and ssh into machine, I get the following:
vagrant@vagrant-ubuntu-trusty-64:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
vagrant@vagrant-ubuntu-trusty-64:~$ which ruby
/usr/bin/ruby
vagrant@vagrant-ubuntu-trusty-64:~$ bundle
Could not locate Gemfile or .bundle/ directory
vagrant@vagrant-ubuntu-trusty-64:~$ cd /usr/local/ruby/2.1.2/bin
vagrant@vagrant-ubuntu-trusty-64:/usr/local/ruby/2.1.2/bin$ ls
erb  gem  irb  rake  rdoc  ri  ruby  testrb
Problem 1: It seems the default ruby is the ruby used by chef for provisioning (1.9.3) which I do not want to use for my rails application.
bundler is successfully installed, but connected to default (wrong) ruby version.
Ruby 2.2.1 was installed into /usr/local/ruby/2.1.2.
Problem 2: By using some code like this in default.rb I seem to be able to make my ruby version the default, but then bundler does not work.
link "/usr/bin/ruby" do
  to "/usr/local/ruby/2.1.2/bin/ruby"
end
link "/usr/bin/gem" do
  to "/usr/local/ruby/2.1.2/bin/gem"
end
Does anybody has an idea how to fix this / can create a pull request to get this working?
sudo chef-clientso inspecting vagrant user environment gives you a different view than the root environment. - Tensibai/usr/local/ruby/2.1.2/binto the path of uservagrantinstead of creating the symlinks? - Dennisrvm default 'version'command somewhere, I'm pretty sure the cookbook allow to manage it but you'll probably have to work with a two pass chef run so the environment is updated - Tensibai