Heroku run rake db:reset error - ruby-on-rails-3

I am trying to reset my Heroku database. I am getting the following error:
** Invoke environment
** Execute db:abort_if_pending_migrations
rake aborted!
uninitialized constant Object::State
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
/app/db/seeds.rb:9:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/engine.rb:520:in `load'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/engine.rb:520:in `load_seed'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.2/lib
Line 9 of seed.rb is State.create(name: 'Alaska', abbrev: 'AK' );
The model is defined.
Any help?

The rake db:reset task is not supported. Heroku apps do not have permission to drop and create databases. Use the heroku pg:reset command instead.

Related

Running into issues installing gitlab-shell

I am trying to install Gitlab CE from source and following this installation guide.
When I attempt to install the gitlab-shell using the command provided.
sudo -u git -H bundle exec rake gitlab:shell:install REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production SKIP_STORAGE_VALIDATION=true
I received the following stack trace error.
WARNING: This version of GitLab depends on gitlab-shell 4.1.1, but you're running Unknown. Please update gitlab-shell.
rake aborted!
Gitlab::TaskFailedError: Gitlab::TaskFailedError
/home/git/gitlab/lib/tasks/gitlab/task_helpers.rb:87:in `run_command!'
/home/git/gitlab/lib/tasks/gitlab/task_helpers.rb:164:in `clone_repo'
/home/git/gitlab/lib/tasks/gitlab/task_helpers.rb:157:in `checkout_or_clone_tag'
/home/git/gitlab/lib/tasks/gitlab/shell.rake:16:in `block (3 levels) in <top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:in `<main>'
Tasks: TOP => gitlab:shell:install
What config file should I be modifying to fix my issue? Do I need to modify the Redis URL even though I am using the default configuration? By the way, this install is on an Ubuntu 16.04 server.
This might be caused by using a version of git that is too old.
To debug: append the --trace option to bundle exec to get more info on where this error is coming from and inspect the source.

Error: migrate SQLite to Postgres

I developed my app with the standard configuration (SQLite 3). I want do deploy on heroku and have to change to postgresql.
But I get this error, when trying to migrate my db-schema.
rake db:migrate
rake aborted!
/Users/adrianschnell/Sites/bills_cmd/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
...sion_store :cookie_store, key: '_bills_cmd_session'
^
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:588
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/adrianschnell/Sites/bills_cmd/config/environment.rb:8
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:297:in `initialize_tasks'
Tasks: TOP => db:migrate => environment
I don't know what i have to do now.
My Gem File has included 'pg' and my database.yml looks like:
# PostgreSQL v0.8.x
# gem install pg
development:
adapter: postgresql
encoding: unicode
database: bills_cmd_dev
pool: 5
username: adrianschnell
password:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: bills_cmd_test
pool: 5
username: adrianschnell
password:
PostgreSQL is running - via terminal i can access it.
EDIT:
I noticed, that I get the following error when trying to create the postgre db:
rake db:create:all
rake aborted!
syntax error on line 18, col 11: `'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application/configuration.rb:115:in `database_configuration'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:25
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
after hours of searching and testing different suggestions, I tried the ones here: stackoverflow
especially the entry of Darren was the solution for me. Now my RoR App is running with postgre.

Rails: Error on rake jobs:work, but Delayed Job not installed

