Showing posts with label install. Show all posts
Showing posts with label install. Show all posts

Sunday, August 19, 2012

Ubuntu 12.04: No Root File System Is Defined

Problem

I got this error when trying to do a fresh install of Ubuntu 12.04 from USB. I get past the screen that asks if you want to download updates and install third party software, then I get stuck on the "Installation Type" screen.

The installer only sees /dev/sdb which is my USB and shows nothing in the partitions table. All the buttons are disabled. Clicking continue gives me the error "No root file system is defined".

Instead of installing, I went to "Try Ubuntu". This loaded up the Ubuntu desktop. Checking gparted and fdisk, I was able to find /dev/sda. Great! Unfortunately, trying to install gives me the exact same problem.

Solution

When you "Try Ubuntu", open up a terminal and type
sudo apt-get remove dmraid -y
It gave me some errors, but I ignored them. I ran the installer from the desktop and voila! The installer sees /dev/sda and I could install Ubuntu 12.04

References

http://askubuntu.com/questions/111926/installation-stuck-on-installation-type-screen

Friday, September 16, 2011

Ubuntu: Install from USB

Apparently, you can install Ubuntu through a USB stick if your BIOS can boot from USB. I though this was pretty neat and wouldn't have to deal with throwaway media like CDs and DVDs. Unfortunately, each time I tried, the computer would not boot from the USB. It just kept booting from the harddrive no matter what I did in the BIOS.

I finally managed to figure this one out. The first 2 computers just didn't boot from USB. No hints. Nothing. Googling this problem brought up nothing. The solutions were to re-download Ubuntu, check your USB, use a CD, try on another computer, etc.

Fortunately, the 3rd computer I used gave me "Missing Operating System". Bingo! I found something searchable. This brought up a nice blog article. A solution! And it works! Basically, the problem was in the creation of the bootable USB. I was using Ubuntu's Startup Disk Creator. Apparently, it doesn't properly wipe out the USB and repartition appropriately. This caused havoc. The idea is to wipe out the USB stick and repartition before using Startup Disk Creator. This solved my problem.

Check out the solution here: http://ubuntuliving.blogspot.com/2008/11/missing-operating-system-step-by-step.html

Sunday, August 28, 2011

Rails 3.0: PostgreSQL

If you're starting fresh, getting a Rails application running on PostgreSQL can be rather involved.

Install PostgreSQL on Ubuntu.
sudo apt-get install postgresql libpq-dev pgadmin3 -y

Create a new Rails application with PostgreSQL.
rails new <project name> -d postgresql

If this is an old project, install the gem in Gemfile.
gem 'pg'

Create the PostgreSQL user. The username will be the same name as your project which can be found in config/database.yml.
sudo su postgres -c psql
# Enters the psql console.
create user "<username>" with [superuser] password "<password>";
# Outputs CREATE ROLE.
\q
The superuser keyword is optional but makes things easier in development.

If you get the error "FATAL: ident authentication failed", edit /etc/postgresql/8.4/main/pg_hba.conf.
local all all ident
to
local all all md5

Restart PostgreSQL.
sudo service postgresql restart

Create the development and test databases through the terminal.
createdb <project name>_development -U <username> -W
createdb <project name>_test -U <username> -W

References

http://olmonrails.wordpress.com/2008/08/12/switching-rails-to-postgresql/

Wednesday, July 13, 2011

Ubuntu 11.04: Redshift

Redshift is a program that changes the temperature of your monitor according to the time of day. It basically emulates sunset and encourages your body to sleep earlier. Something that I desperately need to do.

I recently upgraded to Ubuntu 11.04 Natty Narwhal, and was happy to find that Redshift had made it into the repositories! Unfortunately, after installing both the application and its GUI counterpart, it did not start.

I tried it in the terminal and to my dismay, I got the following:
> redshift
No clock applet was found.
Initialization of gnome-clock failed.
Trying next provider...
Latitude and longitude must be set.

So what's going on? Well, as of Ubuntu 11.04, Gnome is no longer the default. It's Unity. Hence, there is no gnome-clock.

Luckily, Ubuntu uses Redshift v1.6. In this version, a configuration file can be added! Just create the file ~/.config/redshift.conf with the following:
[redshift]
location-provider=manual

[manual]
lat=49.3
lon=123.06

After saving the file, you can now restart Redshift from the GUI.

Enjoy and sleep early!

Saturday, March 5, 2011

Rails 3.0: Installing Haml

Installing Haml is easy. Open up Gemfile.
gem 'haml'

Install.
bundle install

Now start naming your HTML files with a .haml extension, such as index.html.haml.

Cheat Sheet

Here's a quick cheat sheet to get you started.
#id
.class
%tag
%a{ :href => 'http://wesleymwwong.blogspot.com' }
/ HTML comment
= output
&= escaped output
!= not escaped output
- ruby
-# ruby comment
#{ inline ruby }
:javascript
!!! strict
!!! 5

