Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake db:migrate acts weird #7906

Closed
rhacker opened this issue Oct 10, 2012 · 21 comments
Closed

rake db:migrate acts weird #7906

rhacker opened this issue Oct 10, 2012 · 21 comments

Comments

@rhacker
Copy link

rhacker commented Oct 10, 2012

when I try to run rake db:migrate I got this error

/home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load': cannot load such file -- /vagrant/projects/project/db:migrate (LoadError)
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /home/vagrant/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

I don't know which is the problem. Any suggestions are welcome, i'm just a new guy in rails development :)

@rafaelfranca
Copy link
Member

@rhacker could you run bundle exec rake db:migrate?

@rhacker
Copy link
Author

rhacker commented Oct 11, 2012

I've tried it but it produces the same error

@rafaelfranca
Copy link
Member

I'm not sure. This is working in my machine. Could you publish an example application in the Github?

@rhacker
Copy link
Author

rhacker commented Oct 11, 2012

yes, I will retest and if it doesn't work, i will push it to github

On Thu, Oct 11, 2012 at 2:46 PM, Rafael Mendonça França <
notifications@github.com> wrote:

I'm not sure. This is working in my machine. Could you publish an example
application in the Github?


Reply to this email directly or view it on GitHubhttps://github.com//issues/7906#issuecomment-9338382.

@rhacker
Copy link
Author

rhacker commented Oct 11, 2012

@rafaelfranca I've pushed my project here : https://github.com/rhacker/failed-repo

@gmile
Copy link
Contributor

gmile commented Oct 11, 2012

@rhacker What's the output of which rake command?

@steveklabnik
Copy link
Member

Probably should be bundle exec which rake

@frodsan
Copy link
Contributor

frodsan commented Oct 12, 2012

weird:

frodsan$ rake db:migrate
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.8.0
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0013s
==  CreateUsers: migrated (0.0014s) ===========================================

/Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load': cannot load such file -- /Users/frodsan/tmp/failed-repo/db:migrate (LoadError)
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /Users/frodsan/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

@steveklabnik
Copy link
Member

Since there's no git history, here's the diff between this and a plain repo:

diff --git a/Gemfile b/Gemfile
index 22cddfb..d494b07 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,6 +7,7 @@ gem 'rails', '3.2.8'

 gem 'sqlite3'

+gem 'json'

 # Gems used only for assets and not required
 # in production environments by default.
@@ -20,21 +21,6 @@ group :assets do
   gem 'uglifier', '>= 1.0.3'
 end

-group :development do
-  gem 'cucumber-rails', :require => false
-  gem 'database_cleaner'
-  gem 'guard'
-  gem 'spork'
-  gem 'guard-spork'
-  gem 'guard-rspec'
-  gem 'guard-cucumber'
-  gem 'rspec'
-  gem 'rspec-rails'
-  gem 'capybara'
-  gem 'mechanize'
-  gem 'factory_girl_rails'
-end
-
 gem 'jquery-rails'

 # To use ActiveModel has_secure_password
@@ -50,4 +36,4 @@ gem 'jquery-rails'
 # gem 'capistrano'

 # To use debugger
-#gem 'debugger'
+# gem 'ruby-debug'
diff --git a/Gemfile.lock b/Gemfile.lock
index d0bfce6..19f9624 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -28,18 +28,8 @@ GEM
     activesupport (3.2.8)
       i18n (~> 0.6)
       multi_json (~> 1.0)
-    addressable (2.3.2)
     arel (3.0.2)
     builder (3.0.3)
-    capybara (1.1.2)
-      mime-types (>= 1.16)
-      nokogiri (>= 1.3.3)
-      rack (>= 1.0.0)
-      rack-test (>= 0.5.4)
-      selenium-webdriver (~> 2.0)
-      xpath (~> 0.1.4)
-    childprocess (0.3.5)
-      ffi (~> 1.0, >= 1.0.6)
     coffee-rails (3.2.2)
       coffee-script (>= 2.2.0)
       railties (~> 3.2.0)
@@ -47,44 +37,9 @@ GEM
       coffee-script-source
       execjs
     coffee-script-source (1.3.3)
