How To Install mysql2 gem on Windows 7

First things you should have Ruby, MySQL Server and Connector C installed on the system before trying to install the mysql2 gem AND each one of those components must all be 32bit or all 64bit. No mixing.

Installing MYSQL2 Ruby on Rails gem on a Windows environment can be difficult, typically showing the infamous “ERROR: Failed To Build Native Extension” error:-

If you’re seeing this error, the good news is it’s actually quite simple to resolve. It’s caused because you don’t have the MYSQL C-connector library installed.

Download the MYSQL C-Connector Library

Download archive for the 32bit or 64bit version of Connector C from the direct downloads page.

Unzip the folder to your C:\ drive

Open a command prompt and execute: gem install mysql2 –platform=ruby — ’–with-mysql-dir=”C:\mysql-connector-c-6.1.6-winx64\include”’

Now,

Copy:libmysql.dll from C:\mysql-connector-c-6.1.6-winx64\lib and paste into to C:\Ruby1.9.3\bin folder

This will complete the installation

Test out the installation by running rake db:create command

Advertisements

Install Ruby on Rails in Ubuntu with RVM AND Create Gemset

Step One— Install Ruby with RVM

First check that all of the packages we download are up to date:

1 ) sudo apt‐get update

Once that’s done, we can start installing RVM, Ruby Version Manager. This is a great program that lets you use several versions of Ruby on one machine. If you do not have curl on your system, you can start by installing it:

2) sudo apt‐get install curl

To install RVM, open terminal and type in this command:

3) gpg –keyserver hkp://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

After this type below command

4) \curl -sSL https://get.rvm.io | bash -s stable –rails

After it is done installing, load RVM. You may first need to exit out of your shell session and start up a new one.
5) source ~/.rvm/scripts/rvm

In order to work, RVM has some of its own dependancies that need to be installed. To automatically install them:
6) rvm requirements

You may need to enter your root password to allow the installation of these dependencies.

Step Two—Install Ruby

Once you are using RVM, installing Ruby is easy.
rvm install ruby

The latest ruby is now installed. However, since we accessed it through a program that has a variety of
Ruby versions, we need to tell the system to use the version we just installed by default.

rvm use ruby ‐‐default

Step Three—Install RubyGems (OPTIONAL)

The next step makes sure that we have all the required components of Ruby on Rails. We can continue
to use RVM to install gems; type this line into terminal.

rvm rubygems current

Step Four—Install Rails

Since Rails ships with so many dependencies these days, we’re going to need to install a Javascript runtime like NodeJS. This lets you use Coffeescript and the Asset Pipeline in Rails which combines and minifies your javascript to provide a faster production environment.

To install NodeJS, we’re going to add it using a PPA repository:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

And now, without further adieu:

gem install rails

Now that you’ve installed Rails, you can run the rails -v command to make sure you have everything installed correctly:

rails -v
# Rails x.x.x

If you get a different result for some reason, it means your environment may not be setup properly.

Now, exit your shell and reopen it. Enter command ruby -v. If you get message as ruby does not found, paste below command and check the output

$ type rvm | head -n 1

If output shows “RVM is hashed” or Any other message other than “RVM is a function” that means RVM is not loaded and ofcourse rubies and rails srored inside .rvm directory thats why it was not showing ruby version.

If the o/p of above command shows: ‘rvm is a function’ the problem is solved if not then follow below steps:

To permanently resolve this just copy/paste following line:

[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm”

From: ~/.bash_profile file

To: ~/.bashrc file

Reason this works is that .bashrc is executed each time you enter terminal, and .bash_profile each time you login. That is why solution /bin/bash –login works, but you have to do that each time you enter terminal. This way you are set until your next format, and you will forget all this by then.
check RVM installed correctly by using rvm -v command

CREATE GEMSETS

To see list of gemsets:

rvm list gemsets or rvm gemset list_all

CREATE:

rvm gemset create “gemset_name”

rvm  –­­create ­ –­ruby-­version ruby­1.9.3@my­gemset
It created both .ruby­gemset and .ruby­version.

If you already have created gemset then do this:

rvm ­­ –ruby-­version use 1.9.3@my_app
The will create both .ruby­version and .ruby­gemset.

if you want to only specify a ruby version and do it with rvm you would do: rvm –­­ruby­-version use
1.9.3. This only creates a .ruby­version file.

ENJOY 🙂

Install JAVA on Ubuntu 14.04

First of all check Java is installed or not by following command:

java -version

If java is not installed then it will show:”The program java can be found in the following packages”, Java hasn’t been installed yet, so execute the following command:

sudo apt-get install default-jre

This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:

sudo apt-get install default-jdk

That is everything that is needed to install Java.

All other steps are optional and must only be executed when needed.

Installing OpenJDK 7 (optional)

To install OpenJDK 7, execute the following command:

sudo apt-get install openjdk-7-jre 

This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), execute the following command:

sudo apt-get install openjdk-7-jdk

Installing Oracle JDK (optional)

The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.

You can still install it using apt-get. To install any version, first execute the following commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Then, depending on the version you want to install, execute one of the following commands:

Oracle JDK 6

This is an old version but still in use.

sudo apt-get install oracle-java6-installer

Oracle JDK 7

This is the latest stable version.

sudo apt-get install oracle-java7-installer

Managing Java (optional)

When there are multiple Java installations on your Droplet, the Java version to use as default can be chosen. To do this, execute the following command:

sudo update-alternatives --config java

It will usually return something like this if you have 2 installations (if you have more, it will of course return more):

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:

You can now choose the number to use as default. This can also be done for the Java compiler (javac):

sudo update-alternatives --config javac

It is the same selection screen as the previous command and should be used in the same way. This command can be executed for all other commands which have different installations. In Java, this includes but is not limited to: keytool, javadoc and jarsigner.

Setting the “JAVA_HOME” environment variable

To set the JAVA_HOME environment variable, which is needed for some programs, first find out the path of your Java installation:

sudo update-alternatives --config java

It returns something like:

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:

The path of the installation is for each:

  1. /usr/lib/jvm/java-7-oracle
  2. /usr/lib/jvm/java-6-openjdk-amd64
  3. /usr/lib/jvm/java-7-oracle

Copy the path from your preferred installation and then edit the file /etc/environment:

sudo nano /etc/environment

In this file, add the following line (replacing YOUR_PATH by the just copied path):

JAVA_HOME="YOUR_PATH"

That should be enough to set the environment variable. Now reload this file:

source /etc/environment

Test it by executing:

echo $JAVA_HOME

If it returns the just set path, the environment variable has been set successfully. If it doesn’t, please make sure you followed all steps correctly.

Ubuntu Installation Problems

Well, Guys this post explain how to tackle some problems while installing ubuntu 14.04.2 LTS alongside windows 7

  1. You should not make more than 2 partitions otherwise its will show the option install ubuntu inside windows 7 and you might go into the cycle of auto-rebooting.
  2. After making two partition you can see the option install ubuntu alongside windows 7
  3. Now you can install alongside windows 7