rake db:migration not working on travis-ci build - ruby-on-rails

I'm trying to build my Ruby on Rails project from github on Travis-CI, but I 'm running into a migration problem. It runs a rake task for migration, but it complains about the same migration step after that.
It follows my .travis.yml file:
language: ruby
rvm:
- 1.9.2
before_script:
- "rake db:migrate RAILS_ENV=test"
And here's the build output:
1Using worker: ruby4.worker.travis-ci.org:travis-ruby-3
2
3
4
5$ cd ~/builds
6
7
8$ git clone --depth=100 --quiet git://github.com/rafaelportela/bacilo.git rafaelportela/bacilo
9
10
11
12$ cd rafaelportela/bacilo
13
14$ git checkout -qf 7553b7351b7a642e39ea7b55204de6cd4f320c36
15
16
17$ export TRAVIS_RUBY_VERSION=1.9.2
18
19$ rvm use 1.9.2
20Using /home/vagrant/.rvm/gems/ruby-1.9.2-p290
21
22$ ruby --version
23ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
24
25$ gem --version
261.8.17
27
28
29$ export BUNDLE_GEMFILE=/home/vagrant/builds/rafaelportela/bacilo/Gemfile
30
31$ bundle install
32Fetching gem metadata from https://rubygems.org/.......
33Using rake (0.9.2.2)
34Installing i18n (0.6.0)
35Installing multi_json (1.3.4)
36Installing activesupport (3.2.2)
37Installing builder (3.0.0)
38Installing activemodel (3.2.2)
39Installing erubis (2.7.0)
40Installing journey (1.0.3)
41Installing rack (1.4.1)
42Installing rack-cache (1.2)
43Installing rack-test (0.6.1)
44Installing hike (1.2.1)
45Installing tilt (1.3.3)
46Installing sprockets (2.1.3)
47Installing actionpack (3.2.2)
48Installing mime-types (1.18)
49Installing polyglot (0.3.3)
50Installing treetop (1.4.10)
51Installing mail (2.4.4)
52Installing actionmailer (3.2.2)
53Installing arel (3.0.2)
54Installing tzinfo (0.3.33)
55Installing activerecord (3.2.2)
56Installing activeresource (3.2.2)
57Installing bcrypt-ruby (3.0.1) with native extensions
58Installing coffee-script-source (1.3.1)
59Installing execjs (1.3.1)
60Installing coffee-script (2.2.0)
61Installing rack-ssl (1.3.2)
62Installing json (1.7.0) with native extensions
63Installing rdoc (3.12)
64Installing thor (0.14.6)
65Installing railties (3.2.2)
66Installing coffee-rails (3.2.2)
67Installing orm_adapter (0.0.7)
68Installing warden (1.1.1)
69Installing devise (2.0.4)
70Installing jquery-rails (2.0.2)
71Installing pg (0.13.2) with native extensions
72Using bundler (1.1.3)
73Installing rails (3.2.2)
74Installing sass (3.1.16)
75Installing sass-rails (3.2.5)
76Installing sqlite3 (1.3.6) with native extensions
77Installing uglifier (1.2.4)
78Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
79Post-install message from rdoc:
80Depending on your version of ruby, you may need to install ruby rdoc/ri data:
81
82<= 1.8.6 : unsupported
83 = 1.8.7 : gem install rdoc-data; rdoc-data --install
84 = 1.9.1 : gem install rdoc-data; rdoc-data --install
85>= 1.9.2 : nothing to do! Yay!
86
87
88$ rake db:migrate RAILS_ENV=test
89== DeviseCreateUsers: migrating ==============================================
90-- create_table(:users)
91 -> 0.0174s
92-- add_index(:users, :email, {:unique=>true})
93 -> 0.0017s
94-- add_index(:users, :reset_password_token, {:unique=>true})
95 -> 0.0010s
96== DeviseCreateUsers: migrated (0.0239s) =====================================
97
98
99$ bundle exec rake
100You have 1 pending migrations:
101 20120508052346 DeviseCreateUsers
102Run `rake db:migrate` to update your database then try again.
103
104
105Done. Build script exited with: 1
I'd appreciate any suggestion! =]

