Heroku rake db:structure:load with cleardb can't find 'mysql' - mysql

I am trying to install an instance of Sharetribe on a heroku dyno. I am at the point where I am trying to create the database. I first tried rake db:migrate and it worked for most of the migrations but failed on one of them.
I was advised to use rake db:structure:load, so I tried that and I am getting an error from Heroku saying that mysql needs to be added to the PATH variable. Why is this, and how can I fix it? I'm not sure why it happens on db:schema:load and db:structure:load but not on db:migrate.
The complete stack trace with the error message is:
rake aborted!
failed to execute:
mysqlPlease check the output above for any errors and make sure that `mysql` is installed in your PATH and has proper permissions.
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:148:in `run_cmd'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/mysql_database_tasks.rb:72:in `structure_load'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:189:in `structure_load'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:222:in `load_schema_for'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:236:in `block in load_schema_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:235:in `load_schema_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:293:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => db:structure:load
(See full trace by running task with --trace)
Thanks!

If you need to run heroku run bundle exec rake db:structure:load than you need to install mysql client.
To install additional packages you need to add Buildpacks (official or community based).
For mysql I successfully used https://github.com/din-co/heroku-buildpack-mysql
heroku buildpacks:add --index 1 https://github.com/din-co/heroku-buildpack-mysql
git commit --amend --allow-empty --no-edit
git push heroku -f

Heroku doesn't support mysql, you need to use pg gem in your gemfile in production block.
Please read Getting Started with Rails 5.x on Heroku

Related

Can't fix Active Record Pending Migration Error

i am trying to make a demo restful json api
using this link:
https://scotch.io/tutorials/build-a-restful-json-api-with-rails-5-part-one
but when i trying to run following command
$ bundle exec rspec
ActiveRecord::PendingMigrationError
error generated
i tried many solution available in stack overflow but no effect happen so far
C:\ruby\imran-api>bundle exec rspec
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:573:in `check_pending!': (ActiveRecord::PendingMigrationError)
Migrations are pending. To resolve this issue, run:
bin/rails db:migrate RAILS_ENV=test
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:586:in `load_schema_if_pending!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:592:in `block in maintain_test_schema!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:823:in `suppress_messages'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:597:in `method_missing'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:592:in `maintain_test_schema!'
from C:/ruby/imran-api/spec/rails_helper.rb:27:in `<top (required)>'
from C:/ruby/imran-api/spec/controllers/items_controller_spec.rb:1:in `require'
from C:/ruby/imran-api/spec/controllers/items_controller_spec.rb:1:in `<top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from C:/Ruby23-x64/bin/rspec:22:in `load'
from C:/Ruby23-x64/bin/rspec:22:in `<main>'
full error picture
Run migration files for test environment first:
rails db:migrate RAILS_ENV=test
for window
first go to bin folder:
cd bin
then run the below code:
rails db:migrate RAILS_ENV=test

Incorrect MySQL client library version! This gem was compiled for 5.5.37 but the client library is 5.6.25 [duplicate]

This question already has answers here:
mysql2 gem compiled for wrong mysql client library
(8 answers)
Closed 6 years ago.
I upgraded my Ubuntu from 2014.04 to 2015.04 and now bundle exec rake db:migrate returns an error:
$ bundle exec rake db:migrate --trace
rake aborted!
Incorrect MySQL client library version! This gem was compiled for 5.5.37 but the client library is 5.6.25.
/home/nico/.rvm/gems/ruby-1.9.3-p362/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `require'
/home/nico/.rvm/gems/ruby-1.9.3-p362/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `<top (required)>'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
/home/nico/myapp/config/application.rb:7:in `<top (required)>'
/home/nico/myapp/Rakefile:4:in `require'
/home/nico/myapp/Rakefile:4:in `<top (required)>'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/bin/rake:19:in `load'
/home/nico/.rvm/gems/ruby-1.9.3-p362#global/bin/rake:19:in `<main>'
/home/nico/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval'
/home/nico/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>'
How to solve this problem?
I would rather avoid changing server-side versions.
The answers at I can't run "bundle update" because of "mysql2" gem do not solve the problem.
Local versions:
gem 2.4.8
Rails 3.0.19
mysql Ver 14.14 Distrib 5.6.25
Running these commands solved the problem:
gem uninstall mysql2
bundle install
I ran into the same problem and the accepted answer didn't work for me, most likely because I used capistrano, which installs all gems into a per-app shared directory.
bundle show mysql2
(run in your app's folder) will show you where mysql is installed. Then delete that as well as the the specification.
rm -rf /path/to/application/shared/bundle/ruby/<version>/gems/mysql2-<version>
rm /path/to/application/shared/bundle/ruby/<version>/specifications/mysql2-<version>.gemspec
should do the trick. Alternatively just delete the complete bundle/* and reinstall everything.

Coping with gitlab ssh key syncronization bug

I attempted to use a solution posted here: GitLab v5.0 git push problems to fix the ssh keys getting out of sync problem.
However, when I run the rake command as both root & git users on the repository server I get the following message:
root#gitlab /home/git# rake gitlab:shell:setup RAILS_ENV=production --TRACE
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
How is the rake command supposed to be used to fix the synchronization problem?
It could be similar to this issue 3922:
You must execute this command in the GitLab installation directory containing the Rakefile
So make sure to go in the gitlab directory where you can see the Rakefile.

Getting errors when starting a rails server with MySQL on mac os

I've been tinkering with this one for several days and I still get the same error. For starters, I have been able to start a newly rails app with sqlite as the database but the application we are working on uses Mysql. So when I go to the app directory and type "rails server" it gives me the following:
/Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/mysql2-0.2.7/lib/mysql2.rb:8:in `require': dlopen(/Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/mysql2-0.2.7/lib/mysql2.rb:8:in `<top (required)>'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
from /Users/gojinjedi/Sites/bluey/config/application.rb:7:in `<top (required)>'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Users/gojinjedi/.rvm/gems/ruby-1.9.2-p180#rails3/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
So (I think) MySQL development headers aren't installed, which I googled everywhere how to install them and tried most install command line to no success yet. Examples of commands I've tried:
gem install mysql2
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
I did the bundle install, bundle update and bundle commands in the app directory...I'm running out of options...can you help me?
I'm on mac osx 10.7
have you tried something like this, I'm one Mac OS X (lion) too and I have no problem with the mysql gem. Or may be you can find what you want here
[EDIT]
Or you can simply use ruby-mysql gem for development environment

Problem with MySQL and Rails Server

Final edit: I played with a few different files got some more errors and then reinstalled rvm and everything else from the start, found a few fixes and edited them and finally everything works. thank you everyone for your help
Edit: I have noticed that it says Library not loaded: /usr/local/mysql-5.5.10-osx10.6-x86_64/lib/libmysqlclient.18.dylib (LoadError)
But I have mysql 5.5.11, how do I fix that?
I literally have searched for the past 3 hours, but found nothing that worked
Same error occurs when I either try to launch the server or generate a model
I have bundler and mysql2 gems.
builder (2.1.2)
bundler (1.0.12)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.17)
mime-types (1.16)
mysql2 (0.2.7)
I get the following output:
hrs772:demo kishinmanglani$ rails s
/Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/mysql2.rb:8:in `require': dlopen(/Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql-5.5.10-osx10.6-x86_64/lib/libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/mysql2.rb:8:in `<top (required)>'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/kishinmanglani/rails_projects/demo/config/application.rb:7:in `<top (required)>'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Users/kishinmanglani/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Whenever you get load errors you should make sure you have all of the dependencies installed and in place.
Make sure you have gem mysql2 in your Gemfile.
Install bundler if you don't already have it with gem install bundler.
Run bundle (same as bundle install).
Then try running the server again.
mysql2 with rails 3.0.3 is give some error so try to update rails version with 3.0.6
it working fine so try