Making my own LikeaLittle, but better

Step 1: Make plans to do other things so this feels urgent
Step 2: Make a turkey pie
Step 3: Stare at likealittle and come up with a database schema
Step 4: Make the db schema in a rails app
Step 5: Write some controllers and some simple views
Step 6: HTML stylin’
Step 7: Add stuff.

Go!

Edit: Just gonna add my progress as I do it.

1 and 2: Done!
3: I think I need a status message and a category, and maybe users as well. A user will have many statuses, many “interests” (more on that later), a password, and a name. A status will have content, a date/time, a category, and a few extra fields. A category will have a type, “this class…”, “You’re a…”, “#fml”, and “STUPID PEOPLE” – maybe I’ll add more. Just those for now. They’ll dictate which fields are used by the status, things like “subject” and “number” for the class, “hair colour” and “sex” for You’re a, and so on. People can post fmls relevant to a campus, STUPID PEOPLE complaints about the idiots they ran into – kind of like an angry missed connections, ‘you’re a’ will be everything that likealittle is, only give a few extra-ish options, maybe? And “This class” can be for anything – complaining about a prof, discussing study plans, or just venting.

Now I’ve got to remember how to / find out how to make this in my db! I’ll do that shortly — going for a walk with a friend and buying some christmas gifts.

— upon return: An unfortunate twist of events! It turns out that I am sick. Hopefully just a short cold and these aches and soreness will retreat. Sad day.

What just happened and what’s up next

Friday: Exam invigilation and Tron; exams officially ended.
Saturday: Migrated the blog/site from home server to Linode box
Sunday: Reformatted home box and installed Rails properly.
Monday: Tons of Rails tutoriallage.
Tuesday (today): I’m going to build Likealittle. Better.
Wednesday: Gonna make a Tile Engine in OpenGL, and head home to see family
Thursday: Use / Extend the tile engine, make a simple game-thinger. Maybe a platformer? Visit an old friend, too.
Friday: More OpenGL, I’d imagine, and some Christmas prep.
Saturday: Christmas woooo (and… chrono trigger?)
Sunday: Learn You A Haskell For Great Good
Monday: Probably still Haskell
Tuesday: Going to build something fantastic with Haskell. Who knows what!
Wednesday: Beginning Android Development again. Gonna get a demo 3D program running.
Thursday: Going to write a simple tile-engine based off of my OpenGL one.
Friday: Make it into a game. It doesn’t have to be good, just has to /be/. Also, visiting with more friends! New Years and a birthday party.
Saturday: Relax with friends.
Sunday: Travel home, review my progress, and decide how to proceed for the remaining week or so of holiday.

Good luck, me. Remember that, throughout that, you are to be reading your book and learning math. You’re only doing easy mechanical stuff; just keep it up.

From Zero to Rails: Clean Maverick Meerkat install to working Rails app – Part 2

Last time (and by last time, I mean earlier this evening), I wrote out a skeletal plan for how to install ruby and rails properly on a fresh 10.10 machine. I hadn’t yet tried the instructions, only gathered them from various blogs and searches – here is, step by step, the results of applying the instructions I wrote down earlier. I’ve taken the philosophy that seeing the actual content from the terminal is generally useful, so it’s all here, with explanations when things have gone wrong. The idea is that, next time I do this, I’ll know what the hell is going on.

Step 1:

wcarss@quark:~$ sudo apt-get install curl git-core
[sudo] password for wcarss:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  git libcurl3 libdigest-sha1-perl liberror-perl
Suggested packages:
  git-doc git-arch git-cvs git-svn git-email git-daemon-run git-gui gitk
  gitweb
The following NEW packages will be installed:
  curl git git-core libcurl3 libdigest-sha1-perl liberror-perl
0 upgraded, 6 newly installed, 0 to remove and 3 not upgraded.
Need to get 6,856kB of archives.
After this operation, 14.2MB of additional disk space will be used.
Do you want to continue [Y/n]?

