The --deployment flag requires a Gemfile.lock
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
Admin
Updated on August 02, 2022Comments
-
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 about 11 yearsI 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 about 11 yearsIt depends on your version control. If you use git run
git add Gemfile.lock
(remove it from your.gitignore
first if needed). -
Admin about 11 yearsYes, checked those articles, there is nothing in the releases folder.
-
Prakash Murthy about 11 yearsAfter you added the
deploy.rb file
: Set the:deploy_to
param to a path. Right now, it is getting set tofxtofx
. With that, where would capistrano deploy the files to? Set it to an absolute path like/var/#{application}
. -
Michaël Witrant about 11 yearsCapistrano pulls your app from the remote repository. Did you push your changes before the deploy?
-
Admin about 11 yearsI am not using github. I have used set :deploy_via, :copy
-
Admin about 11 yearsPrakash - 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 about 11 yearsHow is capistrano able to find
fxtofx/releases
? Or for that matter how do you go tofxtofx/releases
? Shouldn't it be/fxtofx/releases
or/usr/fxtofx/releases
or something starting from the root? -
Admin about 11 yearsOk .. I can see what you are pointing out. When I am using
/#{application}
, I am getting an errormkdir: cannot create directory /fxtofx'
. my linux skills may not be the best. -
Prakash Murthy about 11 yearsCreate the base directory (
/fxtofx
or/var/fxtofx
to follow conventions) manually on the server; and then try deploying. -
Michaël Witrant about 11 yearsYou 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 about 11 years
-
Admin about 11 yearsOn my server:
cd ~
, thenmkdir /fxtofx
, I am getting an error of permission denied. Even if I create the directory using sudo, thendeploy:setup
gives the error -
Iaan Krynauw about 6 yearsset :bundle_gemfile, -> { release_path.join('Gemfile') } this worked for me.
-
Dan over 3 yearsThis solved it for me, however I had to remove the line from
~/.bundle/config
, which took me a few minutes to find.