The --deployment flag requires a Gemfile.lock

11,485

Solution 1

Make sure there is nothing in the releases folder that is not a release. See this comment on a bundler issue for more details.

This blogpost titled Capistrano Deployment Trouble explains the same issue.

EDIT TO INCLUDE CONCLUSION FROM DISCUSSION IN COMMENTS

The deploy_to param was not set to an absolute path; hence capistrano wasn't able to find the folder to deploy, causing this error message.

Solution 2

Remove BUNDLE_FROZEN: "true" from .bundle/config file and run bundle again.

Solution 3

I solve this with:

set :bundle_gemfile, "your_app_name/Gemfile"

in the deploy.rb

Share:
11,485
Admin
Author by

Admin

Updated on August 02, 2022

Comments

  • Admin
    Admin over 1 year

    I have spent couple of hours but unable to solve this problem.

    When I try to deploy my local rails app to production server using capistrano I get the below error:

    The --deployment flag requires a Gemfile.lock. Please make sure you have checked your Gemfile.lock into version control before deploying.
    

    Any idea on how to solve this?

    My rails application folder is under version control using Git. I have pushed the local git repo to github and the Gemfile.lock is there on github. So it is under version control. However capistrano continues to give the same error.

    Deploy.rb file: https://gist.github.com/brahmadpk/4748991

  • Admin
    Admin about 11 years
    I can see a Gemfile.lock in my rails directory. As I mentioned in the question my rails directory is under version control. How to add Gemfile.lock specifically?
  • Michaël Witrant
    Michaël Witrant about 11 years
    It depends on your version control. If you use git run git add Gemfile.lock (remove it from your .gitignore first if needed).
  • Admin
    Admin about 11 years
    Yes, checked those articles, there is nothing in the releases folder.
  • Prakash Murthy
    Prakash Murthy about 11 years
    After you added the deploy.rb file: Set the :deploy_to param to a path. Right now, it is getting set to fxtofx. With that, where would capistrano deploy the files to? Set it to an absolute path like /var/#{application}.
  • Michaël Witrant
    Michaël Witrant about 11 years
    Capistrano pulls your app from the remote repository. Did you push your changes before the deploy?
  • Admin
    Admin about 11 years
    I am not using github. I have used set :deploy_via, :copy
  • Admin
    Admin about 11 years
    Prakash - my application directory is 'fxtofx' on the server. Hence I am using #{application}. So the directory structure is fxtofx/releases etc. is there any issue using it that way?
  • Prakash Murthy
    Prakash Murthy about 11 years
    How is capistrano able to find fxtofx/releases? Or for that matter how do you go to fxtofx/releases ? Shouldn't it be /fxtofx/releases or /usr/fxtofx/releases or something starting from the root?
  • Admin
    Admin about 11 years
    Ok .. I can see what you are pointing out. When I am using /#{application}, I am getting an error mkdir: cannot create directory /fxtofx' . my linux skills may not be the best.
  • Prakash Murthy
    Prakash Murthy about 11 years
    Create the base directory (/fxtofx or /var/fxtofx to follow conventions) manually on the server; and then try deploying.
  • Michaël Witrant
    Michaël Witrant about 11 years
    You may try set :copy_strategy, :export, but I can't see why capistrano won't copy Gemfile.lock if it's tracked by git. The doc says "the SCM checkout command is used to obtain the local copy" (github.com/capistrano/capistrano/blob/master/lib/capistrano‌​/…)
  • Admin
    Admin about 11 years
  • Admin
    Admin about 11 years
    On my server: cd ~, then mkdir /fxtofx, I am getting an error of permission denied. Even if I create the directory using sudo, then deploy:setup gives the error
  • Iaan Krynauw
    Iaan Krynauw about 6 years
    set :bundle_gemfile, -> { release_path.join('Gemfile') } this worked for me.
  • Dan
    Dan over 3 years
    This solved it for me, however I had to remove the line from ~/.bundle/config, which took me a few minutes to find.