This blog post helped me tremendously when I was trying to get my Rails 3.2 app working with Travis CI, and write a .travis.yml file that actually worked. Here's mine for your reference, so hope it helps:
.travis.yml
language: ruby
rvm:
- 1.9.2
- 1.9.3
env:
- DB=sqlite
- DB=mysql
- DB=postgresql
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rspec spec/
before_script:
- mysql -e 'create database my_app_test'
- psql -c 'create database my_app_test' -U postgres
bundler_args: --binstubs=./bundler_stubs

Instead of running rake db:migrate RAILS_ENV=test run rake db:test:prepare instead.
This is because rake db:migrate will run all the migrations against your test database, which could take a very long time if you had a lot of migrations. The db:test:prepare task will not do that, instead it will just set up the test database with the schema from db/schema.rb.
Give that a shot and see if that works.

The solution that fixed the problem for me was running:
rake db:schema:load instead of rake db:migrate RAILS_ENV=test

Related

ruby on the rails rake aborted invalid_date

I am trying to run the Rails app 'Simpsons by the Data' (source: https://github.com/toddwschneider/flim-springfield) however whenever I try to run the command bundle exec rake import_data
the following error is returned:
Called from /Users/XXXX/.rvm/gems/ruby-2.3.8/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in 'load_dependency'
rake aborted!
ArgumentError: invalid date
/Users/XXXX/flim-springfield/app/models/episode.rb:52:in 'parse'
I have PostgreSQL 11.1 on MacOS X installed and I have changed the date style from ISO, MDY to ISO DMY as I stupidly thought this would help but it didn't work.
This is my Gem file:
*** LOCAL GEMS ***
bigdecimal (default: 1.3.0)
bundler (2.0.1, default: 1.17.3)
bundler-unload (1.0.2)
did_you_mean (1.1.0)
executable-hooks (1.6.0)
gem-wrappers (1.4.0)
io-console (default: 0.4.6)
json (default: 2.0.2)
minitest (5.10.1)
net-telnet (0.1.1)
openssl (default: 2.0.2)
pg (1.1.4)
power_assert (0.4.1)
psych (default: 2.2.2)
rake (12.3.2, 12.3.1, 12.0.0)
rdoc (default: 5.0.0)
rubygems-bundler (1.4.5)
rvm (1.11.3.9)
test-unit (3.2.3)
xmlrpc (0.2.1)
Has anyone else run into a problem like this while using this Rails app or could even point me in the right direction? I am completely new to this and as this is the first Rails app that I have ever run, I am not sure how to progress. :(
Any help would be really appreciated!

Rails 2.3.8 I18n::UnknownFileType the file type yml is not known

i have an old rails project here running rails 2.3.8 and ruby 1.8.7 with rvm.
when i'm running rake -T or another rake task it will fail with
I18n::UnknownFileType: can not load translations from /home/project/trunk/vendor/rails/activesupport/lib/active_support/locale/en.yml, the file type yml is not known
running some YAML in the console, will work.
i found some solutions for rails 3 and ruby 1.9.3 (Rails 3: 'The file type yml is not known' when trying to access basic _form.html.erb) and rails 2.3 with ruby 2 (Rails legacy app and Ruby 2 error: can not load translations from the file type yml is not known) but didnt help.
my Gems used in this project:
actionmailer (2.3.18)
actionpack (2.3.18)
activerecord (2.3.18)
activeresource (2.3.18)
activesupport (2.3.18)
afm (0.2.2)
Ascii85 (1.0.2)
bundler-unload (1.0.2)
color (1.8)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
hashery (2.1.1)
iconv (1.0.4)
little-plugger (1.1.4)
logging (2.0.0, 1.8.2)
multi_json (1.11.2)
mysql (2.9.1)
pdf-core (0.6.0)
pdf-reader (1.3.3)
pdf-writer (1.1.8)
prawn (2.0.2, 0.12.0)
rack (1.1.6)
rails (2.3.18)
rake (10.4.2, 10.1.1)
ruby-rc4 (0.1.5)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
transaction-simple (1.4.0.2)
ttfunk (1.4.0, 1.0.3)
script/console and script/server running fine.
i have to use ruby 1.8.7 and cannot update. upgrade to rails 3 is'nt possible in month's :)
do you have some idea's to get the rake tasks running?
best
robert
i found the solution:
there was several problems:
rake (10.4.2, 10.1.1) now just using rake 10.1.1
logging (2.0.0, 1.8.2) now just using logging 1.8.2
(after testing) had to replace rdoctask with task in Rakefile
now rake -T works fine

Heroku Ruby version won't upgrade?

I am struggling changing Ruby versions on Heroku.
I use Ruby 2.0.0 with rails 4.
My Gemfile has:
source 'https://rubygems.org'
ruby '2.0.0'
...
The path in Heroku points to:
$ heroku config -s | grep PATH
PATH=bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
When I pushed my app, I could see:
Fetching repository, done.
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 431 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.2)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.0.rc1)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0.rc1)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0.rc1)
Using activemodel (4.0.0.rc1)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using activerecord (4.0.0.rc1)
Using addressable (2.3.5)
Using bcrypt-ruby (3.1.2)
Using coffee-script-source (1.6.3)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0.rc1)
Using coffee-rails (4.0.0)
Using orm_adapter (0.5.0)
Using warden (1.2.3)
Using devise (3.0.4)
Using excon (0.25.3)
Using geocoder (1.1.9)
Using gmapsjs (0.2.30.1)
Using heroku-api (0.3.15)
Using launchy (2.4.2)
Using netrc (0.7.7)
Using rest-client (1.6.7)
Using rubyzip (1.1.0)
Using heroku (3.2.1)
Using hike (1.2.3)
Using jbuilder (1.0.2)
Using jquery-rails (3.0.4)
Using jquery-ui-rails (4.1.1)
Using json (1.8.1)
Using libv8 (3.16.14.3)
Using nifty-generators (0.4.6)
Using pg (0.17.1)
Using bundler (1.3.2)
Using tilt (1.4.1)
Using sprockets (2.10.1)
Using sprockets-rails (2.0.1)
Using rails (4.0.0.rc1)
Using rails_serve_static_assets (0.0.2)
Using rails_stdout_logging (0.0.3)
Using rails_12factor (0.0.2)
Using rdoc (3.12.2)
Using ref (1.0.5)
Using sass (3.2.13)
Using sass-rails (4.0.0)
Using sdoc (0.3.20)
Using therubyracer (0.12.0)
Using turbolinks (2.1.0)
Using uglifier (2.4.0)
Using will_paginate (3.0.5)
Your bundle is complete! It was installed into ./vendor/bundle
Bundle completed (0.46s)
Cleaning up the bundler cache.
Removing rails_log_stdout (01b5bcc572e3)
Removing rails3_serve_static_assets (84910ceb4ca2)
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Asset precompilation completed (3.59s)
Cleaning assets
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby -> console, rake, web, worker
-----> Compressing... done, 33.3MB
-----> Launching... done, v17
http://rocky-shore-1207.herokuapp.com deployed to Heroku
To git#heroku.com:rocky-shore-1207.git
05cf948..73b6cfa master -> master
Since Heroku said Using Ruby version: ruby-2.0.0, it detected my Ruby version.
However, when I run $ heroku run rake db:migrate or heroku run 'ruby -v'
it returned:
Your Ruby version is 1.9.2, but your Gemfile specified 2.0.0
How can I change the Ruby version to 2.0.0 on Heroku?
Conclusion:
I noticed my rails app had .bash_profile file but it had a wrong path. The path disturbed my heroku path for the ruby version.
Thank you for the help everyone :)
Did you execute: bundle update locally and then committed the file Gemfile.lock?
The server is using Ruby 2, but the app is still configured to use the old version if the new lock file is not pushed.
Review the running version:
$ heroku run console
> RUBY_VERSION
If the version is correct, the one you specified, then you have a bundler problem. Just reinstall it.
gem install bundler
I recommend a full and clean build:
bundle clean --force
gem install bundler
bundle install
you are using Bundler version 1.3.2
Make sure you upgrade to version Bundler 2.0+
Then bundle one last time and push your changes to Heroku
I hope that helps..
This is a hopeful long shot, but maybe try run heroku ps:restart and hope it picks up the new Ruby version.