That went well!
Step 2:

wcarss@quark:~$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   986  100   986    0     0   2199      0 --:--:-- --:--:-- --:--:--  7825
Initialized empty Git repository in /home/wcarss/.rvm/src/rvm/.git/
remote: Counting objects: 16345, done.
remote: Compressing objects: 100% (4267/4267), done.
remote: Total 16345 (delta 11025), reused 15855 (delta 10649)
Receiving objects: 100% (16345/16345), 2.92 MiB | 2.02 MiB/s, done.
Resolving deltas: 100% (11025/11025), done.

  RVM:  Shell scripts enabling management of multiple ruby environments.
  RTFM: http://rvm.beginrescueend.com/
  HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

Upgrading the RVM installation in /home/wcarss/.rvm/
    Correct permissions for base binaries in /home/wcarss/.rvm/bin...
    Copying manpages into place.

Upgrade Notes

  * rvm_trust_rvmrcs has been changed to rvm_trust_rvmrcs_flag for consistency
  * Ruby package dependency list for your OS is given by:
    rvm notes
  * If you encounter any issues with a ruby 'X' your best bet is to:
    rvm remove X ; rvm install X
  * If you wish to have the 'pretty colors' again, set in ~/.rvmrc:
    export rvm_pretty_print_flag=1
  * If you see the following error message: Unknown alias name: 'default'
    re-set your default ruby, this is due to a change in how default works.

WARNING: You have RUBYOPT set in your current environment.
This may cause rubies to not work as you expect them to as it is not supported
by all of them If errors show up, please try unsetting RUBYOPT first.

Upgrade of RVM in /home/wcarss/.rvm/ is complete.

wcarss,

Thank you very much for using RVM! I sincerely hope that RVM helps to
make your work both easier and more enjoyable.