References

Friday, February 4, 2011

Rails 3.0: Devise + Mongoid + RSpec

Devise removes the mundane job of writing all the code required to handle a user account. Plus, it supports Mongoid.

The following is a non-exhaustive list of tasks Devise takes care of for you:
  • signup
  • forgot/reset password (including emails)
  • confirmation emails
  • password encryption
  • login
  • logout
  • editing account info
  • locking accounts
  • session expiration

All this is available out of the box. Along with the goodies that are pre-packaged, Devise is fully customizable.

Installation

Open Gemfile
gem 'devise'

Install
bundle install
rails generate devise:install

You will need to setup your mailer if it isn't already setup. Devise depends on the default host being set, so ensure the following is set
# ... other mailer settings
config.action_mailer.default_url_options = { :host => 'localhost:3000' }

Don't worry! Devise is smart and has already detected that you are using Mongoid at this point and not ActiveRecord. It has also created config/initializers/devise.rb. This is where you can configure Devise. Take some time to familiarize yourself with all the options and uncomment any that you would like to use. I'll wait.

Test Helpers

If you are using RSpec, create spec/support/devise.rb with
RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
end

Now you have access to things like
sign_in @user
sign_out @user

Create a User model

It is time to create a User!
rails generate devise user

This generates a user model at app/models/user.rb with some Devise specific lines of code. Include the modules that you want and remove the ones you don't.

Believe it or not, Devise is now properly hooked up and ready!

Routes

Devise automagically generates all the user routes required for handling the user account. If you look in config/routes.rb, you'll notice
devise_for :users

To see all the routes
rake routes

You will notice a bunch of user routes. Fire up your server and navigate to localhost:3000/users/sign_up. Voila!

As a quick reference, here are some useful routes:
  • signup: new_user_registration_url
  • edit account: edit_user_registration_url
  • login: new_user_session_url
  • logout: destroy_new_user_session_url

References

I encourage you to take a look at the Devise home page as there is a wealth of information there.

https://github.com/plataformatec/devise

Monday, October 25, 2010

Rails 3.0: MongoDB + Mongoid

Why Mongoid?

The de facto ORM for MongoDB in Rails is Mongo Mapper, so why choose Mongoid? You can ready why straight from the horses mouth here.

To summarize, Mongoid is built for Rails 3.0 and it handles larger documents better. It also feels like NoSQL when you use it. MongoMapper was built during Rails 2.x days and when MongoDB was young. It is modeled very closely to ActiveRecord to make the transition easier. Hence, it feels more like SQL. MongoMapper is more extensible though with a larger community.

MongoDB

Grab the latest build from MongoDB's download page. At this time, it is 1.6.3.

Download and install. We make a softlink. This way, if we upgrade, we just switch the softlink and everything else stays the same.
cd /usr/local/src/
sudo wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.3.tgz
sudo tar xzf mongodb-linux-i686-1.6.3.tgz
sudo rm -rf mongodb-linux-i686-1.6.3.tgz
sudo ln -s mongodb-linux-i686-1.6.3 mongodb

Add /usr/local/src/mongodb/bin to your path.
PATH=$PATH:/usr/local/src/mongodb/bin

Make /data/db and give ownership to your user. There are obviously several ways to do this, but this is the easiest.
sudo mkdir -p /data/db
sudo chown -R wesley:wesley /data

Start your engines!
mongod

Mongoid

This builds on top of my previous post on installing Rails 3.0 with BDD. This assumes that the Rails application was created without ActiveRecord using -O. Check out Rails 3.0 agnosticism for an explanation.

Add mongoid to Gemfile. bson_ext is installed for a speed boost.
gem 'mongoid', '2.0.0.rc.6'
gem 'bson_ext', '~>1.2'

Install mongoid.
bundle install
rails generate mongoid:config

Cucumber

Add a cucumber environment to mongoid.yml.
cucumber:
  <<: *defaults
  database: myproject_cucumber 

Cucumber makes use of Database Cleaner. There are posts saying Database Cleaner doesn't work with Mongoid. However, it seems like it is now according to the official documentation. We need to modify features/support/env.rb this is not recommended as it is regenerated on a cucumber-rails upgrade. Instead, we will create features/support/local_env.rb.
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
Before { DatabaseCleaner.clean }

RSpec 2

RSpec includes ActiveRecord specific lines in spec/spec_helper.rb. You need to comment out the following 2 lines.
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
# config.use_transactional_fixtures = true

To properly clean the database, RSpec needs to know how to do that with Mongoid. Again, we can use Database Cleaner for this.

Open up spec/spec_helper.rb and add the following in the RSpec.configure block
RSpec.configure do |config|    
  # Other things

  # Clean up the database      
  require 'database_cleaner'   
  config.before(:suite) do     
    DatabaseCleaner.strategy = :truncation
    DatabaseCleaner.orm = "mongoid" 
  end

  config.before(:each) do
    DatabaseCleaner.clean      
  end