ERROR: 'rake/rdoctask' is obsolete and no longer supported

Out of the blue, I started getting the following error message:
(in /Users/me/.rvm/gems/ruby-1.9.3-p125#mysql2/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/me/.rvm/gems/ruby-1.9.3-p125#mysql2/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
When I do rails s (in my development environment terminal - Mac Mountain Lion). This application is in production, so I went to the production environment, did a bundle show, and modified my Gemfile, to harcode the gems versions.
Here's what I have now on my my local development environment (what's producing the error message).
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
annotate (2.4.1.beta1)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bootstrap-datepicker-rails (0.6.15)
bootstrap-sass (2.0.2)
builder (3.0.4)
bundler (1.1.3)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.1)
commonjs (0.2.6)
devise (2.0.4)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
factory_girl (3.2.0)
factory_girl_rails (3.2.0)
hike (1.2.1)
i18n (0.6.4)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.1)
less (2.2.2)
less-rails (2.2.6)
libv8 (3.3.10.4)
mail (2.4.4)
mime-types (1.21)
multi_json (1.6.1)
mysql2 (0.3.11)
nokogiri (1.5.6)
orm_adapter (0.0.7)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.3)
railties (3.2.3)
rake (10.0.3)
rdoc (3.4)
rest-client (1.6.7)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
sass (3.2.7)
sass-rails (3.2.5)
sprockets (2.1.3)
stripe (1.7.0)
therubyracer (0.10.1)
thor (0.14.6)
tilt (1.3.5)
tinymce-rails (3.4.8)
treetop (1.4.12)
twitter-bootstrap-rails (2.1.0)
tzinfo (0.3.37)
uglifier (1.2.4)
warden (1.1.1)
webrat (0.7.1)
I researched Stackoverflow and the web, and none of the suggestions worked (changing the rake gem version to something different. like 0.8.7, etc., editing my app Rakefile to suppress deprecation errors, etc.). I also added rdoc and in my Rakefile, I required 'rdoc/task'
Still, the same error.
Just to help anyone else who has had this hassle.
If you are like me, then your problem is that the current version of rails is 4 and you are wanting to use an older version like 3.0.7
If you install rails fresh to learn it ,say, and the tutorial you are using is for a 3.0.x version of rails OR your job requires the use of the older version of rails.. then you can get into this hole.
In my case I got a 3.0.7 rails project dumped on me and was told to learn rails and make some enhancements to this code.
so, I just started learning rails and was following the tutorial until I got this error when doing a 'rake db:migrate'
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `require'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `<top (required)>'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `load'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block in <top (required)>'
This happened cos I was using an older version of rails.. in my case 3.0.7
If you run a 'bundle show', like I did then, you may see that you are using the rake version 10.0.0 or something like that...and you need to be running rake 0.9.2 ... which is where the problem is coming from..
The solution for me was to (a) add a gem to my gemfile and (b) to a bundle install
So, in my gemfile I added:
gem 'rake', '0.9.2'
Then did a
'bundle install'
Got this message:
You have requested:
rake = 0.9.2
The bundle currently has rake locked at 10.1.0.
Try running `bundle update rake`
And so I did that...
bundle update rake.
And that went fine.
then when I did the'rake db:migrate' it just worked.
Hope this helps somebody.
Vida.
PS: if you are new to rails, like me, and you inherit an older rails app then for gods sake NEVER run 'bundle update' or you will enter a world of pain. That command updates all your gems to the very latest versions and you end up with a load of problems with incompatibilities. The only way out of it is if you are lucky enough to have git installed and can do a 'git checkout' to go back...
I struck with this same problem when try to install gems by the command rake gems:install my rails version is rails2.3.2 and i have rvm installed.
my gem list is,
actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
bundler (1.3.5)
rails (2.3.2)
rake (10.0.4)
rubygems-bundler (1.1.1)
rvm (1.11.3.7)
so uninstalled the rake by the command
rvm use ruby-1.8.7-p371#global && gem uninstall rake -v 10.0.4
then i installed rake of older version
rvm use ruby-1.8.7-p371#global && gem install rake -v 0.8.7
now rake gems:install works fine
hope it may help some one!
Upgrading to rails 4.0.0 I got the same error.
rails -v
(in /Users/oma/.rvm/gems/ruby-2.0.0-p247/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/oma/.rvm/gems/ruby-2.0.0-p247/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
(See full trace by running task with --trace)
To upgrade, I removed the version number in Gemfile
source 'https://rubygems.org'
gem 'rails' # NO VERSION
and did bundle update as I thought this would pick the last. But somehow, I got rails 0.9.5. It feels like some practical joke, really, lol
$ gem list rails
rails (4.0.1.rc2, 4.0.0, 0.9.5)
I can't tell you with 100% certainty that this was the cause, but we were two people, working on the same branch and seeing the same error. The fix worked for both of us. Simply
specify rails version!
$gem uninstall rails -v 0.9.5
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.0'
then bundle, run rails -v, giggle (or cry) and get back to producing
Take a look at similar problem solution on StackOverflow
Another option is to use (example taken from Redmine Rakefile)
require 'rdoc'
require 'rdoc/task'
Instead of
require 'rake/testtask'
require 'rake/rdoctask'
The following works for me using ruby 1.9.3p448 (2013-06-27 revision 41675):
1) Use rake version 10.1.0 (put following in your Gemfile):
gem 'rake', '10.1.0'
(Note you can likely use another version, but the line number below might change.)
2) Comment line 54 of your Rakefile and replace it as follows:
#require 'rake/rdoctask'
gem 'rdoc', ">= 2.4.2"
require 'rdoc/task'
3) Test
$ bundle install
$ bundle exec rake

