I have been working on a rails app and been deploying regularly to heroku using local git depository. I accidentally ran the command:
bundle install --deployment
It seems it downloaded all the gems to the local folder, and now when I want to upload to heroku it is trying to upload many megabytes of gems... How do I undo the command I ran and delete the local gems? How do I prevent bundle install from downloading all gems again?
Wanted to make this an answer because it was jrochkind comment that helped
rm -rf vendor/bundle
The f in -rf ignores the questions asking if you want to really remove this file.
bundle install --no-deployment
The above will disable bundle deployment mode and install needed packages in a non production enviroment
git add .
git commit -m "fixed deployment bundle"
git push heroku master
The above will add all your lock file to git, create a commit with the new update. It will then send your fixed lock file to your master branch to Heroku master branch (It only has a master) along with any other changes you have done.
If you need to send a different branch to Heroku other than your master then instead of git push heroku master run the following code:
git push heroku development:master
The above command will push your development branch to the Heroku master branch. change development to the branch name you want to send to Heroku.
You may try this:
First, remove all your local gems.
rm -r vendor/bundle
Bundle again
bundle install
Run git add --all
Commit and push again to heroku.
Edit Bundler config file at your app root path .bundle/config and remove following line:
BUNDLE_DEPLOYMENT: "true"
Or with oneliner:
sed '/BUNDLE_DEPLOYMENT: "true"/d' .bundle/config
Related
So how exactly does one commit .openshift/markers/force_clean_build to force a clean bundle? As per results from git push below...
remote: NOTE: You can commit .openshift/markers/force_clean_build to force a clean bundle
remote: NOTE: Skipping 'bundle install' because Gemfile is not modified.
It looks like you just need to add an empty force_clean_build file in the .openshift/markers directory, add/commit it to git, and push that:
cd app_name
touch .openshift/markers/force_clean_build
git add .openshift/markers/force_clean_build
git commit -m "Force a clean bundle"
See http://atodorov.org/blog/2012/02/18/how-to-update-dependencies-on-openshift/ for an overview of this.
I want to git push to my rails app. I can't seem to find any information about it.
I want my rails app to be something like Heroku in a sense I could git push to it, though obviously building is a whole other matter.
How to be able to git push to rails app?
To Push into git you can follow those steps one after another
$ cd my_project
$ git init
$ git add *
$ git commit -m "My initial commit message"
$ git remote add origin git#example.com:my_project.git
$ git push -u origin master
To Push you rails app to heroku you have to follow the following steps
First install gem heroku
$ gem install heroku
then, Login to heroku with your credentials
$ heroku login
then, Add following gem to your Gemfile
group :production do
gem 'pg'
gem 'rails_12factor'
end
Make sure you add a specific ruby version in your Gemfile, ex: ruby '2.1.2'
run $ bundle install
Create heroku app
$ heroku create
Push to heroku
$ git push heroku master
Run migrations
$ heroku run rake db:migrate
that's it :) Here is a great documentation on heroku page, you can see for more details.
I haven't been able to get Heroku to update my app for some reason. This is the first app I've had problems with this happening. I've tried a couple different methods, but everything I've tried just says in the command "everything is up to date." and when I check heroku, it's just an early version of my app. Any idea why it won't update on Heroku?
Here is what I've tried:
$ bundle exec rake test
$ git add -A
$ git commit -m "..."
$ git checkout master
$ git merge blah
$ bundle exec rake test
$ git push
$ git push heroku
$ heroku run rake db:migrate
and I've also tried this as well:
$ git status
$ git add .
$ git commit -m "..."
$ git push heroku master
$ heroku run db:migrate
Heres the git status:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Here's trying to force it
$ git push heroku master --force
Everything up-to-date
Here's with git remote -v
heroku https://git.heroku.com/stupidapp1.git (fetch)
heroku https://git.heroku.com/stupidapp1.git (push)
origin https://github.com/Tyrantt47/stupidapp1.git (fetch)
origin https://github.com/Tyrantt47/stupidapp1.git (push)
Curtis, I feel like this answer could be judged as the antithesis of a good dev, but if you have the code you want to deploy checked into version control and locally, why not just push it to a new Heroku app.
If the name of the repository is any indication of the scale of the application, I would say try it and see the results.
Heroku provides good documentation on migrating a database from one app to another and its add-on services are easy to get setup, if either one of those are a concern.
Food for thought...
I think that the syntax is
git push -f heroku master
Is it possible to automatically precompile my assets in a Rails app before pushing out to Heroku? I always forget to do it, so it would be nice if when I typed git push heroku master, it would first run rake assets:precompile ; git commit add . ; git commit -a -m "Precompile.", or something to that effect.
Has anyone achieved such a solution? Possibly without hooks? Though I suspect that is the only way.
I finally figured this out. I was indeed on the Cedar stack. The problem was that I had checked my public directory into Git, and when I pushed to Heroku, it realized that public existed, and thus assumed I precompiled. Running git rm -r public and adding public/** to my .gitignore, then pushing, fixes the problem.
It sounds like you might not be on Heroku's Cedar Stack? If you're using the asset pipeline (Rails -v >= 3.1), cedar provides three options for compiling assets.
From the docs:
If you have not compiled assets locally, we will attempt to run the
assets:precompile task during slug compilation.
You could always alias heroku or something similar to rake assets:precompile ; git commit add . ; git commit -a -m "Precompile." ; git push heroku master in your bash profile
ie
#in ~/.bash_profile
alias precompile_push='rake assets:precompile ; git commit add . ; git commit -a -m "Precompile." ; git push heroku master'
On the cedar stack, it will do this during slug compilation. I recommend that.
I've created a gem that run as daemon and automatically pull changes from a Git repo, precompiles assets, commit and push back.
https://github.com/nectify/rails-precompile2git/
Everytime I try to deploy my rails app onto heroku it says
Michael$ heroku create
Creating stormy-window-812..... done, stack is bamboo-mri-1.9.2
http://stormy-window-812.heroku.com/ | git#heroku.com:stormy-window-812.git
Michael$ git push heroku master
! Invalid path.
! Syntax is: git#heroku.com:.git where is your app's name
fatal: The remote end hung up unexpectedly
I'm not sure what's wrong. I do a normal heroku create and my git is working for github to load code. Is there something I'm missing? The path seems to be the right format so I don't know that the problem is.
Your .git/config is borked.
Ensure that the remote for heroku points to:
git#heroku.com:stormy-window-812.git
There must be a bit of misstep somewhere in your process, I created a sample app, using the following commands - hopefully this will help you identify where things aren't going right.
Just the list of commands:
$ rails new sample_app
$ cd sample_app/
$ git init
$ git add .
$ git commit -m "Initial commit"
$ heroku create
$ git push heroku master
$ heroku open
And the commands, with some truncated output:
$ rails new sample_app
create
create README
create Rakefile
create config.ru
create .gitignore
# ..snip..
$ cd sample_app/
$ git init
Initialized empty Git repository in /sample_app/.git/
$ git add .
$ git commit -m "Initial commit"
[master (root-commit) 487a313] Initial commit
37 files changed, 1138 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
create mode 100644 README
# ..snip..
$ heroku create
$ git push heroku master
Counting objects: 63, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (47/47), done.
Writing objects: 100% (63/63), 24.81 KiB, done.
Total 63 (delta 2), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for http://rubygems.org/
Installing rake (0.9.2)
Installing multi_json (1.0.3)
Installing activesupport (3.1.0.rc6)
# ..snip..
-----> Compiled slug size is 5.6MB
-----> Launching... done, v4
http://gentle-water-874.heroku.com deployed to Heroku
To git#heroku.com:gentle-water-874.git
* [new branch] master -> master
$ heroku open
I think you need to cd into your app directory. Then do the push again.
Also, make sure you add heroku as your remote then you can try again:
git remote add heroku git#heroku.com:appname.git
I had this problem after renaming my app. If you do
heroku rename newname
you will then have to do
git remote rm heroku
git remote add heroku git#heroku.com:newname.git
My .git/config was clearly dorked - I attempted changing to first_app as shown above (newby: RoR Tutorial chapter 1) several times. Deleting the /.git/config and doing the steps above starting with 'git init' fixed the config: url = git#heroku.com:dry-eyrie-8108.git
It also be as simple as:
$ heroku login
$ heroku git:clone -a appname ( this line right here solved it for me)
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Not sure if anyone else has ran into this same misunderstanding. The error from heroku mentions the url to your app needs to meet this syntax, "https://git.heroku.com/my-app.git".
This did not work for me. However, the syntax, "my-app.herokuapp.com", resolved the error.