I run
rake db:create
and getting strange error
rake aborted!
126: ═х эрщфхэ єърчрээ√щ ьюфєы№. - C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-
0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so
I tried to reinstall bundler.
Is it gem problem ?
To solve this problem, reference to the following link:
http://maxivak.com/installing-mysql2-gem-on-ruby-1-9-2-and-rails-3-0-5-on-windows/
You need to include mysql-connector through the Rails DevKit.
Related
Guy today i was open old Ruby project
after copy the files to my Sites folder then run this commands
bundle
rake db:create
rake db:migrate
rails s
when i was open my project on the browser i found the project gives me errors because
MySQL not work with me also i got this error on the console
ActiveRecord::SchemaMigation Load (68.0ms) select 'schema_migrations'.* from 'schema_migrations'
processing by HomeController#index as HTML
Completed 500 Internal Server Error in 92ms
log writing faild. invalid byte sequence in US-ASCII
so why i got this error and how i can solve that ??
I solved it now
just to solve the US-ASCII issue
i added this line to the first line in my model page
#encoding: utf-8
also i added the lines
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
in my Gemfile
then i got another error told me use protected_attributes
so i added the line
gem 'protected_attributes'
in my Gemfile and then execute:
$ bundle
I was following a tutorial on lynda.com (RoR 3: Section 6, ep. 3) and after installing MySQL and running:
rake db:schema:dump
I got:
rake aborted! cannot load such file mysql/mysql_api
C:/Sites/demo/config/application.rb:7:in '<top <required>>'
C:/Sites/demo/Rakefile:4:in 'require'
C:/Sites/demo/Rakefile:4:in '<top <required>>'
I did copy:
libmySQL.dll
To:
C:\RailsInstaller\Ruby1.9.3\bin
and I also tried uninstalling and installing the mysql gem a couple of times.
I think your problem is similar to cannot load such file -- mysql/mysql_api.
If you are trying to access 64 bit MySQL from 32 bit Ruby then you might encounter this.
I'm using JRuby 1.7.2, along with DataMapper, and I'm getting an error I can't find an answer to.
I'm just testing out DataMapper along with MySQL 5.5 to see if it will run fine when I build around it. Here's the file I'm testing:
require "data_mapper"
require "keys"
DataMapper.setup(:default, "mysql://#{$user}:#{$pass}#localhost/test_db")
And when I run this, I get the error:
NameError: cannot load Java class com.mysql.jdbc.Driver
And it points to the DataMapper.setup line.
My Gemfile should be alright:
source :rubygems
gem "sinatra"
gem "trinidad"
gem "data_mapper"
# do a `sudo apt-get install libmysqlclient-dev` first
gem "dm-mysql-adapter"
gem "jdbc-mysql"
Is there anything I'm missing? I have MySQL set up with a user/pass locally already.
This is a common error when running JDBC clients for MySQL. You need to make sure you have mysql-connector-java-bin.jar on the classpath. You can download it from here.
I'm using Rails 3.2.9 and to solve the problem I added this to my application.rb
if defined? JRUBY_VERSION
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
end
actually, the correct answer is to work-around an incompatibility between 5.1.13 and 5.1.22 !
jdbc-mysql gem already contains the mysql-connector.jar it just ain't auto-loading anymore :
https://github.com/jruby/activerecord-jdbc-adapter/tree/master/jdbc-mysql (read the README)
you can also force the driver to auto-load using a Java system property e.g. from a cmd line :
jruby -J-Darjdbc.mysql.autoload=true -S rake ...
I had the same error when trying to use a mysql database from jruby/rails4. In my case this line was missing from ./Gemfile:
gem 'jdbc-mysql'
I am working on Rails 2.3.8. I have following in my environment.rb
config.gem "redis"
config.gem "redis-namespace", :lib => "redis/namespace"
When I list my redis gems then I see:
redis (2.0.3)
redis-namespace(0.7.0)
When I run rake gems:install then I get an error that says:
no such file to load -- redis-namespace
Shouldn't requiring "redis/namespace" solve the issue? Can anyone please help me with this?
It sounds as if rake gems:install depends on the very gem it is trying to install.
Try using rails_gem_install or bundler instead.
After I updated to ubuntu 12.10, I started getting this error:
NoMethodError: undefined method `init' for Mysql:Class
I am using the mysql adapter.
% gem install mysql
solved the problem. Note that this gem was installed already even before I updated the ubuntu version but somehow the setup got messed up in the update.