-    cucumber (1.2.1)
-      builder (>= 2.1.2)
-      diff-lcs (>= 1.1.3)
-      gherkin (~> 2.11.0)
-      json (>= 1.4.6)
-    cucumber-rails (1.3.0)
-      capybara (>= 1.1.2)
-      cucumber (>= 1.1.8)
-      nokogiri (>= 1.5.0)
-    database_cleaner (0.8.0)
-    diff-lcs (1.1.3)
-    domain_name (0.5.4)
-      unf (~> 0.0.3)
     erubis (2.7.0)
     execjs (1.4.0)
       multi_json (~> 1.0)
-    factory_girl (4.1.0)
-      activesupport (>= 3.0.0)
-    factory_girl_rails (4.1.0)
-      factory_girl (~> 4.1.0)
-      railties (>= 3.0.0)
-    ffi (1.1.5)
-    gherkin (2.11.4)
-      json (>= 1.4.6)
-    guard (1.4.0)
-      listen (>= 0.4.2)
-      thor (>= 0.14.6)
-    guard-cucumber (1.2.0)
-      cucumber (>= 1.2.0)
-      guard (>= 1.1.0)
-    guard-rspec (2.1.0)
-      guard (>= 1.1)
-      rspec (~> 2.11)
-    guard-spork (1.2.1)
-      childprocess (>= 0.2.3)
-      guard (>= 1.1)
-      spork (>= 0.8.4)
-      sys-proctable
     hike (1.2.1)
     i18n (0.6.1)
     journey (1.0.4)
@@ -92,27 +47,12 @@ GEM
       railties (>= 3.1.0, < 5.0)
       thor (~> 0.14)
     json (1.7.5)
-    libwebsocket (0.1.5)
-      addressable
-    listen (0.5.3)
     mail (2.4.4)
       i18n (>= 0.4.0)
       mime-types (~> 1.16)
       treetop (~> 1.4.8)
-    mechanize (2.5.1)
-      domain_name (~> 0.5, >= 0.5.1)
-      mime-types (~> 1.17, >= 1.17.2)
-      net-http-digest_auth (~> 1.1, >= 1.1.1)
-      net-http-persistent (~> 2.5, >= 2.5.2)
-      nokogiri (~> 1.4)
-      ntlm-http (~> 0.1, >= 0.1.1)
-      webrobots (~> 0.0, >= 0.0.9)
     mime-types (1.19)
     multi_json (1.3.6)
-    net-http-digest_auth (1.2.1)
-    net-http-persistent (2.7)
-    nokogiri (1.5.5)
-    ntlm-http (0.1.1)
     polyglot (0.3.3)
     rack (1.4.1)
     rack-cache (1.2)
@@ -139,37 +79,16 @@ GEM
     rake (0.9.2.2)
     rdoc (3.12)
       json (~> 1.4)
-    rspec (2.11.0)
-      rspec-core (~> 2.11.0)
-      rspec-expectations (~> 2.11.0)
-      rspec-mocks (~> 2.11.0)
-    rspec-core (2.11.1)
-    rspec-expectations (2.11.3)
-      diff-lcs (~> 1.1.3)
-    rspec-mocks (2.11.3)
-    rspec-rails (2.11.0)
-      actionpack (>= 3.0)
-      activesupport (>= 3.0)
-      railties (>= 3.0)
-      rspec (~> 2.11.0)
-    rubyzip (0.9.9)
     sass (3.2.1)
     sass-rails (3.2.5)
       railties (~> 3.2.0)
       sass (>= 3.1.10)
       tilt (~> 1.3)
-    selenium-webdriver (2.25.0)
-      childprocess (>= 0.2.5)
-      libwebsocket (~> 0.1.3)
-      multi_json (~> 1.0)
-      rubyzip
-    spork (0.9.2)
     sprockets (2.1.3)
       hike (~> 1.2)
       rack (~> 1.0)
       tilt (~> 1.1, != 1.3.0)
     sqlite3 (1.3.6)
-    sys-proctable (0.9.2)
     thor (0.16.0)
     tilt (1.3.3)
     treetop (1.4.11)
@@ -179,32 +98,15 @@ GEM
     uglifier (1.3.0)
       execjs (>= 0.3.0)
       multi_json (~> 1.0, >= 1.0.2)
-    unf (0.0.5)
-      unf_ext
-    unf_ext (0.0.5)
-    webrobots (0.0.13)
-    xpath (0.1.4)
-      nokogiri (~> 1.3)

 PLATFORMS
   ruby

 DEPENDENCIES
