My rails applications run on a shared host. I don't have access to a commandline and can't run the bundle command. I can run a few pre-selected rake commands.
On my development machine, I've done bundle install --deployment, so that all my gems are in vendor/bundle.
Problem is, however, that my development machine is not compatible with my shared host (32/64 bits), so the native extension of the mysql2 gem doesn't work on the shared host. The shared host does have the mysql2 gem installed, though.
If I remove 'mysql2' from the Gemfile, I get this error: !!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2' (<= this was because I had the adapter set to mysql instead of mysql2 in database.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: db
pool: 5
username: user
password: pass
socket: /var/run/mysqld/mysqld.sock
(same for test/production)
If I keep gem 'mysql2' in my Gemfile, I get this error (which makes sense, because of the native extension was compiled on a different machine:
/home/project/vendor/bundle/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.so: wrong ELF class: ELFCLASS32 - /home/project/vendor/bundle/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.so
If I remove gem 'mysql2', I get:
Please install the mysql2 adapter: 'gem install activerecord-mysql2-adapter' (no such file to load -- active_record/connection_adapters/mysql2_adapter)
I would like to specify which gems should be loaded from my own applications vendor/bundle directory and which gems from the system gem directory.
Is this possible with bundler?
What's the best solution for this problem?
Thanks.
Check your database.yml file. Make sure you are not referring to the adapter that you don't have installed in your environment.
Have you checked your gemlock file for -x86 gem references? I had a similar issue deploying from windows xp to 64-bit ubuntu. Modify these to remove the -x86 part and run bundle install again, this should build the 64-bit native gem if all the libraries are on the instance.
Related
I use Capistrano to deploy a Rails 3.2.1 app that uses mysql2 adapter.
The app is working fine locally on windows, but when i try to deploy to a linux server, Capistrano throws the following error:
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (mysql2 is not part of the bundle. Add it to Gemfile.)
Please note that i'm tracking Gemfile.lock on GIT but i noticed this:
...
mysql2 (0.3.11-x86-mingw32)
...
The lock file locked the version which is fine, but i think it locked the windows version (x86-mingw32) which might not work on linux.
Any one had the same issue? I don't want to untrack Gemfile.lock because it's not recommended.
My deploy.rb is like:
require "bundler/capistrano"
load "deploy/assets"
... configuration here ...
P.S. I also noticed other gems locked with this part "x86-mingw32", like bcrypt-ruby
Don't worry about any gems with "mingw32" in your Gemfile.lock. Take a look at your Gemfile. Do you have the following line?
gem 'mysql2'
Given this, did you run bundle install at the linux server (or did you put this functionality to your capistrano recipe?)
BTW, if you have any windows-specific gems, and you want to be sure that they are only loaded in this context, use the following condition:
platforms :mswin, :mingw do
# placeholder for gems in a windows environment
end
I have installed ruby(1.9.2),gem(1.8.10) and rails(3.1.0), and MYSQL is runnig on WAMP. when I try to install mysql2 0.3.7 gem(gem install mysql2 -v 0.3.7)
when run the following command it shows error
and also tired
C:/dev/Ruby192/bin/ruby.exe extconf.rb --with-mysql-lib="c:\Program File
s\MySQL\MySQL Server 5.1\lib\opt" --with-mysql-include="c:\Program Files\MySQL\M
ySQL Server 5.1\include"
but looks like i dont have \lib and \include folders in my MYSQL installed directory(in this case D:\wamp\bin\mysql\mysql5.5.8).
please help me installing the mysql gem version greater than 0.3(as I am using Rails 3.1).
Any help will aapreciated.
Thanks
Nagendra
For those cases, you should try install either mysql or mysql2 gem against MySQL Connector/C
I've written a tutorial about that:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
Install Mysql Connector/C, it provides necessary lib and include files.
I am still having problem with mysql2 gem but below approach helped me install mysql with RoR on Windows Env.
Step 1 : Gem File changes : ({app}/Gemfile)
Update mysql2 --> mysql
Step 2 : Updates in database.yml file ({app}/config/database.yml)
Change adapter: mysql2 --> adapter: mysql
host: localhost --> host: 127.0.0.1
Step 3 : Downoad mysql-connector-c-noinstall-6.0.2-win32
Step 4 : Copy mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll file to C:\RailsInstaller\Ruby1.9.3\bin
Step 5 :bundle update && Start rails server
bonjour dudes.
i have a small problem with rails.
today i install rails 3 and decided create a new project.
rails new blablabla --database=postgresql
i edited database.yml and paste to it my databases, logins and passwords of postgres.
my postgresql works on port 5433 (instead of 5432)
database.yml example:
development:
adapter: postgresql
database: devdb
encoding: utf8
username: postgres
password: mypassword
host: localhost
port: 5433
i just want to start server, or add controller, but rails says:
Could not find gem 'pg (>= 0)' in any of the gem sources listed in your Gemfile
but i have 'pg'. i think problem with port, but i dont know how fix problem.
sorry for bad english, and thanks for answers.
It would appear from the error message that you are using Bundler to manage your gems for the project. Have you tried running bundle install to bring all of your sources in the Gemfile up to date? Here is an example:
> bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
[...]
Using zendesk_remote_auth (0.9.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
My Rails server worked well through normal development scripting and I planned to use Netbeans for Rails. When I started my existing project with Netbeans and restarted my Webrick server, It shows error
RuntimeError (Please install the jdbcmysql adapter: gem install activerecord-jdbcmysql-adapter (no such file to load -- java))
I feel this error is related with JRuby, But I never using JRuby and I am using Ruby 1.9.2, Rails 3.0.0 and I dont want to use JRuby and Glassfish. I tried to remove default JRuby and Ruby1.9.2 as default, but i cant. I feel there may be a cause of linking error w.r.t JRuby. Kindly help me to rectify this issue.
Got the same error.
Look in your config/database.yml - netbeans changes the adapter automatically. Just write 'sqlite3' as adapter or whatever fits for you instead of 'jdbcmysql'.
Hope I could help!
I solved this issue, In Netbeans,,, i set Ruby 1.9.2 as default by
Project -> Right Click "My project" -> Set Configuration ->Customize -> Changed Ruby Platform as "Ruby 1.9.2" from "JRuby".
Now it works without any error. This may help for some other reader.
--
With Thanks,
Palani Kannan. K,
You didn't install the necesary gem, that's all. You need to do this: gem install activerecord-jdbcmysql-adapter to install necesary aditional gems, and then you have to edit your database.yml with the proper gem, for example:
development:
adapter: jdbcmysql
encoding: utf8
reconnect: false
database: db_development
pool: 5
username: username
password: passwrd
socket: /var/run/mysqld/mysqld.sock
Check your database.yml file you will find that tha adapter have been changed from your previous configured database to jdbcmysql.
you can delete it and write it back!
For example:
development:
adapter: jdbcmysql
and if you were using mysql
development:
adapter: mysql2
And it will works!
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
ruby mysql2 gem installation issues
I have worked with ruby on rails with mysql2 database. I have installed the the mysql2 gem in my system. I successfully configure my database my database.yml file which is
development:
adapter: mysql2
database: AddressBook
username: root
password: root
host: localhost
pool: 5
timeout: 5000`
but the issues are
When i tried to create my model using the command rails g model contact it shows an error
"Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (no such file to load -- active_record/connection_adapters/mysql2_adapter) (RuntimeError)"
like this.
So in order to install mysql2 i have execute the command gem install mysql2. It shows 1 gem installed with a message of "Enclosing class/module 'mMysql2' for class Client not known"
And one more thing, after installing mysql2 gem file if i am check the existence of mysql2 using command
which mysql2
it again shows no mysql2 is installed with a message
"/usr/bin/which: no mysql2 in (/usr/lib/ccache:/usr/lib/ccache:/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/zoondia001/bin)"
If ruby on rails database connection is not possible with mysql2 please tell me another way to connect ruby on rails to database
i am using fedora 13 and installed ruby,ruby on rails and all the gems that are needed for running. Anybody please tell me how track this problem, i am nearly spend my 48 hours for tracking this issues but not getting the solution. please help me
thanks
Add
gem 'mysql2', '< 0.3'
in gemfile
Finally it is corrected. I have remove ruby,rails and gem from system and re-install again. Any way thanks for the help