Mysql2 gem installation issue on ubuntu with ruby on rails - ruby-on-rails

I am unable to install mysql2 gem .
I have recently installed ruby 2 and rails 4 version .
I am not able to install mysql2 gem, getting the below error when i run the command gem install mysql2:
Some index files failed to download. They have been ignored, or old ones used instead.

Make sure that the following packages are installed first
sudo apt-get install mysql-client mysql-server libmysqlclient-dev
You may need to run
sudo apt-get update
before installing them

You should provide more information. But here some thoughts:
Why are you using gem install mysql2 instead of adding the gem to your Gemfile and run bundle?
I had some issues with Rails 4 and mysql2 v0.4.x and downgraded to v0.3.20

Related

tiny_tds gem installation issue on Rails 5

I have tried to install gem tiny_tds on Rails 5, but not able to install. I have googled it and tried all the solution. But there is no solution. Can you please suggest me to install it.
Below are the solutions I have tried,
Rails 4: Error when installing tiny_tds gem?
sudo apt-get install freetds-dev
tiny_tds gem can be easily installed from terminal using following command:
$ gem install tiny_tds
If any other issue you are facing with tiny_tds gem you can refer the documentation of gem:
https://github.com/rails-sqlserver/tiny_tds
Make sure you have freetds library installed in case of MacOS
brew install freetds
Debian 10
Rails: 5.2
Ruby 2.5
How to Install FreeTDS:
source: https://www.microsoft.com/en-us/sql-server/developer-get-started/ruby/ubuntu/
Use the Terminal with Root or Sudo permissions to run the following commands:
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.27.tar.gz
tar -xzf freetds-1.00.27.tar.gz
cd freetds-1.00.27
./configure --prefix=/usr/local --with-tdsver=7.3
make
sudo make install
cd ..
gem install tiny_tds
This should get you started.

Rails - Gem Error while installing pg (1.1.3), and Bundler cannot continue

I am still fairly new to Rails. I am trying to push to Heroku and I am getting errors.
The first error is when I run a Bundle Install I get this error message:
"An error occurred while installing pg (1.1.3), and Bundler cannot continue.
Make sure that gem install pg -v '1.1.3' succeeds before bundling."
I have tried to run this command
gem install pg -v '1.1.3'
But it fails and gives me this error message:
"ERROR: Error installing pg:
ERROR: Failed to build gem native extension."
Does anyone have a solution to this?
I had the exact same problem, and solved it by running sudo apt install postgresql-contrib libpq-dev. Then bundle worked just fine.
if you're using OSX, you could try running
brew install postgresql
and then installing the gem
TL;DR; If you installed the Postgres using the PostgresAPP instead of BREW then the problem might be that you don't have the postgres bin folder in the $APTH
The solution is to find the Posgres app installation folder an in it the /bin folder.
In my case if I run which postgres doesn't work which means I don't have it in my $PATH, so what I did is I navigated to: cd /Applications/Posgres.app then to Contents and then to Versions until I found the latest folder:
/Applications/Postgres.app/Contents/Versions/latest/bin
Now, with this I can install the PG GEM by providing the path to the bin folder of my Postgres app installation
Finally, in the terminal in the root of my Rails project I ran where I provide the postgres config file path to the GEM installer:
gem install pg -v '1.2.3' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
I encountered the same problem. I am using Ubuntu. I installed Postgres using this Ubuntu guide. After installing Postgres, I ran this code sudo apt install postgresql-contrib libpq-dev then bundle install.
The accepted answer is not correct. If you installed postgresql-contrib and libpq-dev as mentioned in Cesar Faria answer, and you still getting the same error, most probable you missed the list of packages which are considered essential for building Debian packages. All that packages included in build-essential package. So, all you need to do to get rid of the error is the command below.
sudo apt install libpq-dev build-essential
try instaling with pg-config like this:
gem install pg -v 1.1.3 -- --with-pg-config=/usr/pgsql-9.X/bin/pg_config.
In pg-config path mention the posgtres version installed in you're system.
Postgresql needs to be in local in order to install gem pg. Try this
brew install postgresql
and the re-install bundle
bundle install
or
If you are using yum. Try this
sudo yum install postgresql-devel
The following is only for your local environment:
Note: Update the command below to match your version postgresql/13.2/...
> brew install postgres
> sudo gem install pg -v '1.1.4' --source 'https://rubygems.org/' -- --with-pg-config=/usr/local/Cellar/postgresql/13.2/bin/pg_config
Also, make sure to start your server > pg_ctl -D /usr/local/var/postgres start

MySQL gem install error on Windows 7

I am using Windows 7 and creating connection to MySQL2. I need to install gem. I am following these steps. Could someone please review them:
Add the following to the Gemfile: gem 'mysql2', '~> 0.3.15'
Run the following in cmd: gem install mysql2 -v '0.3.15'
Go to the application using cmd and run this code: bundle install
When I perform step (3), I get the following error:
An error occurred while installing mysql2 (0.3.15), and bundler cannot
continue make sure that `gem install mysql2 -v "0.3.15" ' succeeds
before bundling..
My application resides on the D drive and I am using Windows 7.
I have found a solution that works on Ubuntu.
My mistake was that had not installed the my-sql library before trying to connect.
Please follow these steps to do this. Run the following commands:
sudo apt-get install mysql-client libmysqlclient-dev
sudo gem install mysql2
Add the following to the gemfile
gem 'mysql2', '~> 0.3.15'
And then run:
bundle install

mysql2 gem installation on linux

I am trying to install a gem on linux but it is giving me an error:
An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.3.11' succeeds before bundling.
What do I need to do now?
Probably, it can't build mysql2 native extension.
If you're using Ubuntu 14.04 or newer, try sudo apt-get install ruby-mysql libmysqlclient-dev.
On older versions of Ubuntu install this: sudo apt-get install libmysql-ruby libmysqlclient-dev
On OS X: brew install mysql
There are also similar questions: 1, 2, 3.
I was using LInux 16 Cinnamon and got that error message. I used "Resure"'s, solution sudo apt-get install libmysql-ruby libmysqlclient-dev
then ran bundle install for project.
It worked!

problem in installing rails

hi all i am getting problem while installing rails in by gem :
i have written in terminal
gem install rails
Successfully installed rails-3.0.3
1 gem installed
Installing ri documentation for rails-3.0.3...
File not found: lib
what i need to do next and how to install rails using gem.
I had the same problem. I continued with the error. I do not see anything breaking. And I can code peacefully. So, probably you do not need to worry.
sudo apt-get install build-essential libopenssl-ruby libfcgi-dev
sudo apt-get install ruby irb rubygems ruby1.8-dev
sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install rails
sudo gem install sqlite3-ruby
If you dont find path do this: (for Unix based systems)
Quoted from the book, but anyone else would suggest the same
If you can’t find the rails command, you may need to add
/var/lib/gems/1.8/bin to your PATH environment variable.
You can do this by adding a line to your .bashrc file:
export PATH=/var/lib/gems/1.8/bin:$PATH
OK as aditya sanghi has mentioned, I do lack rdoc gem-- so probably running this will help
gem install rdoc rails
I've seen this error when you dont have the "rdoc" gem installed. Can you do a "gem list" and show us a list of gems installed?
Try running "gem install rdoc rails".

Resources