"db:migrate rake" throwing eror "cannot load such file -- bundler/setup" - mysql

I'm a ruby on rails beginner, and I'm trying to run a rails app on my local mac. I have set up the environment and MySQL database, and it was all smoothie until the last setup step: db:migrate rake. I got the following error:
cannot load such file -- bundler/setup
/Users/snailwalker/vietnam/snailwalker/config/boot.rb:7:in `<top (required)>'
/Users/snailwalker/vietnam/snailwalker/config/application.rb:2:in `<top (required)>'
/Users/snailwalker/vietnam/snailwalker/Rakefile:5:in `<top (required)>'
What am I missing?

cannot load such file -- bundler/setup
Most probably the reason of this issue is that you don't have bundler. You should install bundler then try to run migrations again.
gem install bundler
bundle install
bundle exec rake db:migrate
Hope it'll help you.

Related

LoadError: cannot load such file -- mysql2/mysql2 - on rake db:create

When i run rake db:create, I get this error:
LoadError: cannot load such file -- mysql2/mysql2
/Users/vitorqueiroz/dev/pipeline/config/application.rb:10:in `<top (required)>'
/Users/vitorqueiroz/dev/pipeline/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
I had to mannualy install mysql2 gem because the gemfile specifies the version '0.3.20'
I ran
gem install mysql2 -v '0.3.20' -- --srcdir=/usr/local/include/mysql
Bundle install runs fine, and says everything is installed.
bundle list mysql2 evaluates to:
/Users/vitorqueiroz/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.3.20
--
Any alternatives?
You can try
bundle exec rake db:create
to be sure that bundled gems are loaded.
https://bundler.io/man/bundle-exec.1.html

Heroku rake db:structure:load with cleardb can't find '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

How to resolve loaderror in ROR

Can anybody please help me to resolve this error.I am tring to work with mysql and ROR
modified the gem file as "gem mysql" and database.yml file
copied the libmysql.dll(from mysql-connector-c-6.1.5-winx64 folder) file to rubu193/bin folder.
typed gem install mysql and it installed succefully.
typed bundle install
but when i typed rake db:create,it gave the following error.
Error:
LoadError: cannot load such file -- mysql/mysql_api
c:/Site/book/config/application.rb:7:in `<top (required)>'
c:/Site/book/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
please help to resolve this error.

Can't rake:db migrate - Keep getting a 'rake aborted! load error' [duplicate]

This question already has answers here:
Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)
(10 answers)
Closed 8 years ago.
I installed MySQL using Homebrew (brew install mysql), and then ran $ gem install mysql2 . I'm on a Mac running OSX 10.9.4.
I changed directories into the root of my app, and then try to run the rake db:migrate command, and got this error:
Levine_iMac$ rake db:migrate
rake aborted!
LoadError: dlopen(/Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle, 9): Symbol not found: _SSLv2_client_method
Referenced from: /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
in /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle - /Users/Levine_iMac/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-darwin13.0/openssl.bundle
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in require'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:3:in <top (required)>'
/Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in <top (required)>'
(See full trace by running task with --trace)
Levine_iMac$
I tried adding something to my .bash_profile, as described here, but that did not work.
I tried a sudo command as described here, but that did not work.
I then tried updating my Ruby version from 2.1.1.. to 2.1.2.., and now I am getting this error when I run rake:db migrate
Levine_iMac$ rake db:migrate
rake aborted! cannot load such file -- bundler/setup /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/boot.rb:4:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/config/application.rb:1:in '<top (required)>' /Users/Levine_iMac/Dropbox/Coding/Sandbox/simple_cms2/Rakefile:4:in '<top (required)>' (See full trace by running task with --trace) Levine_iMac$ bundle install rbenv: bundle: command not found The 'bundle' command exists in these Ruby versions:
2.1.1
Levine_iMac$
Any ideas on how to remedy this? Thanks.
Well, what are you exactly expecting to happen when you run rake db:migrate? Is some next step going to materialize for you? If you are able to answer this question, you will understand why what you're doing doesn't make sense.
I'll elaborate:
rake db:migrate only works in the context of an existing rails application. Running 'gem install mysql2' will get that library for you on your computer (this command is executed by itself, it doesn't actually have anything to do with Rails itself, or need a Rails app for context). So, there's no linear connection between the two.
rails new myapp
add 'gem mysql2' in the Gemfile
bundle
rake db:create
Or, alternatively:
rails new myapp -d mysql

Error when starting Rails server with MySQL

I'm running Rails 4.0.3 on Ruby 2.0.0 on Windows 7, and have installed the DevKit (all x64).
I've installed the mysql2 gem using subst X: "C:\Program Files\MySQL\MySQL Server 5.6" and then gem install mysql2 --platform=ruby -- --with-mysql-dir=X:, and it installed fine. I then created a new app with rails new mysql_testy which ran fine, but when I run rails server I get the following error:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in 'require': 193: %1 is not a valid Win32 application. - C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in 'require'
from C:/Users/Liam/Ruby/mysql_testy/config/application.rb:7:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in 'tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in '<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'`
Do you guys have any idea what's happening?
Not sure if you figured it out yet, but I was having the same issue. I installed the 32 bit sql connector, copied the libmysql.dll file from it and pasted it into Ruby/bin folder. Opened a new command prompt and was able to connect to the server.
Before this step though you may have to reinstall a fresh MySQL2 gem pointing to the path of the connector: gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\mysql-connector-c-6.1.5-win32\lib" --with-mysql-include="C:\mysql-connector\mysql-connector-c-6.1.5-win32\include" --with-mysql-dir="C:\mysql-connector"'
Hope this helps