-  capybara
   coffee-rails (~> 3.2.1)
-  cucumber-rails
-  database_cleaner
-  factory_girl_rails
-  guard
-  guard-cucumber
-  guard-rspec
-  guard-spork
   jquery-rails
-  mechanize
+  json
   rails (= 3.2.8)
-  rspec
-  rspec-rails
   sass-rails (~> 3.2.3)
-  spork
   sqlite3
   uglifier (>= 1.0.3)
diff --git a/Rakefile b/Rakefile
index 5d6dd6d..6af3f3d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -4,4 +4,4 @@

 require File.expand_path('../config/application', __FILE__)

-Project::Application.load_tasks
+FailedRepo::Application.load_tasks
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index f6ce71c..b38796a 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
 <head>
-  <title>Project</title>
+  <title>FailedRepo</title>
   <%= stylesheet_link_tag    "application", :media => "all" %>
   <%= javascript_include_tag "application" %>
   <%= csrf_meta_tags %>
diff --git a/config.ru b/config.ru
index a07eeba..a7b8321 100644
--- a/config.ru
+++ b/config.ru
@@ -1,4 +1,4 @@
 # This file is used by Rack-based servers to start the application.

 require ::File.expand_path('../config/environment',  __FILE__)
-run Project::Application
+run FailedRepo::Application
diff --git a/config/application.rb b/config/application.rb
index 3f4344f..e010f60 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -9,7 +9,7 @@ if defined?(Bundler)
   # Bundler.require(:default, :assets, Rails.env)
 end

-module Project
+module FailedRepo
   class Application < Rails::Application
     # Settings in config/environments/* take precedence over those specified here.
     # Application configuration should go into files in config/initializers
diff --git a/config/database.yml b/config/database.yml
index 09cc85a..51a4dd4 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -12,7 +12,7 @@ development:
 # 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: &test
+test:
   adapter: sqlite3
   database: db/test.sqlite3
   pool: 5
@@ -23,6 +23,3 @@ production:
   database: db/production.sqlite3
   pool: 5
   timeout: 5000
-
-cucumber:
-  <<: *test
\ No newline at end of file
diff --git a/config/environment.rb b/config/environment.rb
index 957a8d5..bb64e2d 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -2,4 +2,4 @@
 require File.expand_path('../application', __FILE__)

 # Initialize the rails application
-Project::Application.initialize!
+FailedRepo::Application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 4b008d7..cde61e0 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,4 +1,4 @@
-Project::Application.configure do
+FailedRepo::Application.configure do
   # Settings specified here will take precedence over those in config/application.rb

   # In the development environment your application's code is reloaded on
diff --git a/config/environments/production.rb b/config/environments/production.rb
index a37fad7..0f4e55a 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,4 +1,4 @@
-Project::Application.configure do
+FailedRepo::Application.configure do
   # Settings specified here will take precedence over those in config/application.rb

   # Code is not reloaded between requests
diff --git a/config/environments/test.rb b/config/environments/test.rb
index f480a35..655e6aa 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,4 +1,4 @@
-Project::Application.configure do
+FailedRepo::Application.configure do
   # Settings specified here will take precedence over those in config/application.rb

   # The test environment is used exclusively to run your application's
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
index cdc6e9a..0914c60 100644
--- a/config/initializers/secret_token.rb
+++ b/config/initializers/secret_token.rb
@@ -4,4 +4,4 @@
 # If you change this key, all old signed cookies will become invalid!
 # Make sure the secret is at least 30 characters and all random,
 # no regular words or you'll be exposed to dictionary attacks.
-Project::Application.config.secret_token = '89b19767adf50a2d97c87783a6a7a8b5527b44734ad70679ee8512f440b3c11338655ce0d765b5f6fedb843693a88f4dac0ca0e737dd35b5ad2e7ea283a3cf9d'
+FailedRepo::Application.config.secret_token = '3a53b5af32527ab7f061996cf8caba2d0984c7988244c7c4889ccefa974a62afe0b074f0307464a32dd47fd2ad2958102115ae16a2f801fe9ee7179bfa56cd59'
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 8b9cd1c..2bf823a 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -1,8 +1,8 @@
 # Be sure to restart your server when you modify this file.