Could not find builder-2.1.2 in any of the sources

I'm following the Getting Started with Rails guide, but I ran into a problem:
bash-4.1$ bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.14)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.7)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using sqlite3-ruby (1.3.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
bash-4.1$ rake db:create
(in /Users/user/Documents/blog)
Could not find builder-2.1.2 in any of the sources
Try running `bundle install`.
bash-4.1$ bundle show builder
/Users/user/.gem/ruby/1.8/gems/builder-2.1.2
I also tried installing Builder as a RubyGem, but that didn't change a thing.
Try running it through bundle exec to make sure all of the gems specified in your Gemfile are available at their correct versions: bundle exec rake db:create
You can verify the installed gem is visible to bundle like this:
bundle show builder
/usr/lib/ruby/gems/1.8/gems/builder-2.1.2
I have the same problem though, bundle exec rake still fails to see the installed gem.
My version of rake (installed at /usr/bin/rake) was pointing at an old version of Ruby 1.8.
Modify the first line of rake to point at the correct version of Ruby. You can also clear out the bundle cache under the 'vendor' directory or move bundle to another local directory:
bundle install --path gems
On the command line, locate your default 'ruby' and 'rake' commands and check the version of Ruby:
which ruby
which rake
ruby -v
In /usr/bin/rake (line #1):
#!/opt/local/bin/ruby

Resources