Where is the Gemfile in Windows 7 located? - mysql

i need some help at ruby on rails specially with ruby gems.
If i use the "rails generate scaffold something", I get always the failure:
"Specified 'mysql2' for database adapter, but the gem is not loaded. Add 'gem' mysql2 to your Gemfile(Gem::LoadError)"
If i use the command "gem -list" mysql2(0.3.15) will show up in this list.
After some search i read(Install mysql adapter gem install)
that i should edit the Gemfile and add gem 'mysql2', "~>0.3.15" instead of gem 'mysql2' in Gemfile.
So my problem is now where is this Gemfile located. I use ruby on Windows 7, and i installed Ruby with the "railsinstaller-2.2.2"
Regards, dot

Related

Rails: bundle doesn't show installed mysql2 gem

I know may be this is a popular problem but i try many solutions and not get to finish
I try to install mysql in rails with
gem install mysql2
And I get the result
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.18
1 gem installed
But when i try to execute the command
bundle show mysql2
I get
Could not find gem 'mysql2'.
All these command execute in my application root directory
What is the problem ?
bundle show lists the names and versions of all gems that are required by your Gemfile, so at first you should add mysql2 gem to it:
gem 'mysql2'

Can't Connect to MySql From Rails Application in Windows

I am trying to create a Rails application in windows with MySQL as the Database. I have created a rails app and it runs just as fine. But when I try to connect to the mySQL database I am getting weird errors, which I was unable to solve after hours of Googling and hunting around. Maybe I am performing a silly mistake, new to Rails and Ruby.
Here is how I proceeded in creating the app with MYSQL
In command prompt
rails new sample_app -d mysql
[success]
Opened a new command prompt window and
C:\sites\cd sample_app> rails -s
Now I get this error
Could not find gem mysq12 (>=0) in any of the gem sources listed in your Gemfile
Run bundle install to install missing gems
Note: I didn't get the error when I created my first rails app without using Mysql.
Next, I ran this command
gem install mysql2
And got this
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for rb_hash_dup()... no
checking for rb_intern3()... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Next I ran this one -
bundle install
Closed all command prompt windows, opened a new one, moved to my app directory and typed
rails -s
Error:
could not find gem mysq12 (>=0) in any of the gem sources listed in your Gemfile
Run bundle install to install missing gems
Here are some information which I think will be useful
- Rails 3.0.9
- Ruby 1.8.7
- rake (10.1.0, 0.8.7)
- mysql (2.9.1 x86-mingw32)
- MySql 5.6 installed and running (I have created a DB and tables)
- OS: Windows 7 64bit
Here is how my database.yaml file looks like:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_development
pool: 5
username: root
password: buiskol
host: localhost
Here is how the gemfile of the app looks like
source 'http://rubygems.org'
gem 'rails', '3.0.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2', '~> 2.9.1'
I think the problem is that my mysql2 gem is not properly installed. I am not sure where I am doing the mistake. Any help will be much appreciated.
Why are you using gem 'mysql2', '~> 2.9.1' instead of gem "mysql2", "~> 0.3.13"? According to this, there isn't any 2.9.1 version, maybe you meant 0.2.9 ? Otherwise, you're installing the wrong version of that gem, or the wrong gem with the right version.
You should use:
gem "mysql", "~> 2.9.1"
or
gem "mysql2", "~> 0.3.13"
in your gem file. Since there's no version 2.9.1 for mysql2, correct the typo and try again

Mysql version (0.3.11) doesn't ship with Activerecord

