{"id":21,"date":"2010-09-11T23:07:40","date_gmt":"2010-09-11T21:07:40","guid":{"rendered":"http:\/\/www.hacksrus.net\/blog\/?p=21"},"modified":"2012-10-28T17:42:06","modified_gmt":"2012-10-28T15:42:06","slug":"capistrano-with-rails-3-and-bundler","status":"publish","type":"post","link":"https:\/\/www.hacksrus.net\/blog\/2010\/09\/capistrano-with-rails-3-and-bundler\/","title":{"rendered":"Capistrano with Rails 3 and bundler"},"content":{"rendered":"<p>Today I tried to deploy a new Rails 3 project using beloved Capistrano.<\/p>\n<p>When it came to installing the gems after the deployment process however, although I found an almost ready to use task for Capistrano, I stumbled upon a severe issue:<br \/>\nWhenever bundler tried to install gems, I was automatically asked for my root password.<\/p>\n<p>Given that interactive prompting is nasty with Capistrano, and I don&#8217;t want a single application&#8217;s gems installed system-wide anyway, I did a little research and found a hardly documented way to install the gems inside the Rails application directory (what used to be vendor\/gems).<\/p>\n<p>Apparently you don&#8217;t use vendor\/gems anymore, but vendor\/bundle. The idea is almost the same though.<br \/>\nHere is the task you need, in order to make bundler unpack the gems there:<\/p>\n<pre lang=\"ruby\">\r\nnamespace :bundler do\r\n  set :bundle_dir, File.join(release_path, 'vendor\/bundle')\r\n  \r\n  task :create_symlink, :roles => :app do\r\n    shared_dir = File.join(shared_path, 'bundle')\r\n    run(\"mkdir -p #{shared_dir} && ln -s #{shared_dir} #{bundle_dir}\")\r\n  end\r\n \r\n  task :bundle_new_release, :roles => :app do\r\n    bundler.create_symlink\r\n    run \"cd #{release_path} && bundle install #{bundle_dir} --without test\"\r\n  end\r\nend\r\n \r\nafter 'deploy:update_code', 'bundler:bundle_new_release'\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today I tried to deploy a new Rails 3 project using beloved Capistrano. When it came to installing the gems after the deployment process however, although I found an almost ready to use task for Capistrano, I stumbled upon a severe issue: Whenever bundler tried to install gems, I was automatically asked for my root [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":10,"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/posts\/21\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hacksrus.net\/blog\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}