0

I am working a new project in Codeanywhere (I am new on Ruby), but when I try to use "rake db : migrate" I have this error:

rake aborted!                                                                                                                                                                                                                                        
Don't know how to build task ':' (see --tasks)                                                                                                                                                                                                       
/home/cabox/.rvm/gems/ruby-2.1.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'                                                     
(See full trace by running task with --trace)

Before this I use bundle update and after and nothing, and when I put "rake-T", db Migartion is on the tasks, when I try with --trace, pass the same.

I try before with rake db:migrate and the same happened `rake aborted!

SyntaxError:     
/home/cabox/workspace/blog/db/migrate/20170103233409_create_posts.rb:5: syntax error, unexpected ':'                                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'                                                                                                                                        
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'                                                                                                                               
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'                                                                                                                                
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'                                                                                                                                        
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:761:in `load_migration'                                                                                                                                      
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord- 4.1.6/lib/active_record/migration.rb:757:in `migration'                                                                                                                                           
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:752:in `disable_ddl_transaction'                                                                                                                             
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:1044:in `use_transaction?'                                                                                                                                   
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:1036:in `ddl_transaction'                                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:990:in `execute_migration_in_transaction'                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:952:in `block in migrate'                                                                                                                                    
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `each'                                                                                                                                                
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:948:in `migrate'                                                                                                                                             
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:807:in `up'                                                                                                                                                  
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/migration.rb:785:in `migrate'                                                                                                                                             
/home/cabox/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.6/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'                                                                                                      
/home/cabox/.rvm/gems/ruby-2.1.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'                                                                                                                                                                  
Tasks: TOP => db:migrate                                                                                                                                                                                                                             
(See full trace by running task with --trace)` >    

Does anyone know how to solve this problem?

In the migration file I have:

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :title
      t.strind : 
      t.text :body 
      t.timestamps
    end
  end
end
0

3 Answers 3

5

I am pretty sure what is happening is you are inserting a space in there when you type it out. It needs to be

rake db:migrate

not

rake db : migrate

That error message is pretty common when there is a spelling error or some other kind of typing error when running the command.

Your migration has a typo as well, should be this

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :title
      t.text :body 
      t.timestamps
    end
  end
end
Sign up to request clarification or add additional context in comments.

5 Comments

I try, but it happen the same. Tasks: TOP => db:migrate (See full trace by running task with --trace)
SyntaxError: /home/cabox/workspace/blog/db/migrate/20170103233409_create_posts.rb:5: syntax error, unexpected ':' /home/cabox/.rvm/gems/ruby-2.1.2/gems/rake-12.0.0/exe/rake:27:in <top (required)>' This is the most important of the message error.
I think in your migration file you did the same thing by putting a space before (and possibly after) a ' : ' somewhere, it is unrelated to the original issue, but we can fix it easily. Just post the migration file in the original post and I will tell you what to correct.
i put the file in the post :)
You solve my problem, i edit the file like you put in your anwer (i dont know why my file was in that state beacuse i didn't move anything) Sincerly thanks
1

Rake is a software task management tool, similar to Make, etc. in other systems

The generic syntax is

rake namesapce:task

In your case it is

rake db:migrate

Comments

-1

Try doing rake db:reset if you want to rebuild your db again. It does 4 things for you

rake db:drop
rake db:create
rake db:migrate
rake db:seed 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.