I have a old rails project that is using rails 3.0.9 and I am trying to run it using rails s. It appears that when I do this is gives me the following error:
You will see that it says that the current adapter that I have installed is not supported by foriegner. I have updated my gemfile to look like the following:
gem 'rake', '0.9.2.2'
gem 'mysql2'
gem 'rails', '3.0.9'
gem "acl9"
gem 'foreigner'
gem 'devise'
gem 'will_paginate', '3.0.pre2'
gem 'jquery-rails'
gem 'lazy_high_charts'
gem 'client_side_validations'
gem 'carrierwave'
gem 'tiny_mce'
#gem 'devise_security_extension'
#gem 'rails_email_validator'
#gem 'easy_captcha'
group :development do
gem 'rspec-rails', '2.6.1'
gem 'jspec'
gem 'faker', '0.3.1'
gem 'rspec'
gem 'annotate'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'spork', '0.9.0.rc8'
gem 'webrat'
gem 'autotest-growl'
gem 'autotest-rails'
gem 'autotest', '4.4.6'
gem 'autotest-rails-pure', '4.1.2'
gem 'factory_girl_rails'
gem 'ZenTest'
gem 'test-unit'
end
What I don't seem to understand is why it would say in the command prompt that the gem is missing and I need to add it to my gemfile when it is there. What is the best solution to tackling this.
It isnt working cause you are trying to install the latest version of mysql2 which doesnt work with rails 3.0.X. You can get around this by specifying the version this way
gem 'mysql2', '< 0.3' or gem "mysql2", "~> 0.2.7"
But to get around the foreigner dependency which is probably the main issue here:
You can upgrade your rails version to 3.1.x or higher and upgrade the mysql2 in the gem file. I see that you have a recent version of ruby.
After you update the gems in the gemfile, make sure you run bundle install in the command line...before trying to start the server. Also, ensure that you setup your database in the database.yml file in the config folder.
edit your config/database.yml file from:
adapter: mysql
to
adapter: mysql2

How to resolve Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)

I am running a rails3 app on Dreamhost: not the best call but I need it operational before I can pitch migrating to Heroku.
I am using rails 3.2.1, and ruby 1.8.7 with
gem 'mysql2', '~> 0.2.7'
in my Gemfile...
I get the following error when I deploy and reload:
Please install the mysql adapter: gem install activerecord-mysql-adapter (mysql is not part of the bundle. Add it to Gemfile.)
I have tried gem 'mysql2', gem 'mysql2', '< 0.3' and get the exact same issue.
Any other ideas?
First try adding config.assets.initialize_on_precompile = false to your application.rb.
Then make sure your DATABASE_URL var starts with mysql2:// instead of mysql://
In general when rails is trying to be helpful it will try to generate the name of an adapter gem based on whatever you have in your database.yml. If that gem doesn't exist it's a good indication that something with the adapter line is wrong
for mysql2 the adapter type needs to be mysql2 as well
database.yml
adapter: mysql2
I had the same problem and after checking if you have in database.yml that you have adapter:mysql2 you should check if you have the gem of mysql loaded.
in your Gemfile you should have the line : gem "mysql2" and not other database like sqlite3 which was my case.
Hope this helps.
I get into the same situation of trying to set up mysql with Ruby on Rails for my
Windows Vista platform installed with MySQL 5.5 and Rails Installer for Ruby 1.93.
After getting the adapter and connector for mysql2, I still get this error message : "rubygems_integration.rb:143:in block in replace_gem': Please install the mysql2
adapter:gem install activerecord-mysql2-adapter` (mysql2 is not part of the b
undle. Add it to Gemfile.) (LoadError)"
I checked the my gem directory "Ruby1.9.3\lib\ruby\gems\1.9.1\gems" and see
both activerecord-mysql2-adapter-0.0.3 and mysql2-0.3.11-x86-mingw32 are there and
the database.yaml file is correctly updated.
The missing piece is here:http://www.mohanarun.com/how-to-install-mysql-adapter-ruby-gem-in-windows/
After restarting the MySQL server and update the gem file as stated in the above URL. It works.
I hope this will work for you.

How to install mysql2 gem using bundler and capistrano

I'm trying to deploy a small rails3 app to a FreeBSD host using capistrano and bundler. I have added the line
require 'bundler/capistrano'
to my deploy.rb file, and bundler seems to work fine until it comes to the mysql2 gem. Here the install fails because the install script uses chmod and chgrp to try to install the gem with root:wheel as it's owner. This fails and I'm stuck with a half installed app.
I tried to trick bundler into using the system wide version of the mysql2 gem like this:
group :production do
gem 'mysql2', :path => "/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.6"
end
group :development, :test do
gem 'mysql2'
end
But this is not allowed by bundler, and I can't leave the path in the development mode, as the setup for the development machines are completely different.
Has anybody had any luck getting the mysql2 gem work with a bundler/capistrano setup on FreeBSD?
Add this to your deploy.rb
default_environment['RB_USER_INSTALL'] = '/usr/bin/install -c'