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

  • Managing secret keys
  • aws codedeploy git revision during deploy
  • Amazon secret keys and Heroku
  • AWS Elastic Beanstalk Git saying “Already Up-To-Date”
  • AWS CodeDeploy Github File Already Exist
  • Selecting other branch instead of master as a source repository on AWS CodeBuild
  • 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.

  • git error “Cannot rewrite branch(es) with a dirty working directory”
  • git pull does nothing
  • How can I install Git on FreeBSD after error code 1?
  • hg to git conversion and subrepo merge
  • How to discard local commits in Git?
  • GIT: is a tag unique per commit?
  • 2 Solutions collect form web for “Bundle command not found while deploying rails app in aws using mina”

    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
    

    You can invoke the rvm with this configuration

    task :environment do
      # If you're using rbenv, use this to load the rbenv environment.
      # Be sure to commit your .ruby-version or .rbenv-version to your repository.
      # invoke :'rbenv:load'
    
      # For those using RVM, use this to load an RVM version@gemset.
      invoke :'rvm:use', 'ruby-x.x.x'
    end
    
    Git Baby is a git and github fan, let's start git clone.