The --deployment flag requires a Gemfile.lock - ruby-on-rails-3

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

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

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.

I solve this with:
set :bundle_gemfile, "your_app_name/Gemfile"
in the deploy.rb

Run bundle and add your Gemfile.lock to your version control.

I had the same problem, even though I had no files or folders in the releases folder. Turned out it was a silly little thing: the gemfile.lock file in my repo was in lowercase for some reason, while capistrano needs Gemfile.lock with a capital G.
This is how I solved it:
Delete gemfile.lock
Delete gemfile.lock from you repo (git rm ...)
run bundle install
add the new Gemfile.lock file to your repo: git add Gemfile.lock
remove the folders from the server (don't know if this is really needed, did it anyway)
deploy

After adding bundle config unset deployment this line in the terminal, bundle install started working again for me.

I am getting exactly the same problem.
There is nothing in my releases folder (at all - my deploy cold keeps rolling back).
My gemfile.lock is checked in to Subversion.
I get:
** [out :: localhost] The --deployment flag requires a Gemfile.lock. Please make sure you have checked your Gemfile.lock into version control before deploying.
Is there any way to stop the rollback so that I can see what the releases folder looks like at the time it tries to run
cd /var/qlarity/releases/20130222003607 && bundle install --gemfile /var/qlarity/releases/20130222003607/Gemfile --path /var/qlarity/shared/bundle --deployment --quiet --without development test
Later....
I found that I could prevent the rollback by commenting out the code as shown from
gems\capistrano-2.14.1\lib\capistrano\recipes\deploy.rb
task :update_code, :except => { :no_release => true } do
# on_rollback { run "rm -rf #{release_path}; true" }
strategy.deploy!
finalize_update
end
This enabled me to examine my releases folder and sure enough, there was no Gemfile.lock in it. Turns out I have ended up with an unnecessary folder in my Rails project file structure so that instead of
myapp/trunk/app
myapp/trunk/config
...
myapp/trunk/Gemfile
I had
myapp/trunk/myapp/app
myapp/trunk/myapp/config
...
myapp/trunk/myapp/Gemfile
This meant I ended up with a folder containing my Gemfile
releases/nnnn/myapp
and bundle was looking for Gemfile in
releases/nnnn
When I changed my Capistrano config from
deploy.rb
set :repository, "file:///D:/_SVN//myapp/trunk"
to
deploy.rb
set :repository, "file:///D:/_SVN//myapp/trunk/myapp"
now all is good. Really should look at fixing the folder structure next!

Related

Incorrect path for Pods-testAppTests/Pods-testAppTests.debug.xcconfig: unable to open file

So I recently uploaded my react-native project on GitHub, then cloned it back to see how it will build(did it for first time... yeah). And on react-native run-ios I got a repetitive error: "react-native-app/ios/Pods/Target Support Files/Pods-testAppTests/Pods-testAppTests.debug.xcconfig: unable to open file (in target "testAppTests" in project "testApp") (in target 'testAppTests' from project 'testApp')
I found a solution, where this:
cd ios
pod deintegrate
pod install
helped me as the project then built and ran correctly.
So my question is, how to upload it to GitHub in a way so it builds always correctly after cloning it?
Update
Checking and editing .gitignore solved this problem.
Maybe this is linked to files which have been added/committed, while they should have been ignored, private and local only (not uploaded to GitHub)
Check your .gitignore: here is one for ReactNative, as explained in "Creating a .gitignore for a Clean React Repository", blog post written by Parker Johansen.
Then, assuming you don't have any pending changes/work in progress, you can, as explained here, apply your new .gitignore to your existing repository:
cd /path/to/local/cloned/repo
# create your .gitignore
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
git push
Finally, clone it again, and see if it compiles better.
The OP adds in the comments:
I found that folder 'Pods' doesn't exist on GitHub, that's why this error occurs, how can I add it to my /ios folder on Github correctly
I advise to check if there is a .gitignore rule which would ignore said folder:
git check-ignore -v Pods/aFile_inside_Pods

AppCenter doesn't seem to run pod install despite existence of Podfile

I've got a react-native app that builds on AppCenter. I have a Podfile in my /ios directory, and locally, I can run pod install. The AppCenter documentation says that "App Center scans the selected branch and if it finds a Podfile, it will automatically do a pod install step at the beginning of every build. This will ensure that all dependencies are installed.", but as far as I can tell, it's not running pod install for my build and the build fails for that reason.
Tried adding pod install to a pre-build script, in which case the build succeeds.
Make sure the Cocoapods version running on the build agent matches the one on your podfile.lock.
You can add a post clone script like this on your ios/ folder:
appcenter-post-clone.sh This will automatically install the matching cocoapods version.
Push that file to your repo, then make sure you open the build configuration and hit Save and Build.
It appears that in addition to having a Podfile, you must NOT have a ios/Pods folder present. In my case, I also had to explicitly add that folder to my .gitignore

Deploying Laravel 4 with Capistrano. Permission denied during `composer install`

I'm trying to use Capistrano to deploy my Laravel 4 site and when I try to:
run "cd #{current_path} && composer install --no-dev"`
in my deploy.rb I get this error:
sh: 1: composer: Permission denied
and a few lines later:
failed: "sh -c 'cd /var/www/public/mysite/current && composer install --no-dev'" on root#my.ip.add.ress
If I comment out the run command above then Capistrano is able to complete the deployment successfully. However, I then have to manually run composer install from the current release directory of my site in order to get everything on my site working properly.
I've tried running my deploy with the -d flag to go through the deployment step by step, I've tried fixing permissions in case they were incorrect, but neither seems to fix this error. Also, I've looked all over for a possible answer and can't find anyone else with this specific issue.
So, I have two questions:
Any ideas of a fix to this?
It seems like running composer install each time I deploy is just creating more work than is necessary. Would it be better to either:
a) not ignore the vendor folderin my local repository therefore removing the need to runcomposer install` on each deploy? Or,
b) run composer install in the root directory (at the same directory level as current and releases) and then change the path to vendor/autoload.php in the bootstrap directory to point to this new directory so I never need to run composer install again?
I figured it out. Instead of:
run "cd #{current_path} && composer install --no-dev"
I'm doing this instead:
run "cd #{releases_path}/#{release_name} && php /usr/local/bin/composer/composer.phar install --no-dev"
(I changed #{current_path} to #{releases_path}/#{release_name} because Capistrano was executing rm -f /var/www/public/myapp/current AFTER the composer install command.

Duplicate assets after deployment of app in Heroku

I'm very new with rails development and deployment using Heroku.
So recently I found that some JavaScript files that seems to be duplicated. For example I made a javascript function in one file (sample.js), then I erased this file, and I put the function inside of application.js.
Under my test development, it works perfect. But then when I commit the changes to heroku, I end up having the same function twice!
The javascript files are under the folder /app/assets/javascripts/
So how can I tell heroku to remove the duplicate files?
Am I missing some step before sending new version of my app to heroku?
Any help will be greatly appreciated
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
Rails 3.1.0
You're only deleting files from the repo when you use the git rm command. Even if you delete the actual file, it's still in the repo, and won't be changed by the git add -f * command (which only adds changed files).
You should be able to remove the file from heroku by running these commands:
$ git rm app/assets/javascripts/sample.js
$ git commit -m 'your commit message'
$ git push heroku master

How can I remove a gem from my Rails 3 project without getting this really strange Bundle error?

The error is:
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
WHAT VERSION CONTROL? Why/how does Bundle know anything about version control? I just removed a line from my Gemfile. Am I not supposed to do that?
Do rm -rf .bundle && bundle install from your project root.