Nubie at Ruby on Rails so I wanted to build a "Hello World" style of app to get familiar with RoR. The app I chose, along with tutorial on installation, was Dave Berube's "checkbook" app as in http://www.redhat.com/magazine/025nov06/features/ruby/
Yes it is from 2006 and maybe I have bumped into my errors because RoR has moved on through the years. Anyway, I get errors similar to banditKing with his app on 20th Sept., and many others; I get a persistent error as below.
When I ran RoR without creating my first app, it displayed the initial splash screen which effectively told me to "get working and create sites!" so that was a good start :-)
[running "rails generate migrate InitialSchema" to begin generating the application framework.]
/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
from /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
My environment:
RH Enterprise Linux version 6, 64-bit
[root#svr checkbookapp]# which mysql
/usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.69 Source distribution
[root#svr checkbookapp]# which ruby
/usr/local/bin/ruby
[root#svr checkbookapp]# ruby -v
ruby 2.0.0p247 (2013-06-27) [x86_64-linux]
Rails version is 4.0.0
[root#svr checkbookapp]# gem list | grep mysql
mysql (2.9.1)
mysql2 (0.3.13)
Start of my app's Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'mysql2'
...
I have added the library path to MySQL path into my .bash_profile as done by banditKing but that has not resolved this error. Have tried re-installing mysql2 gem several times and doing numerous "bundle install" operations. Downloaded and installed the connector 6.1 from the MySQL site and yum install'd the share and the development versions without any difference.
Try updating RubyGems with gem update --system. You should get something like version 2.x. There's a bug with RubyGems 1.8.x on Ruby 2.0 installing gems with c extentions (like mysql2 and nokogiri).
Related
I'm trying to set up my local dev environment to match my team's. I can't upgrade Ruby/Rails/mysql2 (for the time being).
I know my local MySQL config is good (enough?) because I can create a new Rails project and run it just fine. I'm getting the same error if I run rake db:create or rails s or even start IRB and run require 'mysql2'.
I've googled the hell out of this. I was initially using MariaDB as my MySQL implementation locally, so I thought that might be screwing with the mysql2 gem. So I ripped out MariaDB and finally got MySQL 5.6 working (another team version we're locked into at the moment). After successfully upgrading to MySQL 5.6, I'm confident that's 100% not the issue.
I would expect if I had the wrong password for it to complain about the config somehow, but it's always the same.
uninitialized constant Mysql2::Client::SECURE_CONNECTION
Ruby (RVM): ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
Mysql2: 0.3.16
There have been some other version-related struggles, but nothing this strong. The only thing I've encountered that I haven't actually tried is building the mysql2 gem locally.
I would expect require 'mysql2' to at least load the gem. Neither Rails nor Rake will work with the gem at all. It's almost like it's missing some internal file.
following as discussion about this error in official gem, you should update version as
From
gem 'mysql2', '0.3.16'
to
gem 'mysql2', '0.3.17'
if you still met an error after you update version to 0.3.17, i think that you should update to 0.2.24
https://github.com/brianmario/mysql2/issues/603
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)
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.
I am fairly new to Ruby on Rails and am currently having a problem with configuring config/database.yml to connect Oracle XE 11g R2. I need your help!
Here is my setup:
VirtualBox 4.3.6
Ubuntu 64 v12.04.3
$ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
$ rails -v
Rails 4.0.2
$ gem -v
2.2.2
$ gem install ruby-oci8
Building native extensions. This could take a while...
Successfully installed ruby-oci8-2.1.7
Parsing documentation for ruby-oci8-2.1.7
Done installing documentation for ruby-oci8 after 4 seconds
1 gem installed
# Oracle XE 11gR2 installed in a different VM (Host: 10.1.1.3)
#
$ ruby -r oci8 -e 'OCI8.new("ruby/ruby#10.1.1.3").exec("select * from session_privs") do |r| puts r.join(","); end'
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE SEQUENCE
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
Note that I can verify connection using the command above. However, I cannot create a new model using the "rails generate model Post title:string text:text" command - I get a long list of errors which complain that my "adapter" is not valid.
Questions:
Q1. What do I have to put in the Gemfile?
Q2. Should I see ruby-oci8 gem in the output of the command "bundle install" - currently I can see "Using sqlite3 (1.3.9) and there also 2 entries in the Gemfile as follows:
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
Q3. Has anyone successfully configured database.yml to work with Oracle XE? Please share it with me.
Thanks in advance for your help,
Roobie
Having ruby-oci8 installed is often the hard bit, so you're nearly there.
Activerecord needs an adapter to talk to any kind of database; for oracle you will want oracle enhanced.
So add this to your Gemfile then redo bundle install:
gem 'activerecord-oracle_enhanced-adapter'
Read the linked page for oracle-specific quirks. Your database.yml file should look like this:
database:
adapter: oracle_enhanced
database: //10.1.1.3:1521/XE
username: ruby
password: ruby
The "XE" in the database connection string is the SID. I think with oracle XE the SID is always "XE" but I don't have one handy and haven't used it since 10g.
You shouldn't need to add ruby-oci8 to your gemfile because the oracle adapter declares it as a dependency, but it doesn't hurt to add it.
I am trying to set my machine up so I can follow this tutorial: the intro to rails screen-cast i wish i had.
I keep running into issues, most recently the following:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/ansi-1.4.1/lib/ansi/code.rb:5:in `require':
no such file to load -- Win32/Console/ANSI (LoadError)
This occurs when ever I run rails g. (I would like to see if my r spec generator has been added.)
Environment details: Windows 7, ruby 1.9.2p290, rails 3.1.1, rubygems 1.8.15
After you installed "gem install win32console", can you add this gem into your Gemfile file and try to run bundle install again?
Gemfile
gem "win32console", "~> 1.3.0"
RailsInstaller may be your best bet if you're looking for an integrated Windows Rails experience.
It's up-to-date (-ish, doesn't use Ruby 1.9.3) with:
Ruby 1.9.2-p290
Rails 3.1.1
Git 1.7.6
and other useful bits.