end 

References


Updates

December 2, 2010: Changed Cucumber local_env.rb for database cleaning.
December 2, 2010: Added a section for RSpec database cleaning.
February 1, 2011: Updated Mongoid version in the Gemfile
February 26, 2011: Added a note to clean out ActiveRecord specific lines in RSpec.

Tuesday, October 19, 2010

Rails 3.0: Installing Cucumber + RSpec 2 + Capybara + AutoTest

Behaviour Driven Development (BDD) was created in response to Test Driven Development (TDD). TDD had brought the idea of testing to the forefront, but stopped short when it was applied mainly to developers. It failed to include other stakeholders. BDD is suppose to remedy this by specifying the behaviour of the application at a high level in English. This allows non-developers to spec out the application and be included in the conversation.

Cucumber

Cucumber is a BDD framework for Ruby. Specs will be written at this higher layer first to drive behaviour.

RSpec 2

RSpec 2 just came out of beta. It is a TDD framework for Ruby. Specs will be written at this second layer for testing the details of the implementation.

Capybara

Capybara is a replacement for Webrat. It is used to simulate how a real world user would interact with your application. A good post about why you would use Capybara over Webrat can be found here.

AutoTest

AutoTest runs your Cucumber and RSpec specs automatically whenever a file that affects the specs is modified.

Install

This builds on top of my previous post on installing Rails 3.0. This assumes that the Rails application was created without Test::Unit using -T. Check out Rails 3.0 agnosticism for an explanation.

Open Gemfile and add the following.
group :development, :test do
  gem 'capybara'
  gem 'database_cleaner'
  gem 'cucumber-rails'
  gem 'cucumber'
  gem 'rspec-rails'
  gem 'autotest'
  gem 'spork'
  gem 'launchy'
end

Install the gems. If you aren't using ActiveRecord, you won't have a database.yml. cucumber:install will complain unless you pass -D to it.
bundle install
rails generate rspec:install
rails generate cucumber:install --rspec --cabybara

AutoTest checks your entire project for changes. When tests fail, test.log is written to and because there is a change, AutoTest will kick-off again, and again, and again. To stop this from happening, create a .autotest at the root of your project to ignore certain files.
Autotest.add_hook :initialize do |at|                                                                                                                                                                          
  %w{ .git doc log tmp vendor }.each { |ex| at.add_exception( ex ) } 
end

AutoTest does not run Cucumber out of the box. There is debate whether autotesting Cucumber is a good idea since it is a very high-level test and can be quite heavy. Autotests should run quickly. If you want autotesting of Cucumber, you must add AUTOFEATURE to your environment before running or in your .bashrc.
export AUTOFEATURE=true

Start continuous testing. Hit ctrl+c twice to stop.
autotest

References


Updates

Feb. 8, 2011: Added solution to AutoTest continuously running on failure.

Monday, October 18, 2010

Rails 3.0: Agnosticism

When Rails and Merb merged, agnosticism was one of the big features to be added to Rails. They have stayed true to this vision.

Take a look at the help when creating a new Rails application.
rails new --help

You will notice three options.
  • -O: Skip Active Record
  • -T: Skip Test::Unit
  • -J: Skip Prototype

This allows you to create a fresh Rails application and have it ready to integrate with other gems more easily.
rails new myproject -OTJ

Monday, October 11, 2010

Rails 3.0: Installing with RVM + Thin

To keep things clean, we will use RVM's gemsets to install Rails 3.0. This will keep your work environment clean and allow you to switch between projects without worry which Ruby version or gems are installed.

Setup

I rarely look at the local documentations of gems, so let's not download them.
Create ~/.gemrc and add the following to it.
gem: --no-ri --no-rdoc

Install Ruby 1.9.2 and create a gemset for your project.
rvm install 1.9.2
rvm gemset create myproject 

Rails 3.0

When using a gemset, all gems installed will be bundled under that gemset. Therefore, you can have a gemset per project without worry about cross-contamination!

Use your gemset to install Rails 3.0. We will also need to install Bundler.
rvm use 1.9.2@myproject
gem install bundler
gem install rails
rails new myproject
cd myproject

Create .rvmrc in the root of your project and add the following to it.
rvm use 1.9.2@myproject
This tells RVM to switch to the project's Ruby version and gemset whenever you enter the project.

Give it permission.
cd ..
cd myproject
This will prompt you to trust the .rvmrc. Type 'y' and hit enter. It will automatically switch to 1.9.2@myproject now when going to the project.

Install the required Rails 3.0 gems. If you don't want sqlite, go into Gemfile and remove sqlite3-ruby and use your favourite database. I will be using MongoDB in a later post.
bundle install

Thin

WEBrick is slow. Let's install Thin.

Open up Gemfile and add thin.
gem 'thin'

Install thin.
bundle install

Start

Drum roll please!
rails server thin

Now visit http://localhost:3000/