I'm tired of entering the name of my app each time I run a heroku command in the terminal:
heroku run rake db:migrate --app myapp
heroku run rake db:seed --app myapp
heroku run rake sth:else --app myapp
The --app is very redundant and annoying, I didn't figured out where were the option to configure it globally once for the project.
heroku doesn't require the --app argument when it knows which app it should talk to. This occurs when there is exactly one Git remote pointing to Heroku for a repository.
You don't appear to have any remotes pointing to Heroku. Run
heroku git:remote --app myapp
to add such a remote. Once that's done you should be able to omit the --app argument for heroku commands on that particular repository.
If you prefer to do this yourself you can run
git remote add heroku git#heroku.com:myapp.git
Note that it's possible to have multiple Heroku remotes, e.g. if you have a staging and a production app. In this case you will also have to provide the --app argument to specify which one should be used.
Related
I want to restore the backup from staging to demo
I followed the documentation on heroku and combed through SO but no luck so far.
I am using Windows 7 and versions are:
heroku/toolbelt/2.33.2 (i386-mingw32) ruby/1.9.2
Ruby: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
Rails: 3.2.7
Steps:
$heroku pgbackups:capture
HEROKU_POSTGRESQL_ONYX_URL (DATABASE_URL) ----backup---> b004
←[0KCapturing... donet |
←[0KStoring... done
$heroku pgbackups:url
"https://s3.amazonaws.com/hkpgbackups........."
I know the command above is not required but I did it anyway just to make sure that a url is generated for backup db.
and the command for restore:
$heroku pgbackups:restore --remote demo DATABASE 'heroku pgbackups:url'
**! Backup not found**
Just to be sure, I tried the following other formats of the command:
heroku pgbackups:restore --remote demo DATABASE 'heroku pgbackups:url --remote staging'
heroku pgbackups:restore --app demoapp DATABASE 'heroku pgbackups:url --app stagingapp'
They both are resulting in Backup not found error
I also tried with the name of the db on demo:
$heroku pgbackups:restore HEROKU_POSTGRESQL_ROSE 'heroku pgbackups:url --remote staging' --remote demo
! Backup not found
Please help!
Use backquotes instead of single quotes.
` heroku pgbackups:url -a source-app `
Log into your heroku control panel and make sure the version of PGbackup you have isn't depreciated
I've upgraded my app from Bamboo to Cedar following the instructions here. My problem now is whenever I run any heroku command on the new heroku app I receive the following error
$ heroku run rake db:migrate --app my-app
Running `rake db:migrate` attached to terminal... up, run.1
Error: No such file or directory
The error does not tell me which file is causing this problem so most of the related posts haven't been applicable to this particular problem
The same error occurs for heroku run console, or even heroku run why_wont_this_work
I attempted heroku update, was yelled at for not having the Heroku Toolbelt, installed that, and still get yelled at for not having the Heroku Toolbelt.
I can find my apps in heroku apps command, and also do some command to read information from app like heroku addons --app appname.
But I couldn't find my apps in some command like heroku addons:add addon_name, heroku pg:reset.
Work commands
heroku apps:
=== My Apps
my_app_1
my_app_2
(Also I can see my apps in heroku web dashboard.)
heroku addons --app my_app_1(not in my_app_1 folder):
=== my_app_1 Configured Add-ons
shared-database:5mb
heroku addons(in my_app_1 folder):
=== my_app_1 Configured Add-ons
shared-database:5mb
Doesn't work commands
heroku addons:add sendgrid(in my_app_1 folder):
! No app specified.
! Run this command from an app folder or specify which app to use with --app
heroku pg:reset DATABASE --confirm my_app_1(in my_app_1 folder):
Resetting SHARED_DATABASE (DATABASE_URL)... failed
! Resource not found
Here is my environment.
Max OS X Lion (10.7.4)
rvm 1.13.8 (stable)
ruby 1.9.3p194
heroku 2.26.5
Adding the heroku's remote configuration to git did the trick for me. Validate if you have it configured with git remote -v on the terminal and you should get something like:
heroku git#heroku.com:your-app.git (fetch)
heroku git#heroku.com:your-app.git (push)
if you don't, add it with
git remote add heroku git#heroku.com:your-app.git
It looks like the latest version fo the Heroku gem (2.26.5) is broken. A workaround is to downgrade to 2.26.3.
gem uninstall heroku -v 2.26.5
gem install heroku -v 2.26.3
It looks like you have a conflict between the Heroku gem, and the Heroku Toolbelt. I'm guessing you have installed the Heroku Toolbelt, but still have the Heroku gem in your gem file.
Remove the Heroku gem from your Gemfile and save.
Run the bundle command to update your Gemfile.lock
In Terminal, run gem uninstall heroku (NOTE: there may be multiple versions of the Heroku gem installed, and you'll need to uninstall all of them.)
In Terminal, run heroku addons
If you get heroku: command not found then you don't have the Heroku Toolbelt installed.
Install the Heroku Toolbelt and run the command again.
NOTE: If you're not in the app's directory, you'll need to add --app myapp1 to the Heroku commands.
Hope this helps.
I'm currently using asset_sync in my Rails app, and I have the environment variables set in my Heroku app. When I run heroku config I get:
AWS_ACCESS_KEY_ID: XXXXXXXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY: XXXXXXXXXXXXXXXXXX
FOG_DIRECTORY: MY-BUCKET-NAME
FOG_PROVIDER: AWS
etc...
When I push my app to Heroku, it tries to run rake assets:precompile and I get the following message:
Preparing app for Rails asset pipeline
Running: rake assets:precompile
/usr/local/bin/ruby /tmp/build_2pa7aisux9av8/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
AssetSync: using /tmp/build_2pa7aisux9av8/config/initializers/asset_sync.rb
rake aborted!
Fog directory can't be blank, Aws access key can't be blank, Aws secret access key can't be blank
But then I run:
heroku run rake assets:precompile --app my-app-name
...and it processes everything and syncs to S3 just fine:
Running `rake assets:precompile` attached to terminal... up, run.1
/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets
AssetSync: using /app/config/initializers/asset_sync.rb
/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=staging RAILS_GROUPS=assets
AssetSync: using /app/config/initializers/asset_sync.rb
AssetSync: Syncing.
Using: Directory Search of /app/public/assets
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css.gz
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css.gz
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css
AssetSync: Done.
Any ideas why it wouldn't work during the push but it would work fine when I heroku run rake assets:precompile?
I had the same problem on one of our servers, until I found the documentation on the asset_sync github page that says you need to run
heroku labs:enable user-env-compile --app <appname>
in order for it to work.
Heroku also has AssetSync documentation
It's so nice to only be compiling assets once now
I can see you're running the assets:precompile rake task with --app my-app-name option. Just to be sure, do you have multiple apps on Heroku? (eg. staging and production). If you do make sure make sure running heroku config --app my-app-name results in the output you had with heroku config.
If you had the expected results with the above command, it's likely the ENV vars aren't available on git push as suggested here asset_sync_test github readme . You can go around that by using the following in your config/environments/*.rb file:
config.asset_sync.aws_access_key = ENV['AWS_ACCESS_KEY_ID']
config.asset_sync.aws_access_secret = ENV['AWS_SECRET_ACCESS_KEY']
config.asset_sync.aws_bucket = ENV['FOG_DIRECTORY']
config.asset_sync.fog_provider = ENV['FOG_PROVIDER']
I have a Node project that is using Bundler and Guard to handle my pre-compilations steps.
This means that I have a Gemfile in the root of my project along with the package.json file.
My problem is that Heroku believes that my project is a Ruby app, just because the Gemfile exists. And complains that I have not committed the Gemfile.lock, which I don't want to commit.
-----> Heroku receiving push
-----> Ruby app detected
!
! Gemfile.lock is required. Please run "bundle install" locally
! and commit your Gemfile.lock.
!
! Heroku push rejected, failed to compile Ruby app
Is there a way to tell Heroku that the app is a Node app and not a Ruby app?
The solution to this, with a lot of help from Heroku Support is: use a build pack!
Override the Heroku default buildpacks by specifying a custom buildpack in the BUILDPACK_URL config var
$ heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs
You can also specify a buildpack during app creation
$ heroku create -s cedar --buildpack https://github.com/heroku/heroku-buildpack-nodejs
Simple when you know it. Some more documentation can be found at Heroku Dev Center
It seems there's a new way to do this as BUILDPACK_URL is now deprecated, explained here, but essentially the command is:
$ heroku buildpacks:set heroku/nodejs
You may also specify a buildpack during app creation:
$ heroku create myapp --buildpack heroku/nodejs