Translate

August 29, 2012

How to install Ruby on rails in Windows 7

Introduction:
This is a step by step tutorial that will let you install Ruby on rails 3 in your Windows 7. These steps ease the installation process.

Steps:
  • Download Ruby Windows installer from ruby-lang.org
  • Select version 1.9.3, which is the most recommended and stable release for Windows. 
    When installing this software, make sure to check "Add Ruby to PATH".
  • After installing Ruby, open CMD and check if you Ruby is accessible by executing the following command:
  • ruby -v

    If it works fine you should see the version number of Ruby
  • Then check if you can access gem command by executing:
  • gem -v
  • As you will see, probably the gem version installed by default if this is not the latest, you need to update gem like this:
  • gem update --system
  • Now you are ready to install Ruby on rails, without rdoc and ri documents. By executing following command
  • gem install rails --no-ri --no-rdoc

    Ruby on rails works with SQLite by default but we will use MySQL.
  • In order to let you use both, let us download SQLite and then configure MySQL.  Download SQLite dlls from sqlite.org, unzip them and copy them to:
  • c:\<your_ruby_dir>\bin
  • Now you should install SQLite gem:
  • gem install sqlite3-ruby
  • Now it is time for MySQL. Go to the MySQL website and download the community edition and after installing it in your OS, download this libMySQL.dll and copy it into the same location you put the SQLite dlls
  • c:\<your_ruby_dir>\bin
  • Now install the MySQL gem. To install the mysql gem execute:
  • gem install mysql
  • Now we are ready to create a testing project in rails. Since we are going to use MySQL as DB, we should then execute:  
  • rails new my_first_project -d mysql

August 15, 2012

Missing gcc-4.2 on Mountain Lion

Missing gcc-4.2 on Mountain Lion

I've seen reports of missing /usr/bin/gcc-4.2 on OSX 10.8 (Mountain Lion). Some have tried to reinstall xCode and that worked for them.

I got this when I was trying to install gem
    make
    ....
    make: /usr/bin/gcc-4.2: No such file or directory
    make: *** [bcrypt_ext.o] Error 1
    

Executing following command solved problem on my system.

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

apple-gcc42 installs its gcc-4.2 binary into /usr/local/bin (or wherever you installed Homebrew), not /usr/bin.
Your ruby gems are probably trying to use gcc-4.2 because ruby configures itself to build C extensions with whichever compiler built ruby itself. If you built ruby using gcc-4.2 on an older version of Xcode when that still came with gcc-4.2, that would explain why it's looking for that specific path. Reinstalling ruby with /usr/local/bin/gcc-4.2 would fix the problem.

Note: Linking /usr/bin/gcc to /usr/bin/gcc-4.2 is not perfect way, This is simple trick.

August 14, 2012

Install RVM, Ruby, Ruby on Rails on OS X Mountain Lion 10.8

OS X Mountain Lion was released for all users in the Mac App Store.
Here are some of the things you should consider as you make the switch to this shiny new operating system.

After I downloaded the 4GB installer from the Mac App Store, the whole upgrade process took me about 45 minutes on my 13" 2012 Macbook Pro. It was a simple and straightforward process as the installer takes care of everything.

Once the installer is done, we need to do some additional work to get up to speed once again and be able to compile Ruby (using RVM) or install packages using Homebrew.

Install Xcode + Command Line Tools
You can get Xcode from the Mac App Store. You'll need at least version 4.4 of Xcode for it to work with OS X Mountain Lion. After the installation, open up Xcode in your /Applications folder. You'd want to go to Xcode -> Preferences -> Downloads tab then install the "Command Line Tools". After you're done, quit Xcode and fire up Terminal.

After the upgrade, Apple will set the ownership of your /usr/local folder to root. You can easily fix this by running this command in Terminal:

sudo chown -R `whoami` /usr/local

Next, you need to update Homebrew:

brew update

To install any Ruby that's older than 1.9.3 like 1.9.2, 1.8.7 etc.
You'll need to install GCC 4.2. Apple does not ship the Command Line Tools with gcc-4.2 compiler anymore,
You need to install it via Homebrew. By default, Homebrew doesn't include any formula that ships with the OS in the main repository, so you'll have to enable homebrew-dupes repository by using brew tap

  brew tap homebrew/dupes
  brew install apple-gcc42 

If you were using a binary package from MySQL website to install your MySQL server, you will need to change the ownership of your MySQL data directory back by issue this command:
sudo chown -R mysql:mysql `brew --prefix`/mysql
Word to the Wise: Backup Your System
Before performing any major upgrade, always make sure that you have the latest backup of your Mac.

August 10, 2012

*** Textmate 2 - Open Sourced ***

One of most known code/text editors on OS X went open source. Since yesterday TextMate 2 is available on GitHub.

Allan Odgaard's TextMate has been a beloved text editor since 2004 and one of gem of Mac's favorite apps for about just as long, but since 2009, development on the app has slowed to a crawl: three years ago, Odgaard said TextMate 2 was about 90% complete, but it didn't hit the web until end of year 2011, also a final version still hasn't been released.

In a surprise (and very awesome move), its source code has: TextMate 2 is going open source.

If you're interested in tinkering or even compiling TextMate 2 for yourself, you can grab it on GitHub.

Legal
The source for TextMate is released under the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
TextMate is a trademark of Allan Odgaard.