Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Rake commands won't work and localhost error

After replacing my biller folder with the new project files I got a localhost error when I tried running the rails server. I used the tips provided in the comments here: https://teamtreehouse.com/forum/activerecord-how-do-i-get-the-updated-project-data

and the error changed to: uninitialized constant Mysql2::Client::SECURE_CONNECTION mysql2 (0.3.15) lib/mysql2/client.rb:12:in <class:Client>' mysql2 (0.3.15) lib/mysql2/client.rb:2:in<module:Mysql2>' mysql2 (0.3.15) lib/mysql2/client.rb:1:in <top (required)>' mysql2 (0.3.15) lib/mysql2.rb:10:in<top (required)>' activerecord (4.0.3) lib/active_record/connection_adapters/mysql2_adapter.rb:4:in <top (required)>' activerecord (4.0.3) lib/active_record/connection_adapters/connection_specification.rb:56:inresolve_hash_connection' activerecord (4.0.3) lib/active_record/connection_adapters/connection_specification.rb:46:in resolve_string_connection' activerecord (4.0.3) lib/active_record/connection_adapters/connection_specification.rb:30:inspec' activerecord (4.0.3) lib/active_record/connection_handling.rb:39:in establish_connection' activerecord (4.0.3) lib/active_record/railtie.rb:176:inblock (2 levels) in <class:Railtie>' activesupport (4.0.3) lib/active_support/lazy_load_hooks.rb:38:in instance_eval' activesupport (4.0.3) lib/active_support/lazy_load_hooks.rb:38:inexecute_hook' activesupport (4.0.3) lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks' activesupport (4.0.3) lib/active_support/lazy_load_hooks.rb:44:ineach' activesupport (4.0.3) lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks' activerecord (4.0.3) lib/active_record/base.rb:322:in<module:ActiveRecord>' activerecord (4.0.3) lib/active_record/base.rb:22:in <top (required)>' activerecord (4.0.3) lib/active_record/schema_migration.rb:3:in<top (required)>' activerecord (4.0.3) lib/active_record/migration.rb:783:in schema_migrations_table_name' activerecord (4.0.3) lib/active_record/migration.rb:791:incurrent_version' activerecord (4.0.3) lib/active_record/migration.rb:800:in needs_migration?' activerecord (4.0.3) lib/active_record/migration.rb:379:incheck_pending!' activerecord (4.0.3) lib/active_record/migration.rb:366:in call' actionpack (4.0.3) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.0.3) lib/active_support/callbacks.rb:373:in _run__2922550594121895017__call__callbacks' activesupport (4.0.3) lib/active_support/callbacks.rb:80:inrun_callbacks' actionpack (4.0.3) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.0.3) lib/action_dispatch/middleware/reloader.rb:64:incall' actionpack (4.0.3) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.0.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall' actionpack (4.0.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.3) lib/rails/rack/logger.rb:38:incall_app' railties (4.0.3) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:inblock in tagged' activesupport (4.0.3) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.3) lib/active_support/tagged_logging.rb:67:intagged' railties (4.0.3) lib/rails/rack/logger.rb:20:in call' actionpack (4.0.3) lib/action_dispatch/middleware/request_id.rb:21:incall' rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall' activesupport (4.0.3) lib/active_support/cache/strategy/local_cache.rb:83:in call' rack (1.5.2) lib/rack/lock.rb:17:incall' actionpack (4.0.3) lib/action_dispatch/middleware/static.rb:64:in call' rack (1.5.2) lib/rack/sendfile.rb:112:incall' railties (4.0.3) lib/rails/engine.rb:511:in call' railties (4.0.3) lib/rails/application.rb:97:incall' rack (1.5.2) lib/rack/lock.rb:17:in call' rack (1.5.2) lib/rack/content_length.rb:14:incall' rack (1.5.2) lib/rack/handler/webrick.rb:60:in service' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:138:inservice' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb:94:in run' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/server.rb:295:inblock in start_thread' This error occurred while loading the following files: active_record/base active_record/connection_adapters/mysql2_adapter mysql2 mysql2/client

I read in another thread that I could restore my database with the commands: rake db:drop rake db:create rake db:migrate

However, I am unable to run any rake commands in my terminal and for that I'm getting this error

rake aborted! Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.1.1. Prepending bundle exec to your command may solve this. /Library/Ruby/Gems/2.0.0/gems/bundler-1.8.0/lib/bundler/runtime.rb:34:in block in setup' /Library/Ruby/Gems/2.0.0/gems/bundler-1.8.0/lib/bundler/runtime.rb:19:insetup' /Library/Ruby/Gems/2.0.0/gems/bundler-1.8.0/lib/bundler.rb:122:in setup' /Library/Ruby/Gems/2.0.0/gems/bundler-1.8.0/lib/bundler/setup.rb:8:in<top (required)>' /Users/hsh2692/biller/config/boot.rb:4:in <top (required)>' /Users/hsh2692/biller/config/application.rb:1:in<top (required)>' /Users/hsh2692/biller/Rakefile:4:in `<top (required)>'

1 Answer

Donald McLamb
Donald McLamb
2,867 Points

Hello,

Not sure exactly what transpired to get you to this point but if the data in the db is not important I would start the project from scratch.

Your issue is this:

"rake aborted! Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.1.1. Prepending bundle exec to your command may solve this. "

If you have not already try this:

bundle exec rake

if that does not work you can modify the gemfile to your version or you can modify the version of rake you are using.

The bundle exec rake didn't do much better. I ended up trashing the new biller folder and overwriting it with my old biller folder which I thought would work fine because it was working before I switched the folder names and tried to run the updated project files. However, I'm now running into the error "Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development"

After running bin/rake db:migrate RAILS_ENV=development I get this error

== 20150401040810 CreateAccounts: migrating =================================== -- create_table(:accounts) rake aborted! StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'accounts' already exists: CREATE TABLE accounts (id int(11) auto_increment PRIMARY KEY, type varchar(255), name varchar(255), email varchar(255), about varchar(255), created_at datetime NOT NULL, updated_at datetime NOT NULL) ENGINE=InnoDB/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `query'