-Project::Application.config.session_store :cookie_store, key: '_project_session'
+FailedRepo::Application.config.session_store :cookie_store, :key => '_failed-repo_session'

 # Use the database for sessions instead of the cookie-based default,
 # which shouldn't be used to store highly confidential information
 # (create the session table with "rails generate session_migration")
-# Project::Application.config.session_store :active_record_store
+# FailedRepo::Application.config.session_store :active_record_store
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
index 999df20..da4fb07 100644
--- a/config/initializers/wrap_parameters.rb
+++ b/config/initializers/wrap_parameters.rb
@@ -5,7 +5,7 @@

 # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
 ActiveSupport.on_load(:action_controller) do
-  wrap_parameters format: [:json]
+  wrap_parameters :format => [:json]
 end

 # Disable root element in JSON by default.
diff --git a/config/routes.rb b/config/routes.rb
index 45d2fb3..2e7450d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,4 @@
-Project::Application.routes.draw do
-  resources :users
-
+FailedRepo::Application.routes.draw do
   # The priority is based upon order of creation:
   # first created -> highest priority.

diff --git a/db/seeds.rb b/db/seeds.rb
index 4edb1e8..d34dfa0 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -3,5 +3,5 @@
 #
 # Examples:
 #
-#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-#   Mayor.create(name: 'Emanuel', city: cities.first)
+#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+#   Mayor.create(:name => 'Emanuel', :city => cities.first)

@steveklabnik
Copy link
Member

Ahh, looks like I got some noise in there because your app was actually named Project.

@steveklabnik
Copy link
Member

It's also not an rbenv thing:

/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load': cannot load such file -- /Users/steve/tmp/failed-repo/db:migrate (LoadError)
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

@rhacker
Copy link
Author

rhacker commented Oct 12, 2012

yeah, it's getting interesting, I've tried to create another blank project and everything works fine.

@steveklabnik
Copy link
Member

@rhacker does it have the same gems with the same gem versions?

@rhacker
Copy link
Author

rhacker commented Oct 12, 2012

It looks like there is a problem in database configuration file, still don't know why it got there XD
https://github.com/rhacker/failed-repo/blob/master/config/database.yml#L15

@mhuggins
Copy link

@rhacker - That's valid YAML markup. You can see that cucumber references &test here: https://github.com/rhacker/failed-repo/blob/master/config/database.yml#L28

@steveklabnik
Copy link
Member

Yep. If you remove it there's an error.

@rhacker
Copy link
Author

rhacker commented Oct 12, 2012

After removing the factories file, everything runs fine https://github.com/rhacker/failed-repo/blob/master/spec/factories.rb .
Anyone has any idea about this ?

@steveklabnik
Copy link
Member

Super strange. @joshuaclayton, any thoughts? Is this a bug in FactoryGirl?

@joshuaclayton
Copy link

Tracked it down.

spec/factories.rb requires spec/spec_helper.rb. After digging through there, I narrowed it down to require 'rspec/autorun', which seems innocuous, until I looked at what it was doing:

module RSpec
  module Core
    class Runner

      # Register an at_exit hook that runs the suite.
      def self.autorun
        return if autorun_disabled? || installed_at_exit? || running_in_drb?
        at_exit { exit run(ARGV, $stderr, $stdout).to_i unless $! }
        @installed_at_exit = true
      end

Notice that at_exit, which is trying to run ARGV... in this case, db:migrate.

The big takeaway here is to be a bit more careful about your Gemfile (specifically, the groups that you set up with the appropriate gems). If they're testing gems, keep them in group :test unless absolutely necessary to move them to development. In this case, factory_girl_rails was behaving as it should've; loading spec/factories.rb. It just happened to be doing it in development. The kicker is that the factories file was requiring spec_helper, which is where everything came crashing down. Removing require 'spec_helper' from the factories file should solve it.

@arunagw
Copy link
Member

arunagw commented Oct 13, 2012

Thanks @joshuaclayton for this deep dive tracking and note.

@rhacker can you give a try now and see if problem gets solved?

@rhacker
Copy link
Author

rhacker commented Oct 13, 2012

@joshuaclayton Thanks for your great explanation :)
@arunagw it works flawlessly now 👍

@rhacker rhacker closed this as completed Oct 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants