Rails: 'require': cannot load such file -- mysql2/2.2/mysql2 (LoadError) - ruby-on-rails

I am new to rails and I have installed Ruby 2.2.2, Rails 4.2.3, Gem version 2.4.8, DevKit, a MySQL server, and it says that I have successfully installed the MySQL2 gem, however, when I go to the root directory of my web app and use the rails server command, I get the following error:
I reinstalled all of the programs (Ruby, Rails, MySQL2, DevKit, etc.) and I am still prompted with this error.
(P.S. I know that other people have posted this same problem but I couldn't find a solution that worked)
Thanks.

Related

cannot load such file — sqlite3/sqlite3_native (LoadError) on ruby on rails

2.5.1 Ruby, 5.2.1 Rails versions. Everything is installed from scratch. Im trying to create a project in RubyMine, and this error pops up right from the start, and i can do nothing untill this error is solved.
This solution didnt work for me:
cannot load such file -- sqlite3/sqlite3_native (LoadError) on ruby on rails
Couldnt make to the end of this solution:
An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue
on 5-th step after execution of "configure" promt says that no acceptable c compiler found in PATH.
Help please.
So it seems that there are some problems with compability on this versions of ruby, rails, and sqlite. I've installed rails installer with 2.3.3 ruby and 5.1.6 rails, and error dissapeared.

sqlite3.rb:6:in require: libruby.so.2.2: cannot open shared object file

sorry for my english.
I was learning about ruby on rails and i tried to update to rails 5.
I uninstall olders version of ruby and now i have problems.
i have reading http://railsapps.github.io/updating-rails.html
i made a mistake because i uninstalled something that i dint do.
now i have ruby-2.3.1
i have this error now.
.gem/gems/sqlite3-1.3.11/lib/sqlite3.rb:6:in `require':
libruby.so.2.2: cannot open shared object file: No such file or
directory -
/home/yvasquez/.gem/gems/sqlite3-1.3.11/lib/sqlite3/sqlite3_native.so
(LoadError)
Thanks for reply
I had the same error with ruby 2.3 & 2.3.1. It is because it fails to recognize the devkit (which i hope you need not install unless you're using Windows) gems as native ruby gems. The problem is with the latest ruby version and the gem configs located in the directory, where you will have to manually specify the native part to each gem.
Anyway, I went back to ruby 2.2.5, and everything works perfectly for me.
Try ruby 2.2.5 OR since you are on linux, try re installing and make sure you add everything to the path so your gems are recognized. Also, try installing sqlite3 separately and add to path.

Rails Server not Working (LoadErrror mysql2) Windows

I am trying to run rails server command but it showing mysql2 Load Error. I will place my Error log here
I searched many places.
I tried to install from my bundle itself using "gem install mysql2 --ruby=platform" command using connector c "libmysql.dll" file pasted in ruby/bin but no use.
I actually have MySQL installed on my system long back when I was doing JDBC connections. Its SQL server version 5.0- Is that version causing this error? Or Do I need to uninstall the MySQL from my system and install Latest Version!
And a doubt for me is how is this MySQL Server 5.0 connected to Rails as I no I have no idea about it, because while installation I used Connector C 6.1 for mysql2 installation from the Command Promt!
I tried Ruby on Rails - cannot load such file -- mysql2/2.2/mysql2 (LoadError)
I also tried Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0
But I am getting the same error.
I think I have given all the details regarding versions and what I did!
I tried doing this like 50 times but no progress! I hope I will get my problem solved !Thank You!
The following below instructions can help you.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-
6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-
dir="C:\connector-6.0.2"'
Or even shorter:
gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"
im not using windows. but seems to be duplicate with posts like this (Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0)

Can't boot WEBrick, the folder for Rails gem is empty

I'm following Michael Hartl's Ruby on Rails tutorial, and I got stuck at trying to start rails server on my Windows 7 machine.
I'm trying to do this by following instructions in Chapter 1.2.5., i.e. by typing
rails server
However, instead of booting WEBrick, this returns the instructions for usage of 'rails' command. I've been googling this for a while, and some of the answers seem to have implied that something is wrong with the rails gem.
Now, I've found the rails gem folder ("C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\rails-3.2.3"), and it's empty!
Also when I try
rails -v
it returns "Rails 3.2.16", although I've removed this version of the gem; if I try
gem list
it kept telling me that the version is 3.2.3.
This persisted until I deleted railties version 3.2.16, which resulted in
rails -v
returning 'Rails 3.2.3', but I still can't boot WEBrick.
Any help would be appreciated.
Did you run the installer?
At the time of this writing, I recommend using the Ruby 2.0.0-p353.
http://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.0.0-p353.exe?direct
Save yourself some future gem headaches and install the DevKit too.
http://rubyinstaller.org/downloads/
It should create a folder at C:\Ruby200. Start a new command prompt for the new paths to take affect.
Once Ruby is install, gem install Rails. From your other post, I recommend gem install rails -v 3.2.16
Then execute rails new project_name, then cd project_name. Then run rake db:migrate to create the initial database. At this point, you should be able to run rails server and visit localhost:3000 in your browser.
OK, I've managed to solve my problem.
I've seen a few more people having the same issue, but none of the solutions that I've found helped me, so here's what did it for me, though I'm not 100% sure what exactly was that one thing that actually did it...
I've followed the advice #scarver2 gave in response to my other question, and uninstalled both Rails and Railties gems from my crispy fresh installation of Ruby 1.9.3. (I've installed it using RailsInstaller). Then I've installed Rails 3.2.16 gem by typing
gem install rails -v 3.2.16
and this also installed the corresponding Railties 3.2.16 gem without my intervention.
Then I followed steps from chapters 1.2.3. and 1.2.5. of the tutorial, but making sure that line referencing ruby version in my Gemfile actually corresponds to the version of Ruby that I have installed.
I typed
ruby -v
in the console, to make sure that I have version 1.9.3. indeed. Confirming this, I've edited the Gemfile in my app so it says
ruby '1.9.3'
instead of ruby '2.0.0' line that's used in Listing 1.5. of the tutorial.
After that I've simply went to my app folder, and typed
bundle update
bundle install
in the console, and this time it did not return any errors as it did in my previous attempts. After that, typing
rails server
did what it should have, and my WEBrick server booted, allowing me to access my app on localhost. Yay!
Now, what I think may have gone wrong the last time was either me screwing up the Gemfile, so the gem versions and their dependencies got messed up. I also assume that ineptly trying to fix this by installing and uninstalling different versions of various gems did not quite help. What may have helped was uninstalling Rails and Railties gems, and installing Rails gem again.

Error with Rails Edge/4 `require': cannot load such file -- thread_safe

Following ths instructions here for getting an app running off Rails Edge to test Rails 4:
What is the best way to generate a Rails app using edge?
and
How to create Edge rails application?
But running into this error:
`require': cannot load such file -- thread_safe (LoadError)
Using the command:
rails new Edge --edge --skip-bundle --database=postgresql --skip-test-unit --skip-index-html
A checkout of Rails master bin dir is on my path.
I am using rbenv with ruby 1.9.3p327.
I have cleared all my installed gems out, just running bundler.
Rails 3.2.9 works fine on my system, have an app in active development.
Issue is not having the rails gems installed (when installing via rubygems, dependencies are automatically resolved.
See https://github.com/rails/rails/pull/8589
Need to go into the cloned rails dir and run "bundle install", which will pull in the necessary gems.

Resources