Raaz Raaz - 4 years ago 220
Git Question

Bundle command not found while deploying rails app in aws using mina

While deploying my rails app using mina, I have got error like

bash: line 82: bundle: command not found
. I have googled but I could not find any solutions. How do I fix this?

This is my deploy.rb

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'


set :user, 'ubuntu'
set :domain, 'www.fuitter.com'
set :deploy_to, '/usr/share/nginx/html/fuitter'
set :repository, 'git@bitbucket.org:mc_cannibal/fuitter2.git'
set :branch, 'master'
set :forward_agent, true


set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']


task :environment do
ruby_version = File.read('.ruby-version').strip
raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
queue %{
source /etc/profile.d/rvm.sh
rvm use #{ruby_version} || exit 1
}
end

task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]

queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]

# Add the repository server to .ssh/known_hosts
if repository
repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first
repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'

queue! %[
if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
fi
]
end

# Create database.yml for Postgres if it doesn't exist
path_database_yml = "#{deploy_to}/#{shared_path}/config/database.yml"
database_yml = %[production:
database: fuitter
adapter: postgresql
pool: 5
timeout: 5000]
queue! %[ test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml} ]

# Create secrets.yml if it doesn't exist
path_secrets_yml = "#{deploy_to}/#{shared_path}/config/secrets.yml"
secret =
secrets_yml = %[production:
secret_key_base:
#{`rake secret`.strip}]
queue! %[ test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml} ]

queue! %[chmod g+rx,u+rwx,o-rwx "#{deploy_to}/#{shared_path}/config"]

end

desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'

to :launch do
#queue "service #{user} restart"
end
end
end


Should I push the deploy.rb file in version control?
PS I have rvm installed.

Answer Source

Ok I have fixed it. I had put the wrong rvm path. After running which rvm , I copied that path and pasted it here.

 task :environment do
  ruby_version = File.read('.ruby-version').strip
  raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
  queue %{
    source path/to/rvm
    rvm use #{ruby_version} || exit 1
  }
end
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download