All:
My error logs show heroku crashing on a rake task, rake jobs:work.
The problem is, I don't have a rake task called jobs or work. I only have one, called cron.
In that task, there's no Delayed Job stuff at all, and nowhere does the word 'jobs' or 'work' appear.
I've also looked in the Config files, and no trace of anything about Delayed Job. It's also not in Vendor/plugins.
Any ideas where the hidden rake task might be?
here's the error code:
2012-01-03T20:28:45+00:00 heroku[worker.3]: State changed from crashed to created
2012-01-03T20:28:45+00:00 heroku[worker.3]: State changed from created to starting
2012-01-03T20:28:48+00:00 heroku[worker.3]: Starting process with command `rake jobs:work`
2012-01-03T20:28:48+00:00 app[worker.3]: (in /app)
2012-01-03T20:28:48+00:00 heroku[worker.3]: State changed from starting to up
2012-01-03T20:28:49+00:00 app[worker.3]: rake aborted!
2012-01-03T20:28:49+00:00 app[worker.3]: Don't know how to build task 'jobs:work'
2012-01-03T20:28:49+00:00 app[worker.3]:
2012-01-03T20:28:49+00:00 app[worker.3]: (See full trace by running task with --trace)
2012-01-03T20:28:50+00:00 heroku[worker.3]: State changed from up to crashed
2012-01-03T20:28:51+00:00 heroku[worker.3]: Process exited
2012-01-03T20:28:53+00:00 app[web.9]:
Here's the --trace code
MacBook-Air:patientapp dougsmith$ heroku rake jobs:work --trace
(in /app)
rake aborted!
Don't know how to build task 'jobs:work'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1728:in `[]'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2050:in `invoke_task'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/app/.bundle/gems/ruby/1.8/bin/rake:19:in `load'
/app/.bundle/gems/ruby/1.8/bin/rake:19
MacBook-Air:patientapp dougsmith$
Do you have 1 or more Heroku worker dyno/s configured?
Looks like Heroku default Procfile run the command
worker bundle exec rake jobs:work
for Rails apps. Probably, editing/creating a procfile without this command makes the trick.
More info:
https://devcenter.heroku.com/articles/procfile
This happened to me. I found that delayed job had been in use before I started work on the site. A worker dyno was still configured for it. After removing that dyno the error went away.

rake db:migrate aborted! on US-ASCII using rake 0.9.2.2 and rails 3.0.10

Recently I upgraded my gems and started adding new stuff to my app like authentication by third party social websites using omniauth gem. On development environment everything is fine and works like a charm.
I am deploying to staging and production servers using capistrano. Basic deployment is fine and working so far, but I have got really strange problems when I want to do migrations when deploying.
I get the following error messages from capistrano:
[my.server.com] executing command
*** [err :: my.server.com] rake aborted!
*** [err :: my.server.com] "\xC5" on US-ASCII
*** [err :: my.server.com]
*** [err :: my.server.com] (See full trace by running task with --trace)
command finished in 2472ms
I was googling all around and couldn't find any relevant solution. I also tried to downgrade rake gem back to 0.8.7 but with no success on the end - the same errors.
After hours of googling and digging in I found the solution that (I hope) may by helpful for someone with a similar or the same problem.
I did bundle exec rake --trace db:migrate on the staging server and got the following error messages:
rake aborted!
"\xC5" on US-ASCII
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `read'
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `<top (required)>'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `require'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `<main>'
So I jumped in to the config/application.rb file to find out what could rise the error. Line 5 of that file loads an external config file:
require 'yaml'
APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
and that external file contains UTF-8 chars, not US-ASCII. So I tried a couple of different solutions to solve that problem.
The only one which worked for me was to add an extra few lines of code on top of config/application.rb file:
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
just to tell rake to load external files using utf-8 encoding. After that change everything went smooth and exactly as expected. Problem solved!
PS.
I really don't know why developers of rake 0.9 have changed previous behavior of rake 0.8 which worked fine for me and probably for you as well for a long time. Maybe you have an idea why? I am very curious.

bundle exec rspec VS rspec spec

Ruby 1.9.2 Rails 3.1
Here is the problem bundle exec rspec spec/ does not work, but rspec spec/ runs ok.
When I run c:\RailsInstaller\work\apptwit>bundle exec rspec spec/ (this is the directory where my app is located, so the path to spec would not need to be specified)
I receive
c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `require': no such file to load -- spec_he lper (LoadError)
from c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `load'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `block in load_spec_files'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `map'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `load_spec_files'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in
`run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_i
n_process'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block
in autorun'
/spec directory exists as exists spec_helper.rb in it.
So basically I have 2 questions:
Why doesn't bundle exec rspec spec/ work while rspec spec/ has no problems?
What is the difference between those two commands?
Take a look at this answer. bundle exec changes your $PATH, or %PATH% in case of Windows. As a result, by using bundle exec rspec you're calling the RSpec's version which is specified in your Gemfile. rspec ran without Bundler executes the one in your $PATH.
The error you see might be caused by the fact that the RSpec version in your $PATH is incompatible with Rails version you're working with. The version installed and executed by Bundler (with bundle exec rspec) is compatible and works fine.