If you have any questions, issues and/or ideas for improvement please
join#rvm on irc.freenode.net and let me know, note you must register
(http://bit.ly/5mGjlm) and identify (/msg nickserv  ) to
talk, this prevents spambots from ruining our day.

My irc nickname is 'wayneeseguin' and I hang out in #rvm typically

  ~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT

If I do not respond right away, please hang around after asking your
question, I will respond as soon as I am back.  It is best to talk in
#rvm itself as then other users can help out should I be offline.

Be sure to get head often as rvm development happens fast,
you can do this by running 'rvm get head' followed by 'rvm reload'
or opening a new shell

  w⦿â¿â¦¿t

    ~ Wayne

wcarss@quark:~$

hmmm, I’ve got a warning now that I have the environment variable RUBYOPT set; it’s set to “rubygems”, and the rvm docs recommended that I unset it. I’m going to proceed without doing so, and hopefully things are fine.

Step 3:

vim .bashrc

huh, it already has [[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm” in it! This is pretty strange; but I’m happy. I also (fortunately) don’t have any return statements floating in my .bashrc, so I’m going to proceed to the next step.

Edit: Here is where I must insert this. It’s a week later, about 3 AM on the day after boxing day. I’ve just been trying to use heroku, and it turns out I was lacking several things in ruby because of some small errors I made at this step. I’ve had to uninstall ruby 1.9.2, install some libs and packages, and now I’m able to reinstall 1.9.2 and proceed. The following line of sudo apt-getting is not enough; in the ‘rvm notes’ above, they listed a bunch of things to install. I would suggest that you just do as they say, exactly. Install or update all of those packages, and that should be your step 4. Then, most of the craziness I deal with later on won’t happen to you. Good luck.

Step 4:

wcarss@quark:~$ sudo apt-get install libruby1.8 zlib1g-dev libssl-dev libreadline5-dev build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version.
The following extra packages will be installed:
  libncurses5-dev libreadline5
The following NEW packages will be installed:
  libncurses5-dev libreadline5 libreadline5-dev libruby1.8 libssl-dev zlib1g-dev
0 upgraded, 6 newly installed, 0 to remove and 3 not upgraded.
Need to get 6,170kB of archives.
After this operation, 23.5MB of additional disk space will be used.
Do you want to continue [Y/n]?

Went well!

Step 5:

wcarss@quark:~$ rvm install ruby-1.9.2

A RVM version 1.1.6 is installed yet 1.0.14 is loaded.
 Please do one of the following:
  * 'rvm reload'
  * open a new shell
  * source your shell init scriptswcarss@quark:~$

Whoops! I was supposed to run ‘source ~/.bashrc’ first – let’s do that.

Step 5 (fo realz):

wcarss@quark:~$ source ~/.bashrc
wcarss@quark:~$

No output: means all is well!

Step 6:

wcarss@quark:~$ rvm install ruby-1.9.2

A RVM version 1.1.6 is installed yet 1.0.14 is loaded.
 Please do one of the following:
  * 'rvm reload'
  * open a new shell
  * source your shell init scriptswcarss@quark:~$

Huh. I’ll try ‘rvm reload’, and if that doesn’t work, I’ll log out and back in.

Step 6 Redux:

wcarss@quark:~$ rvm reload
wcarss@quark:~$ rvm install ruby-1.9.2
/home/wcarss/.rvm/rubies/ruby-1.9.2-p0, this may take a while depending on your cpu(s)...

ruby-1.9.2-p0 - #fetching
ruby-1.9.2-p0 - #extracted to /home/wcarss/.rvm/src/ruby-1.9.2-p0 (already extracted)
ruby-1.9.2-p0 - #configuring
ruby-1.9.2-p0 - #compiling
ruby-1.9.2-p0 - #installing
ruby-1.9.2-p0 - updating #rubygems for /home/wcarss/.rvm/gems/ruby-1.9.2-p0@global
Error running '/home/wcarss/.rvm/rubies/ruby-1.9.2-p0/bin/gem update --system', please read 

/home/wcarss/.rvm/log/ruby-1.9.2-p0/rubygems.update.log
ruby-1.9.2-p0 - updating #rubygems for /home/wcarss/.rvm/gems/ruby-1.9.2-p0
Error running '/home/wcarss/.rvm/rubies/ruby-1.9.2-p0/bin/gem update --system', please read 

/home/wcarss/.rvm/log/ruby-1.9.2-p0/rubygems.update.log
ruby-1.9.2-p0 - adjusting #shebangs for (gem).
ruby-1.9.2-p0 - #importing default gemsets (/home/wcarss/.rvm/gemsets/)
Install of ruby-1.9.2-p0 - #complete
wcarss@quark:~$

Woohoo! ‘rvm reload’ did the charm. This process took about 4-5 minutes on my 6-7 year old 2GHz AMD64. Next up: 1.8.7.
Editor’s note: I didn’t notice the errors the first time I went through this; some of the problems I’ve got a bit later might have been detectable here.

Step 7:

wcarss@quark:~$ rvm install ruby-1.8.7
/home/wcarss/.rvm/rubies/ruby-1.8.7-p302, this may take a while depending on your cpu(s)...

ruby-1.8.7-p302 - #fetching
ruby-1.8.7-p302 - #downloading ruby-1.8.7-p302, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 4086k  100 4086k    0     0   282k      0  0:00:14  0:00:14 --:--:--  428k
ruby-1.8.7-p302 - #extracting ruby-1.8.7-p302 to /home/wcarss/.rvm/src/ruby-1.8.7-p302
ruby-1.8.7-p302 - #extracted to /home/wcarss/.rvm/src/ruby-1.8.7-p302
ruby-1.8.7-p302 - #configuring
ruby-1.8.7-p302 - #compiling
ruby-1.8.7-p302 - #installing
ruby-1.8.7-p302 - #rubygems installing to ruby-1.8.7-p302
Retrieving rubygems-1.3.7
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  284k  100  284k    0     0   217k      0  0:00:01  0:00:01 --:--:--  251k
Extracting rubygems-1.3.7 ...
ruby-1.8.7-p302 - adjusting #shebangs for (gem).
ruby-1.8.7-p302 - #importing default gemsets (/home/wcarss/.rvm/gemsets/)
Install of ruby-1.8.7-p302 - #complete
wcarss@quark:~$

Wicked! Again, a bit over 5 minutes on my aging box. This is working well so far — *knocks on wood* — gonna set 1.9.2 to default:

Step 8:

wcarss@quark:~$ rvm use ruby-1.9.2 --default
Using /home/wcarss/.rvm/gems/ruby-1.9.2-p0
wcarss@quark:~$ 

Easy!

Step 9:

wcarss@quark:~$ sudo apt-get install sqlite3 libsqlite-dev sqlite-doc sqlite3-doc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libsqlite0-dev' instead of 'libsqlite-dev'
The following extra packages will be installed:
  libsqlite0 libsqlite0-dev sqlite
The following NEW packages will be installed:
  libsqlite0 libsqlite0-dev sqlite sqlite-doc sqlite3 sqlite3-doc
0 upgraded, 6 newly installed, 0 to remove and 3 not upgraded.
Need to get 3,248kB of archives.
After this operation, 10.9MB of additional disk space will be used.
Do you want to continue [Y/n]?

I added a few suggested doc packages. Here comes the scary part.. adding gems.

Step 10:

wcarss@quark:~$ gem install sqlite3-ruby
/home/wcarss/.rvm/rubies/ruby-1.9.2-p0/bin/gem:4: warning: Insecure world writable dir /home/wcarss in 
PATH, mode 040733
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

Ah, no! This is exactly the kind of crazy bullshit I feared. I’ll turn to the RVM documentation, they suggested tryinh (the risque) ‘rvm get head’

wcarss@quark:~$ rvm get head

Original installed RVM version:

rvm 1.1.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]

From http://github.com/wayneeseguin/rvm
 * branch            master     -> FETCH_HEAD
Already up-to-date.

  RVM:  Shell scripts enabling management of multiple ruby environments.
  RTFM: http://rvm.beginrescueend.com/
  HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

Upgrading the RVM installation in /home/wcarss/.rvm/
    Correct permissions for base binaries in /home/wcarss/.rvm/bin...
    Copying manpages into place.


Upgrade Notes

  * rvm_trust_rvmrcs has been changed to rvm_trust_rvmrcs_flag for consistency

  * Ruby package dependency list for your OS is given by:
    rvm notes

  * If you encounter any issues with a ruby 'X' your best bet is to:
    rvm remove X ; rvm install X

  * If you wish to have the 'pretty colors' again, set in ~/.rvmrc:
    export rvm_pretty_print_flag=1

  * If you see the following error message: Unknown alias name: 'default'
    re-set your default ruby, this is due to a change in how default works.


WARNING: You have RUBYOPT set in your current environment.
This may cause rubies to not work as you expect them to as it is not supported
by all of them If errors show up, please try unsetting RUBYOPT first.

Upgrade of RVM in /home/wcarss/.rvm/ is complete.

wcarss,

Thank you very much for using RVM! I sincerely hope that RVM helps to
make your work both easier and more enjoyable.

If you have any questions, issues and/or ideas for improvement please
join#rvm on irc.freenode.net and let me know, note you must register
(http://bit.ly/5mGjlm) and identify (/msg nickserv  ) to
talk, this prevents spambots from ruining our day.

My irc nickname is 'wayneeseguin' and I hang out in #rvm typically

  ~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT

If I do not respond right away, please hang around after asking your
question, I will respond as soon as I am back.  It is best to talk in
#rvm itself as then other users can help out should I be offline.

Be sure to get head often as rvm development happens fast,
you can do this by running 'rvm get head' followed by 'rvm reload'
or opening a new shell

  w⦿â¿â¦¿t

    ~ Wayne

Installed RVM HEAD version:

rvm 1.1.6 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
wcarss@quark:~$

Hmm, doesn’t seem to have done anything. But in there, it says “If you wish to install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head), then you must install and use rvm 1.8.7 first.” — so maybe we need to switch to 1.8.7 as default, run ‘rvm get head’ there, gem install something, and then we can make 1.9.2 work? We’ll give that a try if nothing super-promising comes out of a google search. Didn’t work. Googling “ruby-1.9.2-p0/bin/gem:4: warning: Insecure world writable dir”

*time passes*

Holy crap; it’s been a few hours but I’ve finally got the gorram thing. So, what’s wrong? Actually, two things. First off, let’s fix the ‘insecure directory’ thing. First was that my home directory, /home/wcarss, is world-writable! That’s pretty scary. So I called

chmod go-w /home/wcarss

— this leaves the u (for user, being the owner) setting of the directory with write access, and it removes write access for members of the same groups as me, and for assorted “other” users as well. ‘gem -v’ now just returns ‘1.3.7’ instead of

/home/wcarss/.rvm/rubies/ruby-1.8.7-p302/bin/gem:4: warning: Insecure world writable dir /home/wcarss in 
PATH, mode 040733
1.3.7

Next up: problem 2. This one baffled me a bit longer. The problem arises when calling

gem install sqlite3-ruby

First, let’s clarify that we /do not/ want to use sudo for these gem installs. That isn’t the problem. Second, let’s clarify that whatever we’ve got set as the ‘default ruby’ is what version of gem we’re using — so for me, it’s 1.9.2 right now. While attempting to fix this problem, I switched to 1.8.7 for a while and the command worked well enough there. In 1.9.2 though, the problem persisted. You can specify a particular version to run by saying ‘rvm version command’, so, ‘rvm 1.9.2 gem -v’ will only call the 1.9.2 gem, even if you have 1.8.7 set as your default for the moment. Calling this without the version parameter, like so: ‘rvm gem -v’ will call gem for all installed versions, for me that’s both 1.8.7 and 1.9.2, in order.

Okay, lots of text there, so what in sam hill is wrong?

RVM grabs a source repo of ruby and then compiles it. So, I found a solution early on that matched my problem in a rough sense. It’s a fantastic collection of common ruby install issues and their fixes. It suggested that, if I’d built ruby from source, I should go and make/make install zlib. But to my naive mind, RVM wasn’t the same as installing by source.

Turns out, RVM does build from source, so it’s susceptible to the same issues. The fix to this stage of the problem, that will remove this:

ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

is to do:

cd ~/.rvm/src:
sudo apt-get install zlib1g-dev
cd ext/zlib
ruby extconf.rb
make
sudo make install

It worked as expected! I already had zlib1g-dev, the ruby script ran fine and generated a make file, the make file took about 15 seconds to compile the code, and sudo make install did a quick copy. Then I tried it again:

wcarss@quark:~$ gem install sqlite3-ruby
Building native extensions.  This could take a while...
Successfully installed sqlite3-ruby-1.3.2
1 gem installed
Installing ri documentation for sqlite3-ruby-1.3.2...
Installing RDoc documentation for sqlite3-ruby-1.3.2...
wcarss@quark:~$

Huzzah! Finally, we can move on and try installing rails itself — it has a bunch of dependencies that it installs alongside it, so this is where, if something goes wrong, it’s some distant, barely required gem whose documentation will go insane and cause the install process to fail, borking up the whole environment. But here’s hoping it works okay:

Step 11:

wcarss@quark:~$ gem install rails
Successfully installed activesupport-3.0.3
Successfully installed builder-2.1.2
Successfully installed i18n-0.5.0
Successfully installed activemodel-3.0.3
Successfully installed rack-1.2.1
Successfully installed rack-test-0.5.6
Successfully installed rack-mount-0.6.13
Successfully installed tzinfo-0.3.23
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.3
Successfully installed arel-2.0.6
Successfully installed activerecord-3.0.3
Successfully installed activeresource-3.0.3
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.1
Successfully installed treetop-1.4.9
Successfully installed mail-2.2.12
Successfully installed actionmailer-3.0.3
Successfully installed rake-0.8.7
Successfully installed thor-0.14.6
Successfully installed railties-3.0.3
Successfully installed bundler-1.0.7
Successfully installed rails-3.0.3
24 gems installed
Installing ri documentation for activesupport-3.0.3...
Installing ri documentation for builder-2.1.2...
Installing ri documentation for i18n-0.5.0...
Installing ri documentation for activemodel-3.0.3...
Installing ri documentation for rack-1.2.1...
Installing ri documentation for rack-test-0.5.6...
Installing ri documentation for rack-mount-0.6.13...
Installing ri documentation for tzinfo-0.3.23...
Installing ri documentation for abstract-1.0.0...
Installing ri documentation for erubis-2.6.6...
Installing ri documentation for actionpack-3.0.3...
Installing ri documentation for arel-2.0.6...
Installing ri documentation for activerecord-3.0.3...
Installing ri documentation for activeresource-3.0.3...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.1...
Installing ri documentation for treetop-1.4.9...
Installing ri documentation for mail-2.2.12...
Installing ri documentation for actionmailer-3.0.3...
Installing ri documentation for rake-0.8.7...
Installing ri documentation for thor-0.14.6...
Installing ri documentation for railties-3.0.3...
Installing ri documentation for bundler-1.0.7...
Installing ri documentation for rails-3.0.3...
Installing RDoc documentation for activesupport-3.0.3...
Installing RDoc documentation for builder-2.1.2...
Installing RDoc documentation for i18n-0.5.0...
Installing RDoc documentation for activemodel-3.0.3...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for rack-test-0.5.6...
Installing RDoc documentation for rack-mount-0.6.13...
Installing RDoc documentation for tzinfo-0.3.23...
Installing RDoc documentation for abstract-1.0.0...
Installing RDoc documentation for erubis-2.6.6...
Installing RDoc documentation for actionpack-3.0.3...
Installing RDoc documentation for arel-2.0.6...
Installing RDoc documentation for activerecord-3.0.3...
Installing RDoc documentation for activeresource-3.0.3...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.1...
Installing RDoc documentation for treetop-1.4.9...
Installing RDoc documentation for mail-2.2.12...
Installing RDoc documentation for actionmailer-3.0.3...
Installing RDoc documentation for rake-0.8.7...
Installing RDoc documentation for thor-0.14.6...
Installing RDoc documentation for railties-3.0.3...
Installing RDoc documentation for bundler-1.0.7...
Installing RDoc documentation for rails-3.0.3...

It went smoothly; I’m so proud! Next up, we’ll install mongrel…

Step 12:

wcarss@quark:~$ gem install mongrel
Building native extensions.  This could take a while...
Building native extensions.  This could take a while...
ERROR:  Error installing mongrel:
        ERROR: Failed to build gem native extension.

/home/wcarss/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile

make
gcc -I. -I/home/wcarss/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/x86_64-linux -
I/home/wcarss/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/home/wcarss/.rvm/rubies/ruby-
1.9.2-p0/include/ruby-1.9.1 -I.   -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -
Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long  -fPIC  -o http11.o -c http11.c
http11.c: In function âhttp_fieldâ:
http11.c:70: warning: format not a string literal and no format arguments
http11.c:71: warning: format not a string literal and no format arguments
http11.c:77: error: âstruct RStringâ has no member named âptrâ
http11.c:77: error: âstruct RStringâ has no member named âlenâ
http11.c: In function ârequest_uriâ:
http11.c:102: warning: format not a string literal and no format arguments
http11.c: In function âfragmentâ:
http11.c:113: warning: format not a string literal and no format arguments
http11.c: In function ârequest_pathâ:
http11.c:124: warning: format not a string literal and no format arguments
http11.c: In function âquery_stringâ:
http11.c:135: warning: format not a string literal and no format arguments
http11.c: In function âheader_doneâ:
http11.c:172: error: âstruct RStringâ has no member named âptrâ
http11.c:172: error: âstruct RStringâ has no member named âptrâ
http11.c:172: error: âstruct RStringâ has no member named âptrâ
http11.c:174: error: âstruct RStringâ has no member named âptrâ
http11.c:176: error: âstruct RStringâ has no member named âptrâ
http11.c:177: error: âstruct RStringâ has no member named âlenâ
http11.c: In function âHttpParser_executeâ:
http11.c:298: error: âstruct RStringâ has no member named âptrâ
http11.c:299: error: âstruct RStringâ has no member named âlenâ
http11.c:307: warning: format not a string literal and no format arguments
make: *** [http11.o] Error 1

Gem files will remain installed in /home/wcarss/.rvm/gems/ruby-1.9.2-p0/gems/mongrel-1.1.5 for inspection.
Results logged to /home/wcarss/.rvm/gems/ruby-1.9.2-p0/gems/mongrel-1.1.5/ext/http11/gem_make.out
wcarss@quark:~$

Nooooooo! All I wanted to do was install mongrel! Let’s figure out what’s going on here.

*time passes*

Haha, okay. So, it looks like someone upstream buggered mongrel up a bit and left a bunch of “RSTRING(data)->ptr” patterns around when they should have been written as “RSTRING_PTR(data)”. There’s also some malformed case statements. If you go into ~/.rvm/gems/ruby-1.9.2-p0/gems/mongrel-1.1.5/ext/http11, you’ll see our culprit, http11.c. A full explanation of the fix we want can be found here – with a few small edits.
I don’t think the sudo’s are a good idea for us; they’re just there in case you’re working in a system directory. Given that our whole install has proceeded through RVM, which should be inside of your home directory, we’re fine without it. I followed the form on ‘sudo make install’ though, as it feels like a good idea to install things as root. Beyond that, it seemed prudent to run ‘ruby setup.rb’ from within the mongrel-1.1.5 directory, just to make sure that things close off right. So, in succinct form (I’m overlapping with the website I linked here):

cd ~/.rvm/gems/ruby-1.9.2-p0/gems/mongrel-1.1.5/ext/http11
vim http11.c (generally, "RSTRING(data)->thing" becomes "RSTRING_THING(data)")
make the edits suggested at the other site
cd ../../lib/mongrel
vim handlers.rb
fix the case statements from 208-212 (replace ':' with 'then')
gem install gem_plugin (we're avoiding sudo)
cd ../../
ruby setup.rb

And you’re done. Now, let’s test this out. It’s been a bit over 4 hours since I started working on this, so… high hopes. 🙂

Step 13 (ominous!):

rails new example
cd example/
bundle install
rake db:create
rails s

‘new example’ makes a folder called ‘example’ for you, so don’t worry about polluting your space. ‘bundle install’ seems to.. do some kind of magic with gems? I’m not sure. And rake db:create told me that my database already exists:

wcarss@quark:~/code/ruby/testing/example$ rake db:create
(in /home/wcarss/code/ruby/testing/example)
db/test.sqlite3 already exists
db/development.sqlite3 already exists

then ‘rails s’ starts the server, we open up a new tab, and head to servername:3000:
Huzzah!

A bit over 4 hours. That’s a hell of a process to go through to get a thing running. I’m concerned that it might bork up magically in the next few months during an update (that’s what happened to my last one; ubuntu just *forgot* that ruby was installed somehow — it was fun), but at least it’s all under rvm now, and theoretically I can just remove and then reinstall a whole borked ruby environment. If things go too far astray, I can just delete all of rvm! This is the safest I’ve felt about these things in a while.
If something here worked very differently for you, or you’ve got comments, certainly let me know. I can’t promise I’ll be able to fix some problem you’re running across, but I’d like to think I’d give it a try. Thanks for reading; good luck.

From Zero to Rails: Clean Maverick Meerkat install to working Rails app – Part 1

I haven’t done it yet – let’s see how this goes. Writing/researching while watching Mythbusters.

I’ve never known Ubuntu and Ruby to play nicely out of the box. Especially not when you’re trying to get rails involved. Ubuntu’s repositories are known to rubyists not to be safe, sudo isn’t a good idea to use with gem, and the maze of dependency confusion between mysql, postgresql, sqlite3, apache2, rails2/3, and ruby1.8.6/7 and 1.9.1/2 is a novice’s (read: my) nightmare.. What I’ve read again and again is that I should use a tool called RVM to install ruby; so let’s try that.

It looks like (from various blogs and such) the way to install RVM is by running

sudo apt-get install curl git-core
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

then adding

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

to your .bashrc — right at the end is cool. It’s important to now note that you should check whether or not your .bashrc has a ‘return’ floating around anywhere. Very likely that it does. If you find one, follow the instructions in the ‘Troubleshooting’ section here. I’m expecting to have to do this. After you’ve checked (and maybe fixed) that hiccup, reloading your .bashrc and install the ruby stuff:

source ~/.bashrc
sudo apt-get install libruby1.8 zlib1g-dev libssl-dev libreadline5-dev build-essential
rvm install ruby-1.9.2
rvm install ruby-1.8.7
rvm use ruby-1.9.2 --default

lastly, we need to get rails going, so let’s do: (note that I’m not using sudo)

sudo apt-get install sqlite3 libsqlite3-dev
gem install sqlite3-ruby
gem install rails
gem install mongrel

Heh. I’ve got all the steps written out — now let’s try it and see how things go. Culminating steps will be:

rails new example
cd example/
bundle install
rake db:create
rails s

And check out localhost:3000 to see how she reports.

Okay! So, that’s a skeletal plan; next up is actually doing it. That will come in post 2, which I’ve just written!

Migrating wordpress and the server

I migrated the site to a different server earlier this evening; let’s recap. Things in ”s are commands to be run.

  1. Log into your new server
  2. ‘screen bash’ (in case your net drops)
  3. ‘scp -R existing_website_name:~/destinationfolder folder_to_be_copied’ (the new setup will be /home/yourname/destinationfolder/folder_to_be_copied)
  4. hit ‘CTRL-A d’ (detach screen)
  5. hang out on IRC while your data transfers, check in every once in a while
  6. Next up is backing up the existing database – ssh into your existing server, then dump your database using ‘mysqldump -h hostname -u username -p databasename | bzip2 -c > dump.bz2’
  7. exit ssh and ‘scp existing_website:~/path_to_dump/dump.bz2 dump.bz2’
  8. log into mysql, then create your wordpress db user and your wordpress db, and then grant necessary privileges
  9. log out of mysql, and extract your database dump, then restore it by calling ‘mysql -h hostname -u username -p databasename < dump'
  10. change your wordpress directory’s ownership to the user who runs the webserver – probably www-data, by using ‘chown -R www-data directory’
  11. test everything out, make sure your new site is operating the way you’d expect
  12. change over your zonefiles to update your DNS.

In the middle of this, I had some extra steps:

  1. Get frustrated that I don’t have ‘interactive autocomplete’ turned on. In order to make screen autocomplete when I type ‘screen -r’, I have to enable bash_completion. I just copied a friend’s .bashrc and .bash_profile to make this work — I love having smart friends. The relevant lines in each of them are:
  2. .bash_profile:

    # include .bashrc if it exists
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    fi

    .bashrc:

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
    fi
  3. screen -r <TAB> to reattach my last screen session

And it’s all working well!