Friday 26 August 2011

Just discovered SVN switch command - switch to a different branch instead of doing a full checkout

I've been doing complete checkouts whenever our branches get renamed,
instead of using "svn switch". Not a small pain considering it takes 8
minutes to do a full checkout. Good thing this doesn't happen that
often (and probably the reason I haven't discovered the command. not
painful enough). How embarrassing!


Quick example of using SVN's "switch" command

$ cd calc

$ svn info | grep URL
URL: http://svn.example.com/repos/calc/trunk

$ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
U integer.c
U button.c
U Makefile
Updated to revision 341.

$ svn info | grep URL
URL: http://svn.example.com/repos/calc/branches/my-calc-branch

Only fewer files need to be updated. More time to read Hacker News. =)

REF: http://www.linxit.de/svnbook/en/1.1/ch04s05.html

Changes to Macbook Pro - installing Homebrew, RVM, Ruby 1.9.2, Rails, MySQL

I've been meaning to try out Rails 3.0 for a while, and finally got
around to installing it, but I wanted to use Homebrew for managing
packages and RVM so I could easily make use of multiple versions of
Ruby, since Snow Leopard default is Ruby 1.8.7

Every now and then I still have nightmares of what I went through with
getting Ruby to work on Tiger on my Powerbook. I didn't need to do as
much Googling this time around and getting into various dead-ends. And
with the i7 CPU compilation is way quicker than before. =)


1. Installed Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

2. Install Git and Wget

brew install git

brew install wget

3. Installed RVM

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

reloaded .bash_profile:

> source .bash_profile

4. Check that RVM is running

rvm notes

5. Install Ruby 1.9.2

rvm install 1.9.2

6. Install Rails

gem install rails

7. brew install mysql

(during make CPU usage goes way up to 80% and the fan kicks in for the
first time i've seen)

Wednesday 24 August 2011

How to do a git clone through a NTLM proxy

I've already set up CTNLM - http://cntlm.sourceforge.net/ - and have
already used it with Ruby gems yesterday, so I definitely know it's
working. We now have to configure GIT so it uses this proxy (running
on localhost:3128 by default)

>git config --global http.proxy localhost:3128

I've been looking at how to use workflows in Ruby on Rails recently,
and came across this project:

http://openwferu.rubyforge.org/

And the install instructions are here:
http://openwferu.rubyforge.org/quickstart.html

But looks like the GIT protocol can't be used through our proxy,
because if we try it we get this:

>git clone git://github.com/jmettraux/ruote.git
Cloning into ruote...
fatal: Unable to look up github.com (port 9418) (No such host is known. )


So replace git:// with http:// and see if we can do a git clone

>git clone http://github.com/jmettraux/ruote.git
Cloning into ruote...
remote: Counting objects: 22048, done.
remote: Compressing objects: 100% (5796/5796), done.
remote: Total 22048 (delta 16305), reused 21864 (delta 16134)Receiving objects:

Receiving objects: 100% (22048/22048), 4.04 MiB | 304 KiB/s, done.
Resolving deltas: 100% (16305/16305), done.


Yay, it works!!

Tuesday 23 August 2011

Ruby gems error: "Could not find a valid gem 'sqlite3' Possible alternatives: sqlite3" WTH?? Gems could be having network issues.

Installed rails and trying to get a test project running:

Created a new project and tried to get it running:

D:\Development\testrails>rails server

Error was:

D:\Development\testrails>rails server
←[31mCould not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in you
r Gemfile.←[0m
←[33mRun `bundle install` to install missing gems.←[0m

Now trying to install sqlite3, based on advise here:

http://ezruby.com/2011/07/how-to-install-ruby-on-rails-on-windows/

But I got:

D:\Development\testrails>gem install sqlite3
ERROR: Could not find a valid gem 'sqlite3' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3


And trying 'sqlite3-ruby' doesn't work either:

D:\Development\testrails>gem install sqlite3-ruby
ERROR: Could not find a valid gem 'sqlite3-ruby' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3-ruby

I came across this:

http://accidentaltechnologist.com/ruby-on-rails/running-rails-3-on-windows/

which advised to download sqlite3 for Windows and copy the file
sqlite3.dll into the directory [RUBY_INSTALL]\bin

No dice, still getting the same error

I also copied the file sqlite3.def to the same location - still
failing! Could it be because my version of sqlite is too new (current
one I downloaded is 3.7.7.1)

Then I realised that I forgot to use the proxy settings. At work, we
go through a Windows proxy, and to get Ruby gems to work, I had to
install CTNLM - which requires username and password - and then
access the proxy like this:

gem install --http-proxy http://localhost:3128 rails

Now it works!!


D:\Development\testrails>gem install --http-proxy http://localhost:3128 sqlite3-
ruby
Fetching: sqlite3-1.3.4-x86-mingw32.gem (100%)
Fetching: sqlite3-ruby-1.3.3.gem (100%)

#######################################################

Hello! The sqlite3-ruby gem has changed it's name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.

Thanks from the Ruby sqlite3 team!

<3 <3 <3 <3

#######################################################

Successfully installed sqlite3-1.3.4-x86-mingw32
Successfully installed sqlite3-ruby-1.3.3
2 gems installed
Installing ri documentation for sqlite3-1.3.4-x86-mingw32...
Installing ri documentation for sqlite3-ruby-1.3.3...
Installing RDoc documentation for sqlite3-1.3.4-x86-mingw32...
Installing RDoc documentation for sqlite3-ruby-1.3.3...

And Rails works now:

D:\Development\testrails>rails server
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-08-23 16:27:11] INFO WEBrick 1.3.1
[2011-08-23 16:27:11] INFO ruby 1.9.2 (2011-02-18) [i386-mingw32]
[2011-08-23 16:27:11] INFO WEBrick::HTTPServer#start: pid=4908 port=3000


D:\Development\testrails>


So the lesson here is:

When you see a nonsensical error like this

ERROR: Could not find a valid gem 'sqlite3' (>= 0) in any repository
ERROR: Possible alternatives: sqlite3

It could mean that Ruby gems is having network problems, and can't
access *any* repository.


REFS:

http://ezruby.com/2011/07/how-to-install-ruby-on-rails-on-windows/
http://stackoverflow.com/questions/4418/how-do-i-update-ruby-gems-from-behind-a-proxy-isa-ntlm
http://cntlm.sourceforge.net/
http://accidentaltechnologist.com/ruby-on-rails/running-rails-3-on-windows/