Ruby On Rails
I was a little unfair to Ruby on Rails last week, so I decided to try installing it Sunday afternoon. This is my story.
Ruby
3:30 Sunday afternoon. Finally got my vpn working, so I can now send emails off my desktop at home. Look at my emails, decide I'm not up to it. Browse through the comments on the website. Remember Ruby on Rails. Maybe, I think, I should try working with Ruby before commenting on it.
So I search for Ruby on Rails on Google. Find the Ruby on Rails site, which has some basic info. Realize I'll probably need Ruby for Ruby on Rails to work. Nothing here on that. How about this article? Nope.
4:15. Maybe I already have Ruby. I open up the console application and try:
[stephen@localhost stephen]$ ruby bash: ruby: command not found
OK, maybe not. I try to 'locate' Ruby and find nothing.
OK, maybe on my website then. Since I have vpn working, I can access my website via ssh. Like this:
[root@localhost stephen]# ssh xxx@www.downes.ca Warning: Permanently added 'www.downes.ca,xx.xx.xx.xx' (RSA) to the list of known hosts. downess@www.downes.ca's password: Last login: Mon Oct 3 22:24:22 2005 from nrc.gc.ca [downess@downes ~]$ ruby -bash: ruby: command not found
Guess not.
So, back to Google, this time to search for Ruby itself. Maybe to find some way of knowing whether I even have it installed, maybe to get it if I don't.
I land at the Ruby home page. Big warning: Ruby vulnerability in the safe level settings. Great, that makes me feel at ease. OK, how about some instructions? I try the documentation and find nothing useful. Scroll down. Oh, isn't that lovely:
Keep scrolling. Scoll back up. Oh wait, a tiny little link at the top, Getting Stated With Ruby.
I look at the short list of items. Check the Ruby FAQ. Look at the General Questions. Still don't know whether I have Ruby. Back up. Open Why's (Poignant) Guide to Ruby and click Open the Book.
And am swept away. Not because the book tells me whether I have Ruby or how to install it, but by the most poetic programming guide I have ever read. Time passes as I read the first three chapters. It's basic 'How to program Ruby' stuff, familiar ground, since I read a similar guide a few months back.
This is what convinces me to actually try installing it:
require 'net/http'
Net::HTTP.start( 'www.ruby-lang.org', 80 ) do |http|
print( http.get( '/en/LICENSE.txt' ).body )
end
What does this do? It accesses a web page (http://www.ruby-lang.org/en/LICENSE.txt), downloads it, and print it to the screen. Beautiful.
4:35. But I'm getting nowhere. I back out, go back to the Ruby Home Pgae, look around again, and see, on the right, the Download Ruby link. OK. The stable release ruby-1.8.3. OK. See that the link is an archive (you can always tell, by the .tar.gz extension). Right-click and save it to my desktop.
4:45. Back into my console again. First, I extract the archive:
[stephen@localhost stephen]$ tar -xzf ruby-1.8.3.tar.gz
This empties the archive into a director called ruby-1.8.3. So I enter the directory:
cd ruby-1.8.3
and then type 'ls' to see what's in there. I type 'more README' to look at the help, and see it's a faily standard install. That means things are pretty standard from here on in.
I have to be a superuser to install ruby, so I type 'su' and then my password. Then I run the configure command:
[root@localhost stephen]# ./configure
My monitor spews output, but everything seems OK (you know it's not OK if you see a bunch of 'Error' messages). Now the software is configured for my won computer. Then I type:
[root@localhost stephen]# make
This will compile the raw code into executibles (basically creating the Linux equivalent of .exe files). Again, much more output.
How did I know to do all this? Well, it's in the README - but more often than not, it's undocumented. Bt this is pretty much the standard way to install software on Linux. So I would probably have been able to guess.
Finally:
[root@localhost stephen]# make install
This is the money shot. More text. Finally, it finishes and I try again:
[root@localhost ruby-1.8.3]# ruby
And... nothing.
I still don't know how to use Ruby. 5:10 p.m., time to go make supper.
5:15. Well, the water's boiling. Still nothing. I type ctl/c and break out of it.
OK. Ruby is a programming language. It probably needs a program to do anything. Back to the documentation. How about Programming Ruby? I need something simple, a 'Hello World' type program. That will tell me whether ruby is running.
Oh, heay, here's a section on downloading and installing Ruby. How about that. Now why isn't this info right on the front page of the Ruby site? I ask you!
Here we go: "The easiest way to run Ruby interactively is simply to type 'ruby' at the shell prompt." That's what I did. But there's more:
% ruby puts "Hello, world!" ^D Hello, world!
OK, let's try that.
OK, took a couple of tries. Note well: "Here we typed in the single puts expression and an end of file character (which is control-D on our system)." I had just thought the ^D was some sort of copying error. But once I figured out that, I was away to the races.
Now: "In the sample directory in the Ruby distribution you'll find a script named 'eval.rb'." OK... but now, ever better, here's the script for a basic Ruby program:
#!/usr/local/bin/ruby -w puts "Hello, World!"
Excellent. I open up kwrite (the Linux equivalent to Notepad), enter the text, and then save it as 'test.rb'. Then I give it permission to execute (on Linux, you aleays have to give programs permission to execute):
[stephen@localhost ruby-1.8.3]$ chmod 775 test.rb
OK, now I'll try running it.
[stephen@localhost ruby-1.8.3]$ ./test.rb Hello, World!
Perfect! It's 5:30 and Ruby is officially installed on my desktop. Now to put it on my web server. This time, I'll try the instructions from Programming Ruby.
[downess@downes ~]$ su [root@downes downess]# cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs bash: cvs: command not found
This is the thing with Linux. Nothing ever works the way it's documented. Probably, if I want this to work, I'm going to have to install some other package (specifically, cvs) which will let me do this.
I have a better idea. I'll simply open FTP and upload the archive of Ruby I already have on my desktop up to my web server. Just a moment then...
While the file was uploading I put the pasta (ravioli) into the boiling water and stirred it (always using a wooden spoon) while the sauce warmed up in the frying pan. Now I have a bowlful of steaming ravioli and am ready to install Ruby on my web server. It's 5:45.
OK, following the same steps as above, Ruby is now installed on my server. I still have half a bowl of ravioli. It's 5:52. I would have been faster, but I had to follow up an email from Doug kaye.
Now what? Well, let's see if my web server can run Ruby files. I'll make one just like I did before, but with one extra line:
#!/usr/local/bin/ruby -w puts "Content-type: text/html\n\n"; puts "Hello, World!"
The 'Content-type' line has to go at the top of any output from scripts on your webserver. Readers never see it, but the server and browser need to know you intend the output to be a web page. Anyhow, I change the name to testrb.cgi (because my server won't recognize a .rb file as something it has to execute - to fix that, I would have to change my server configuration - easier just to rename the file). I upload it to the cgi-bin directory on my server, chmod it as before, and...
It works! 6:00 p.m.
Ruby On Rails
Now I'm ready to try Ruby on Rails.
I go back to the Ruby on Rails site and click on the Download page. It says: "Rails is primarily distributed through RubyGems — the soon-to-be official packaging format for Ruby libs/apps" What the...?!?
See, what Ruby on Rails is, basically, is a framework. What that means is that it's a whole bunch of Ruby code that has already been written. You install the code, then you can write applications on top of it. That way, you don't have to worry about things like connecting to the database, accessing the web, and the like.
Well - once you've installed Ruby on Rails you don't have to worry about it.
OK, so here are the instructions:
- Get hold of RubyGems 0.8.10 (or higher)
- gem install rails --include-dependencies
- rails /complete/path/to/new/railsapp
By 'get hold of' I assume they mean 'download and install' (which makes me wonder, why didn't they say 'download and install'? Oh well. I click on the link (and have a second bowl of ravioli.
A whole list of files. OK, pick the top ones - they seem to be the most recent. .zip is probably a Windows archive, .tgz must be Linux (not sure exactly what .tgz is but it's probably like .tar.gz). What the heck is .tgz though?
I try:
[stephen@localhost stephen]$ tar -xvf rubygems-0.8.11.tgz tar: This does not look like a tar archive tar: Skipping to next header tar: Archive contains obsolescent base-64 headers tar: Error exit delayed from previous errors
Nope. How about:
[stephen@localhost stephen]$ gunzip rubygems-0.8.11.tgz [stephen@localhost stephen]$
That appears to have done nothing, but I type 'ls' to view my directory and see that the file is now called 'rubygems-0.8.11.tar'. Excellent. Now I simply type:
[stephen@localhost stephen]$ tar -xvf rubygems-0.8.11.tar
and I see the whole thing decompressing (and I realize I should have tried tar -xzf before... oh well).
6:28 and I can now 'cd rubygems-0.8.11' to enter the directory. Typical Linux. Takes 5 minutes to install a program, but half an hour to get to that point.
According to the README, I need now to run:
[stephen@localhost rubygems-0.8.11]$ ruby setup.rb
which I do. Permission denied. oops. I need to be root. OK, type 'su' then the password and try again. "Successfully built RubyGem." Excellent. Now to upload this to the server and do it again. Exactly the same process, and it works fine. 6:32.
OK, the next step:
[root@localhost rubygems-0.8.11]# gem install rails --include-dependencies
Should I have been in root? I don't know. Oh well, too late now. It takes some time to run - "Attempting local installation of 'rails'." Waiting. The word 'successfully' a half dozen times, 'Installing'...
6:45. That worked perfectly. So now to do it on the website.
Now for the third step:
rails /complete/path/to/new/railsapp
What the !?#@? This isn't an instruction. It's not... anything!
I go back to the documentation and find the Rolling With Ruby on Rails article again, skip over all the crap for Windows to the bottom of the page. It talks about installing MySQL - happily, I have MySQL installed already. Good thing - I can never remember how to restart it.
Next page. It says, "Open a command window and navigate to where you want to create this cookbook web application. I used c:\rails." More Windows crap.
OK. I'll try this directly on the web server, since I don't have MySQL running on my desktop. I'll create a directory called /rails in my web server root and go there. then I'll type the command and see what happens.
[downess@downes opt-httpd-prefork-htdocs]$ cd rails [downess@downes rails]$ rails cookbook /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/clean_logger.rb:13:in `remove_const': constant Logger::Format not defined (NameError)
and then a bunch of stuff after that. So what happened? Did it work? The text says "This will create a cookbook subdirectory containing a complete directory tree of folders and files for an empty Rails application."
So I look:
[downess@downes rails]$ ls [downess@downes rails]$
Nothing.
I guess I'm supposed to download the cookbook application. The article has it as a .zip file - I wonder whether I can extract it on Linux.
[root@localhost stephen]# unzip cookbook_part1_0.13.1.zip Archive: cookbook_part1_0.13.1.zip
Yes. Good. I'll upload it to the web server, then, into the rails directory. Then I'll try the rails command again:
[downess@downes rails]$ rails cookbook /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/clean_logger.rb:13:in `remove_const': constant Logger::Format not defined (NameError)
Well, that didn't work at all.
I'll try another guide. Let's try Four Days With Rails (and to think - I got a snarky comment when i suggested it might take more than a day). PDF, bleah. I open it up and read: "This example is on my MS-Windows PC. My web stuff is at c:\www\webroot, which I label as drive w: to cut down on typing."
Don't these people realize that most web servers out there run on Linux? Sheesh...
There's that same 'rails' command again. 'Rails ToDo'. It works about as well as 'rails cookbook', which is to say, not at all. Also, there's a bunch of stuff about configuing Apache for Rails. Hm. I try another guide. This one tells me to try 'rails AddressBook'. I get the idea. It still doesn't work.
But I'm not going anywhere until I get past this error.
I try a search in Google. Zero results. I mess around with the search parameters and finally land on this page. It says, "So it looks like Ruby 1.8.3 doesn't play well with Rails (trunk) giving the following error: ./script/../config/../vendor/rails/activesupport/lib/active_support/clean_logger.rb:13:in `remove_const': constant Logger::Format not defined (NameError?)"
Well, that's my error, all right. Now what? I look at the changelog...
# severity changed from normal to critical # priority changed from normal to highest
Sounds about right... I mean, it doesn't run otherwise. But what's this?
* resolution set to fixed * status changed from new to closed
Great. Now what? There is a 'patch' but it consists of about five lines of code to be inserted in some (undesignated) place (obviously the designers know where it goes, but I'm just some schmo trying to install Rails). Why the heck didn't they put the patch in the download? Sheesh.
Back to Google, and I find Ticket #2263 (reopened). Heh. I read:
"Unfortunately, the solution checked into Subversion doesn't work if you're running Ubuntu 5.10 (and I'm guessing Debian sarge) because they have a heavily patched 1.8.2 version of ruby (from CVS) that reports itself as 'ruby 1.8.3 (2005-06-23) [i486-linux]' but has the logger.rb from 1.8.2. Using Rails head, I get empty log lines now with Ubuntu 5.10. While I realize that it may not be really the job of RoR to deal with these patched version of Ruby..."
Well, it looks like it's a wider issue. Here's the proposed solution:
cd ../ruby-1.8.2 ./configure && make && make install
Sweet... if you have Ruby 1.8.2...
So it's back to the top. I'm going to have to install Rails 1.8.2 to make this work. It's now 7:25 p.m. and I'm back where I started.
Ruby (Again)
So I go back to the Ruby directory I installed and type 'make clean'. This removes all the junk from the install (I probably should have done it earlier, but I forgot) but doesn't uninstall Ruby.
Back to the Ruby download page. The only version available is 1.8.3. Hm. Try one of the mirrors? yes, here we go, the mirror at MIT has Ruby 1.8.2 available. Bonus - it's the first one I checked.
Download it, upload it to the web server (I skip doing this on the desktop for now). I delete some spam from my email while I wait. Configure. make. Make Install. make clean. It's a lot faster this time; I know what I'm doing. OK, all installed - do I need to reinstall gems and rails? Probably not... I go back to the Rails directory and try again:
[root@downes rails]# rails AddressBook create create app/apis create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create components [...] create public/images create public/javascripts create public/stylesheets create script [...] create README create script/generate create script/server [...]
Success! Some days I feel like a genius.
Ruby on Rails (Again)
OK, looking at the fastTrack guide I see that it says "The first thing you need to do for any application is create a database for its data to live in. Technically, this step need not occur first, but it needs to occur early; it should be obvious that you should create the database before any application code, even automatically generated code. So let's create a database in MySQL and craft a first table within this database."
So I do have an instance of MySQL running on my website, so I'll just swipe the FastTrack code and create the database. I copy the code below, open phpMyAdmin, create AddressBook as a new database, then run the following as SQL:
CREATE TABLE IF NOT EXISTS contacts (
id smallint(5) unsigned NOT NULL auto_increment,
name varchar(30) NOT NULL default '',
created_on timestamp(14) NOT NULL,
updated_on timestamp(14) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY name_key (name)
) TYPE=MyISAM COMMENT='List of Contacts';
And I note in the commentary: "Of central importance is that every table must have an id column with exactly that name. Rails uses the primary key column id for various recordkeeping and referencing tasks. The fields created_on and updated_on are not required, but if you do include them, Rails maintains them automatically "behind the scenes"; in most cases there is no harm in using these timestamps. So the only "real" data you have yet added is a name for your address book contacts." Also, "Table names should use the plural form."
See, the way a framework works is that things like the database are standardized. That way, the same function can be used on every table of every database.
OK, what next? I need to allow Rails to access my database. This step is pretty murky. here's what I read:
[~/Sites]$ cd AddressBook
[~/Sites/AddressBook]$ head -6 config/database.yml # after editing
development:
adapter: mysql
database: AddressBook
host: localhost
username: some_user
password: password_if_needed
That simply generated a bunch of errors. So I tried the first line:
[root@downes rails]# head -6 config/database.yml
That played back all the text above. OK, what I must need to do is to edit some file to my own database settings, then run the head command. I guess? I use vi and make the changes (you could use any text editor). Then I run the head command and see my changes.
Now I need to start the Rails server. Basically, Rails acts as its own web server, bypassing Apache. Apparently it's faster. But I'm a bit nervous: it appears to use port 3000. I'm in a stupidly secure environment. Will port 3000 even work.
Well, I kickstart it:
[root@downes AddressBook]# script/server -d => Rails application started on http://0.0.0.0:3000 [2005-10-09 19:57:17] INFO WEBrick 1.3.1 [2005-10-09 19:57:17] INFO ruby 1.8.2 (2004-12-25) [i686-linux]
OK, that looks good. It's now 8:00. A short break, at at 8:05 I try out my site. http://www.downes.ca:3000/ is where it should be. I enter the address... and... "Congratulations, you've put Ruby on Rails!" Joy, oh joy!
The welcome page has some instructions for me, so I check them. chmod some directories. Fine. Check the header in the dispatch files. Fine. Now a tricky one - edit the httpd.conf file to run some modules needed by Rails. Good thing i have access - users usually don't have access to the Apache configuration file. Nerously use vi and open the file, check to see whether what I need is there (one line is there) and add the other two. For this to work I'll probably have to restart the server, but I always forget how, so I'll reboot the system, which will restart the server.
8:45 - well, the server didn't restart. So I removed the lines I added to the httpd.conf file and rebooted again. This time it started. So obviously the lines that the Ruby on Rails intro page says I need to add are not quite right.
What would make them right? I try to go back to the Rails page on my server (downes.ca:3000) but it doesn't load. Right, I need to restart the Rails server. So I do that, and now I have an error message:
Rails Error: Unable to access log file. Please ensure that log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed. => Rails application started on http://0.0.0.0:3000
Sheesh - I am beginning to think I should have simply ignored the instructions on the Rails start page.
Oh well. Into the directory, and change the permissions:
[downess@downes AddressBook]$ cd log [downess@downes log]$ ls development.log production.log server.log test.log [downess@downes log]$ chmod 0666 * chmod: changing permissions of `development.log': Operation not permitted ... [downess@downes log]$ su [root@downes log]# chmod 0666 *
Sheesh, nothing is ever simple, is it?
Try to start up the Rails page again. It's still not loading. I think I'll back out and start again. I think I'll erase everything in the AddressBook directory and run the 'rails' command again (using the dreaded rm -r command - be vewy vewy careful).
Nothing happens. Everything is frozen. I can't seem to type anything into the console. My home page isn't loading. What? Oh no! Wait a second... I try another web page. It doesn't load either. Ah! It's simply that my internet connection has dropped. So I have an enforced break while i wait for a bit for Rogers Cable to get its act together. It's 8:55. But wait. Why is the laptop still working. Huh?
OK, I'm back. I rebooted my desktop. No idea what happened. Tried downes.ca:3000 again, and that's still not loading - but at least everything else is. OK then. Maybe I'll try starting the Rails server again.
[downess@downes AddressBook]$ script/server -d => Rails application started on http://0.0.0.0:3000 [2005-10-09 21:01:20] INFO WEBrick 1.3.1 [2005-10-09 21:01:20] INFO ruby 1.8.2 (2004-12-25) [i686-linux] [2005-10-09 21:01:20] WARN TCPServer Error: Address already in use - bind(2)
OK then. Now what? How do I shut down the server? I 'cd' into the 'script' directory and type 'server', hoping for some help. I am rewarded.
[downess@downes script]$ ./server => Rails application started on http://0.0.0.0:3000 => Ctrl-C to shutdown server; call with --help for options
I type Ctl-C. Nothing. Looks like the server is still running. Why would such blatantly false instructions be in the help? Now what? I type 'ps -A' to see what's running. There's an application called 'server' running. Come to think of it, 'server' isn't such a bright name for an application. Still, I type 'kill 3453 to shut down the server application. The process is gone. Was it the right one? I try to restart the server.
[downess@downes AddressBook]$ script/server -d => Rails application started on http://0.0.0.0:3000 [2005-10-09 21:11:46] INFO WEBrick 1.3.1 [2005-10-09 21:11:46] INFO ruby 1.8.2 (2004-12-25) [i686-linux]
OK, that's good. It's running again - and it started error-free this time. Maybe I won't have to wipe things out. Let's try downes.ca:3000 again and see.
No joy. It simply won't load the page. I really should have ignored those instructions. OK then, I'll kill the server, then wipe out the directory, then start over.
So I do that (using - very carefully - 'rm -r AddressBook'. Then I run 'rails AddressBook' again, redo the configuration file, then start up the Rails server one more time. And test downes.ca:3000/
Nothing. It's 9:35 and I have utterly nothing to show for 6 hours work.
That is why I make snarky remarks in my newsletter.
Day Two
8:30 a.m. Monday morning. It's a holiday, so I can delay filling out forms for another day. I decide to look at Rails again.
Thinking about it, I've decided that the error probably occurred here:
Rails Error: Unable to access log file. Please ensure that log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
Why? Well, it can't be httpd.conf because that's back to exactly what it was when I started. I didn't change the dispatch files at all. And Rails feels like it's routing output somewhere else - my attempts to log on to downes.ca:3000 are not being met with a 'connection refused', they're simply not generating any response.
So, what to do? I figure I'll go back and install Rails again. So I log back into my server and
[downess@downes ~]$ su [root@downes downess]# cd rubygems-0.8.11 [root@downes rubygems-0.8.11]# gem install rails --include-dependencies Attempting local installation of 'rails' Local gem file not found: rails*.gem Attempting remote installation of 'rails' Updating Gem source index for: http://gems.rubyforge.org Successfully installed rails-0.13.1
Just like before. Now I'll go clear out the AddressBook directory and try again. That done, I reinitialize AddressBook, chnage database.yml, and startup the server. Oops, it has been running since last night. Kill it, start again. Try to open downes.ca:3000. No luck. Maybe another port? I try
[root@downes AddressBook]# script/server -d -p 2999
to try to start it on port 2999. Any luck? No. 8:45 a.m.
It then occurs to me that I saw something about a test utility called 'rake' in some documentation. I try a Google search, and end up on this help page for Rake. The safest thing to try is 'rake --tasks' so I type that in and get a list of tasks. Good. Rake is working. I look at the task list, and of course, I have to guess at what to try next:
[root@downes log]# rake default (in /home/downess/opt-httpd-prefork-htdocs/rails/AddressBook) rake aborted! 'Packets out of order' error was received from the database. Please update your mysql bindings (gem update mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. ./Rakefile:151
Hm. So I look at the help page as suggested, and it turns out to be a page of gibberish on the MySQL site. Maybe I'll try to update my mysql bindings.
[root@downes log]# gem update mysql
Upgrading installed gems...
Attempting remote upgrade of mysql
Attempting remote installation of 'mysql'
Building native extensions. This could take a while...
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6 for inspection.
ruby extconf.rb update mysql\nchecking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6/gem_make.out
Well, that didn't work. I look at the MySQL page again and realize that this is something to do with the code. I copy the error message and try a Google search. I get this hit:
svn update vendor/rails
ruby script/server
- first db access works. any subsequent db accesses get "packets out of order" error.
cd vendor/rails
svn update -r 1790
everything works again.
Well, that looks like my problem. Let's try the fix:
[root@downes AddressBook]# cd vendor/rails bash: cd: vendor/rails: No such file or directory [root@downes AddressBook]# cd vendor [root@downes vendor]# ls [root@downes vendor]# cd .. [root@downes AddressBook]# cd .. [root@downes rails]# svn update -r 1790 bash: svn: command not found
So. The directory doesn't exist, and the command doesn't function. OK, back to the page I found. Scrolling down, I see this was a common problem. At the bottom of the page is a link to this discussion. Yes, there's my error, with a lot of discussion around it. Something to do with old/new MySQL logins. As one commentator writes, "Long story short, the version of mysql-ruby that is getting shipped with RubyGems is two bugfix releases behind, so just install the latest version from source." Sheesh. And what a weird error - works once, never works again! That's the sort of error that just sucks the life out of you. 9:15 a.m.
I read through the commentary. A dozen different solutions are proposed. Some work, some don't. Which to choose? I try the one that looks the most straightforward:
However, using my old user/password and commenting the line require ‘active_record/vendor/mysql411’ from mysql_adapter.rb worked for me.
So I search for the file in question, open it up using vi, and comment out the line. What is the 'comment out' character in Ruby? Not sure... I scoll down a bit. Ah - just like normal, just use the hash mark (#) in front of the line. I save the file.
[root@downes rails]# locate *mysql_adapter.rb /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb [root@downes rails]# vi /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb
Now what? There was no next step described.
Maybe try the 'gem update mysql' again. No, it fails, just like before. Just try downes.ca:3000? No, it still stalls out. I try the next solution proposed on the discussion board.
I had the same problem and tried to “gem install mysql�. It failed. I ran extconf.rb for mysql sources that gem wisely saved. Extconf.rb looks for mysql lib and include directories in /usr/local whereas in my case they were in /usr/local/mysql. Adding parameters to extconf.rb solved the problem:
OK, where is my mysql lib? I have no idea. Let's check /usr/local/mysql. Yes, there they are. I think. So I decide to follow what this person did.
cd /usr/lib/ruby/gems/1.8/gems/mysql-2.5.1 sudo ruby extconf.rb --with-mysql-dir=/usr/local/mysql sudo make sudo make install
I try the first command 'cd' and it reports back, directory not found. Sheesh. I use 'locate /*ruby*' to find the right directory. It turns out to be /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6. OK, let's try the commands.
[root@downes mysql-2.6]# sudo ruby extconf.rb --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient... yes
checking for mysql_ssl_set()... yes
checking for mysql.h... no
checking for mysql/mysql.h... yes
creating Makefile
[root@downes mysql-2.6]# sudo make
gcc -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.8/i686-linux -I/usr/local/lib/ruby/1.8/i686-linux -I.
-DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_MYSQL_H -I/usr/local/mysql/include -c mysql.c
gcc -shared -L'/usr/local/mysql/lib' -Wl,-R'/usr/local/mysql/lib' -L'/usr/local/lib'
-Wl,-R'/usr/local/lib' -L'/usr/local/mysql/lib/mysql' -Wl,-R'/usr/local/mysql/lib/mysql'
-o mysql.so mysql.o -lmysqlclient -ldl -lcrypt -lm -lc
[root@downes mysql-2.6]# sudo make install
install -c -p -m 0755 mysql.so /usr/local/lib/ruby/site_ruby/1.8/i686-linux
OK. Now what. Try the 'gem update mysql' command again? Not sure. I try it.
[root@downes mysql-2.6]# gem update mysql Upgrading installed gems... Attempting remote upgrade of mysql Attempting remote installation of 'mysql' Building native extensions. This could take a while... ruby extconf.rb update mysql checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... yes checking for mysql_query() in -lmysqlclient... no make make: Nothing to be done for `all'. make install install -c -p -m 0755 mysql.so /usr/local/lib/ruby/gems/1.8/gems/mysql-2.6/lib Successfully installed mysql-2.6 Gems: [mysql] updated
Ah. That's much better. OK, let's kill the server, remove AddressBook, and start again from scratch. Type 'rails AddressBook' again, edit database.yml again, run the 'head' command, start the server, and try to open downes.ca:3000 and... nothing. Bleah.
I decide to try the 'rake default' command again, just in case something has changed.
[root@downes AddressBook]# rake default (in /home/downess/opt-httpd-prefork-htdocs/rails/AddressBook) rake aborted! Access denied for user 'downess'@'localhost' to database 'AddressBook' ./Rakefile:151
See, one of the things I like about Perl is that I get my error messages right on the screen. This business of just sitting there and doing nothing is really not working for me. In any case, what I see here is a different error, an access denied error. That means it might be something I can fix in MySQL - it is, after all, a brand new database, and so I may need to explicitly allow the username to access it. I go into phpMyAdmin and run the following:
REVOKE ALL PRIVILEGES ON `AddressBook` . * FROM "downess"@ "localhost"; GRANT ALL PRIVILEGES ON `AddressBook` . * TO "downess"@ "localhost" WITH GRANT OPTION ;
Now I try the 'rake default' command again. It's slightly different:
[root@downes AddressBook]# rake default (in /home/downess/opt-httpd-prefork-htdocs/rails/AddressBook) rake aborted! Access denied for user 'root'@'localhost' (using password: NO) ./Rakefile:173
OK, then. I do the same thing, except for root@localhost. And try the 'rake default' command again. And it fails, with the same error. I check root's privileges again. He pretty much has everything; I'm not sure what more I could offer. What's he trying to do? I take a look, and it looks like he's trying to empty the test database. Well, I haven't configured a test database at all; that would explain the access denied, I suppose. I open up database.yml and look at it. Yes, there it is:
test:
adapter: mysql
database: rails_test
host: localhost
username: root
password:
OK, no access of that configuration is authorized. I'll edit this to make it match the other. Then run 'rake default again'.
[root@downes AddressBook]# rake default (in /home/downess/opt-httpd-prefork-htdocs/rails/AddressBook) /usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/rake_test_loader.rb" /usr/local/bin/ruby -Ilib:test "/usr/local/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/rake_test_loader.rb"
What does that mean? It appears to have worked. This is good. 10:15 a.m. Time for a break.
11:30. OK, erase AddressBook, and start it up again. Same procedure. No joy. OK, the changes I made were to gems. So perhaps if I reinstall Rails now, gems will install a version that plays nice with mysql. I wish I knew whether 'gem install rails --include-dependencies' actually replaced the previous instance of Rails - I can imagine a programmer checking the headers and deciding to skip the install if the previously installed version looks current. Oh well.
[root@downes AddressBook]# gem install rails --include-dependencies Attempting local installation of 'rails' Local gem file not found: rails*.gem Attempting remote installation of 'rails' Successfully installed rails-0.13.1
I wonder why it never finds the local gem file. Is there something I should know? Oh well. Clear out AddressBook yet again, edit database.yml, run head, kill the previous server process, restart the Rails server. And... nothing. OK, let's check the mysql error log. Where is it? I try 'locate /*mysql*log' but it shows nothing that looks like an error log. How about 'locate /*mysql*log*'? No. Maybe 'locate /*mysql*error*'? Again, nothing that looks like an error log. OK, cd '/usr/local/mysql'. Hunt around. Nothing. Try a Google search. Well, this article tells me how to set up logs, but doesn't tell me where they are. This page on the badly document mysql site tells me that the files seem to be named .err (it's hard to say for sure - one sentence says errors are routed to the console, which would be idiocy).
So I try 'locate /*mysql*err' which gives me a pile of results. The very last result, though, includes the string 'downes.ca.err', which suggests to me trying 'locate /*downes.ca.err'. That gives me a half dozen hits. I decide to try for /opt/mysql-4.0.20/data/downes.ca.err. I type 'tail downes.ca.err' after entering the directory, so I see only the end of the file. Nope, that's from last January. Let's try /var/lib/mysql/downes.ca.err. Nope, that's the same file, it looks like. OK, how about /opt/mysql-4.1.9/var/downes.ca.err? I cd into /opt/mysql-4.1.9/var/ and type 'ls' to see what's in there. What the heck?
AddressBook downes-bin.000006 downes-bin.000012 downes-bin.000018 edurss moodle urchin downes-bin.000001 downes-bin.000007 downes-bin.000013 downes-bin.index elgg mysql wikiplam downes-bin.000002 downes-bin.000008 downes-bin.000014 downes.ca.err etomite mysql.sql wordpress downes-bin.000003 downes-bin.000009 downes-bin.000015 downes.ca.pid ibdata1 scoop downes-bin.000004 downes-bin.000010 downes-bin.000016 drupal ib_logfile0 test downes-bin.000005 downes-bin.000011 downes-bin.000017 dwiki ib_logfile1 test_you_can_safely_delete
AddressBook! It's a directory, so I 'cd AddressBook' and look inside.
[root@downes var]# cd AddressBook/ [root@downes AddressBook]# ls contacts.frm contacts.MYD contacts.MYI db.opt
Hm. None of these look like an error. Back up, then, to look at the error file.
051009 21:39:43 mysqld started 051009 21:39:44 InnoDB: Started; log sequence number 0 1323437 /opt/mysql-4.1.9/libexec/mysqld: ready for connections. Version: '4.1.9-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution
There's the reboot from yesterday. Mysql came back up, and sat waiting, error-free, while it handled the various requests from my website. No errors at all. What gives? Back into the AddressBook directory. The first three files contain binary data, which I can't read. The last:
[root@downes AddressBook]# more db.opt default-character-set=latin1 default-collation=latin1_swedish_ci
Swedish? Huh? But that's probably not the cause of my problem. What is? I don't know. Let's reboot the server.
Server's back up. Try to ssh back into it. Now I'm getting password error problems. Permission denied. Oops, forgot to start the vpn. Start the vpn, then try to login. Permission denied. I can't enter my own server. FTP access also fails. I've probably tripped up on of those stupid security systems by trying to login without vpn. So I'm shut out until the system either clears itself or until I can get into it physically on Tuesday. It's 12:25 pm.
1:00 p.m. Still locked out. But I've been thinking, rereading this document. When I ran 'gem install rails --include-dependencies' the first time, it gave me a whole string of stuff - a bunch of 'success' and 'installed' messages. But when I ran it later, it simply gave me the 'Rails installed' message. This means it's not reinstalling the dependencies, just Rails. And my problem - accessing MySQL - is probably in one of the dependencies. So even though I've fixed gems, it might not be installing Rails properly. Hm. But wait, if that were so, rake wouldn't have run properly. And it did. Maybe that's not it either. Hm. What I want to do is remove everything I installed and to start over, knowing what I know about the various fixes I need to make to things. But how to do that? I have no idea.
I've gone back to the Ruby on Rails site. This time I click on Community. I want someone to send this file to; maybe they can suggest something. But it doesn't look like a community at all - it looks like instructions on how to install Rails. Wha? I click on Start at the beginning and there's some diatribe about Rails and Ajax. Interesting, but definitely not the beginning. Check Getting Started on Rails. It begins, "Make sure you have Ruby 1.8.2 installed." Yeah, right, learned that the hard way. Most of the rest looks like what I've done so far (no mention of the errors, though). I note the Apache stuff, which is different. In addition to the stuff about mod_rewrite.so there's also a whole bunch of code to enable Rails to do redirects (that's when a server gets a request for one page, and sends it to a different place - it allows for simple URLs). Well, trying to load 'mod_rewrite.so' simply crashed my server before. Does Rails require Apache 2 or something? Ah, but I look at this page. I'm not at that point yet; it simply shouldn't be a factor. Accessing downes.ca:3000 should access Rails, without redirects. Like it did before.
I wonder about uninstalling Rails. It seems to me there ought to be an 'gems uninstall' to match 'gems install'. I try a Google search. Yes, there it is - naturally, a discussion list question about why it doesn't work. Still, will it work? I look at this Rubyforge page and it appears you can order it to remove the dependencies as well. Except, (from here), "The current gems software is a bit sloppy in its dependency evaluations while deleting." Still, it looks like 'gems uninstall rails --include-dependencies' would do the trick. 1:30 p.m. Still locked out of my web server.
Comments
Re: Ruby On Rails
Several times in your "story" you could have solved the problems waaay much faster and easier if you just stopped and read/comprehended the actual error messages. You must be a really expensive programmer, have to disagree with the previous commenter, not for the quality, but for the time it takes you to solve problems. As true 4 years ago as it is now. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
phusion passenger has made this *much* easier now. You can just drop it in, add 4 lines to apache.conf and you're good to go. How long does this need to be? [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I had problems installing RoR on XP. A few hours on Google 'Groups' (groups.google.com) and google proper had me sorted out eventually. Ruby 1.8.4, Rails 1.1.6, Postgresql 8.1 (warning 'pgadmin', the web postgresql admin front-end, doesn't have sql export/import, perhaps better to use mysql for developement). [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I came across this site last saturday when I was attempting to get Ruby on Rails up&running. I blogged about it here - http://patrick.blogdns.org/blog/adventures-in-the-land-of-ruby-on-rails-part1 1 of the issues I had was with the very informative (that's sarcasm for those that missed it) yaml.rb (which is a ruby file, not a rails file). Apparently, unlike other languages&other init files, yaml requires *spaces* *only*. I had a few tabs in my file&that's why yaml was complaining. I was also having issues with getting RoR to work under apache, but problem was solved when I found a small side note about file permissions on several directories - I don't know if this will help those on windows or not. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I have been trying to get RoR installed now for three days. I am constantly having issue, error after error. Does anyone have a full proof step-by-step installation instruction complete with commands? Thanks, Dan [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
To echo others - thanks. I took a similar shot at getting RoR running (on RHEL 4.1/MySQL/Apache2) and am left shaking my head. It's hard to imagine a programming efficiency win that could really outweigh the systems administration nightmare of installing RoR on a viable production server. RoR = not ready for prime time. It makes for a nice demo, but unless/until the developers take the production environment setup problem seriously (or the world tips on its ear, and it starts to make sense to run a production server on port 3000 of a Windows XP workstation), the whole idea is purely academic. - Dave [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I'm still trying to install it - third time this weekend and I'm about ready to just say "fsck this" until someone at RoR gets their head screwed on straight. I *am* on Windows, but I can reasonably match a Linux environment (as far as the program is concerned). [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I just want to THANK YOU for blogging your whole experience of setting up Ruby on Rails applications on Linux. It guided me through the setup today when I moved an application I developed on Windows using instantRails to a linux box. I don't know how much more time I would've taken if not for your blog, since I ran into many of the same problems as you did. I really appreciate your taking the time. - nina [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
wow, i found it easy to get up & running on gentoo and mac os x. no problems at all. i've had it running on windows too but since my experience with windows is as a desktop user it wasn't as easy for me. (/windows/system32/drivers/etc/hosts, WTF?!) [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I hail your efforts. I as well am stuck in the same situation installing it on SLED 10 (I know the release isn't out yet) and got the same #28000Access denied for user 'root'@'localhost' (using password: NO) error. For the life of me I can't figure it out. Anyway, back to the drawing board. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
This whole article makes you sound like a whiney little prick. It comes off highly antagonistic as though it should install itself because you were thinking about it. Go try windows and leave your comments to yourself. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
To the person who said that it is hard to believe such problems would exist because it is so easy on set up in 2 minutes on Mac OS X, please understands that: (1) There are installers for Mac and Windows that make everything easy but (2) Most big iron webserver clusters run some form of industrial strength unix and there are often many hidden complexities in how things are set up. All I can say is try setting up ruby, gems, and rails on an AIX server, which requires a lot of compiling from stratch and commenting out of things.... [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I like your article's style. It is the standard way to instll any open source package. Lot's of try and error approach. By the way I have installed Ruby on Rails on Mandrake Linux platform. It works for me now. But I was struggling with the installation for few hours as well. But all of the struggle payed off when I started to see the development structure and played with the language and some simple examples. I like the structure I like the scripting language of ruby and testing approach. I am definitively into ruby after trying PHP, Perl, Java etc.. I am trying to convert my application written in PMWiki/PHP to Ruby on Rails. Aleks ( http://www.exploreluxury.com ) [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
All too many one-click installers for Windows that come complete with their own whole environments. If however you already HAVE a working stack and just want to add RoR -- well good luck with that. Hard to find, hard to read, hard to get, hard to do. I'm about ready to give up. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Ya,, well fact is I been messing around for 2 day on both FC5 and SUSE_10 trying to fix the "No such file or directory - /tmp/mysql.sock" error. Normally I could solve this stuff but the error ouputs just plani SUCK. They tell one "nothing" at all (completly WORTHLES). The programmers of this stuff should realize that this is the year 2006 and that using whole sentences is common for GOOD computer code. Sentence that explain what it is looking for EXACTLY. Once more it is strange that the RubyOnRails people have not picked up on all the "bitching" and explained EXACTLY how to make the system work. Gary [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
A clarification: In my database.yml file, the line beginning with password: happened to be above the line beginning with host:. In your database.yml file, if you have another field on the line above host: line then make sure that there is a space between : and whatever follows on that line. unknown [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 3, col 2: 'host: localhost' (ArgumentError) To fix this problem edit your $RAILS_ROOT/config/database.yml file and make sure that there is a space after password: unknown [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Hmm, a warning to anyone installing Rails as a gem on Windows XP (and possibly other Windowseses) - the "gem" command takes absolutely *ages* to do anything, so be prepared to sit and wait for about a half an hour, hitting "Y" every ten minutes or so to install dependencies. Also, if your server is IIS, you're in for a rough time (a lot of Rails depends on URL rewriting, which IIS does *not* have as standard). There are HOWTOs on the Wiki at rubyonrails.org. That said, I've had generally extremely positive experiences with Rails, and Ruby is a pleasure to work with. The newer versions (I'm using 10.0) are a lot more stable. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Why do you insist on using a wooden spoon to stir your ravioli? [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I have to echo the comment, "when it goes wrong, it really goes wrong". I'm trying to install it on XP and after I type, "gem install rails --include-dependencies" it starts humming away for three lines, and just hangs at "Updating Gem source index for: http://gems.rubyforge.org" No message, no timeout, no nuthin. I'm currently looking to try instant Rails ( http://rubyforge.org/projects/instantrails/ ) I'd rather choose my installs my self... so easy to inject some sneaky code into an installer....yikes. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Stephen, it's funny how much our experiences differ. It took me about four hours with the "Rolling with ruby on rails" tutorial before I was absolutely blown away. From that moment on, I've been using ruby exclusively for any project where I have a choice. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
"As I recall, it took me minutes to get Ruby and Rails setup on Linux. If even navigating the Ruby and Rails websites is so difficult, maybe you should stick to cooking" What a ridiculous thing to say. I got rails to work on tiger following the agile book, but I got stuck with an error message on page 57. How arrogant of you to say that if the conventions of the computer world are not obvious to us, it is OUR problem, and we should give up. Wake up, this is an internet world, and just as the print had to be standardized so everyone could read, not just the monks, so it is time for installs to be tested/standardized so everybody can participate in the internet world. Thank you for this post, we do need to figure out how to debug these problems and it is encouraging to see how you went about it. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Oh my dear Lord, you just saved me banding my head on my new ibook. I couldn't get my apps I wrote on my gentoo-linux desktop to work on my ibook. Since I'm going home for Winter Break (I go to Colorado School of Mines), I was trying to move stuff I needed to work on onto the laptop to work on since I have to leave my desktop behind, and now I can thanks to your article. You saved my sanity and possibly my soul. --Samuel "Artoo" Goodwin www.freshman-15.blogspot.com [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Hi, I fairly recently came to Ruby and wanted to use Rails. I am disapponted to read your experiences and shall bookmark it. However, to offer a counter to the article, I have installed on several Windows boxes, all my OS X boxes, my Ubuntu based machine and 3 fedora Core based Lnux systems. I can give my word that I never had any issue on any of the installs. When it goes wrong - it seems to go wrong! Now I could talk for a long time on the issues of installing .NET Framework on a production server and the soon forgotten hopes of enjoying your weekend..... [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
As I recall, it took me minutes to get Ruby and Rails setup on Linux. If even navigating the Ruby and Rails websites is so difficult, maybe you should stick to cooking (mmm, frozen ravioli -- gimme 2 bowls) and stream-of-consciousness writing (I haven't slept so well in weeks). [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Windows XP Pro install... Go to rubyonrails.org Click Download link connects to http://rubyforge.org/projects/rubyinstaller/ grab windows msi file Run downloaded file Program installed Finished in 9 minutes Go to http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html and ready about how to get started...great place to start. posted by www.randyandgerri.com [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Gentoo Is Love. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
These instructions work on OSX, most linux distros and FreeBSD You can skip ruby if you already have a good copy. But if you only have the stock ruby that comes with OSX I would compile it from source and rename the stock OSX ruby and irb to ruby.bak and irb.bak so you don't end up using them on accident. __________________________________________________ ______________ Get Ruby1.8.2 curl -O http://rubyforge.org/frs/download.php/2338/ruby-1.8.2.tar.gz tar xvzf ruby-* cd ruby-1.8.2 ./configure make make test sudo make install __________________________________________________ ______________ Get Ruby gems curl -O http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgz tar xvzf rubygems* cd rubygems* sudo ruby setup.rb __________________________________________________ ______________ Get Rails and a few other gems sudo gem install rails RedCloth search_generator salted_login_generator production_log_analyzer answer yes to all dependencies __________________________________________________ ______________ Get mysql-ruby C bindings (the pure ruby ones suck) This command works great on osx as well using the mysql 4.1.x installer from mysql.com or the serverlogistics.com mysql as well. curl -O http://tmtm.org/downloads/mysql/ruby/mysql-ruby-2.7.tar.gz tar zxvf mysql-ruby-* cd mysql-ruby-* ruby extconf.rb --with-mysql-config make sudo make install __________________________________________________ ______________ download fastcgi developers kit curl -O http://fastcgi.com/dist/fcgi-2.4.0.tar.gz tar xvzf fcgi-2.4.0.tar.gz cd fcgi* ./configure make sudo make install __________________________________________________ ______________ Get the new non memory leaking ruby-fastcgi bindings curl -O http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz tar xzvf ruby-fcgi* ruby install.rb config --without-ext ruby install.rb setup sudo ruby install.rb install __________________________________________________ ______________ We need the correct pcre .so’s for lighttpd to work correctly curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-5.0.tar.gz tar xzvf pcre-5.0.tar.gz cd pcre-* ./configure make sudo make install __________________________________________________ ______________ Get lighttpd curl -O http://www.lighttpd.net/download/lighttpd-1.4.6.tar.gz tar xzvf lighttpd-1.4.6.tar.gz cd lighttpd-* ./configure make sudo make install __________________________________________________ ______________ Compile php as a fast-cgi binary The main thing here is the following configure options. You can add whatever else you like to your php binary but these are needed for fast-cgi support. $ ./configure \ --enable-fastcgi \ --enable-discard-path \ --enable-force-cgi-redirect \ __________________________________________________ ______________ Lighttpd Launcher Script Here is a link for a sweet enhancement. Put this script in your RAILS_ROOT/script folder and put the lighttpd.conf file in RAILS_ROOT/config. Now you can launch your rails app by cd’ing into your RAILS_ROOT for your app and typing: $ruby script/lighty -p 7500 -e development (or whatever port & env you want to use) Now you can hit http://localhost:7500/ and you will get your app running on lighttpd no muss no fuss. Very sweet for development. Here is the link: http://www.bigbold.com/snippets/posts/show/303 . Name the first ruby script lighty and name the config file lighttpd.conf. Now every time you start your app this way is creates a new lighttpd.conf in /tmp and starts lighttpd up with that file. This way you can give it command line options as to what port to bind to and others. I’m using this for development and it is sweet! [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
As a previous poster put it - It's pretty tough to mess this up on Windows 1. Download the "Ruby One Click Installer" http://rubyforge.org/projects/rubyinstaller/ 2. Download and Install XAMPP - (this is a great download) http://www.apachefriends.org/en/xampp.html 3. type "gem install rails" at a command prompt If you've got a decent broadband connection, you should be good to go in about 15 minutes. You'll have everything you need Ruby, Rails, MySQL, PhpAdmin (makes managing your database a breeze), plus you'll have Apache Perl PHP and a few other cool tools to play with too. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I think you should start learning more about Linux and its tools if you want to use it. Else you might be better off actually having a webserver running Windows. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I'm amazed you stuck with it through the problems you had. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Though, what Stephen says IS valuable: see http://redhanded.hobix.com/inspect/aTourOfRubyEveryBlinkOfTheEye.html [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I managed to setup Rails in 2 minutes on Mac OS X Tiger without any single problem. The thing to mention is Ruby was already there. Second time I tried it on Widnows and still no problems. I can't believe in what you are writting here. Never heard of anyone before having so many problems with that sweet thing. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
if you're on ubuntu/debian, all you need to do is apt-get install rails. That picks up all the dependencies and is all you need. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Ruby One Click Installer + XAMPP + gem install rails worked for me. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Funny, For windows there is an all in one installer. I had Ruby/MySql/Apache, etc. running perfectly within 5 minutes and I'm not kidding! Linux installs always are fraught with novelty... [Comment] [Permalink] [Previous][Next]
Restarting apatche
noticed you forgot this bit: #>sudo apachectl configtest #>sudo apachectl graceful I use the tcsh shell, which has tab completion, and its just great all around. i just type "apach" then mash tab a few times till it prints out a list of all the commands in my path that have that first few letters. generally i can at least remember "apach" when trying to restart :-) running into a few problems of my own.. I seperated the webserver problems from the rails problems. application works great through webbrick, but through lighttpd it crashes and burns, spitting out "Rails Error: Unable to access log file. Please ensure that log/production.log exists an..." still workin those kinks out.. awesome walkthrough though. keep it up! i can see some places i might go from here! good luck with your stuff. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I decided to try the Onlamp tutorial http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1 and was all excited about seeing it work, but I ran into the database.yml error as well: c:/ruby/lib/ruby/1.8/yaml.rb:119:in `load': parse error on line 20, col 11: `' ( ArgumentError) from c:/ruby/lib/ruby/1.8/yaml.rb:119:in `load' from ./script/../config/environment.rb:58 from ./script/../config/environment.rb:58:in `open' from ./script/../config/environment.rb:58 from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `re quire__' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `re quire' from script/server:42 Everything had worked perfectly up until I made that file and attempted to restart the webrick server, now nothing works. I'm at a loss and I can't seem to find an answer anywhere...perhaps in a few days one will pop up [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
OK, this is the beauty part of open source culture. I can just continue to work on other stuff for a few days, and you guys will collaborate and commiserate, and a week from now you will have solved the problem, and you'll publish the process, with all the necessary hacks they *didn't* tell you about in the README files, and I'll be up and running in an hour or two. Sweet! [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Hi, textdrive.com has Ruby on Rails already installed, you might find an account with them to save you a lot of time. (No affiliation, not even a customer, just a suggestion.) [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
Sorry about the comments error, it has been fixed. Apparently Ruby is running but is simply inaccessible outside NRC (I will write a Part 2 when I get time to work on it again). So, maybe, if you follow what I did, your Ruby installation will work. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I am totalling having the exact same problem Stephen. I am assuming it has to do with the MySQL install. The first time it worked, but now I am totally locked out. I have uninstalled serveral times, deleted the MySQL files and deleted every reference to MySQL in the Registry. Re-install. No luck. Thanks for walking through it. Please post if you get it corrected! [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
PPS: oh, and I get this error when I try to "preview" a second time: Permission denied . at /opt/apache-1/htdocs/cgi-bin/page.cgi line 82. [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
PS: Hmmm, maybe you should keep crackin on that ruby stuff... and replace your comment script! I'm quite sure I hit "preview" (I even made changes in the textbox after reading the preview text), but the comment script posted my first draft!! Plz excuse my typos... b [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I feel your pain Stephen... although I actually managed to get through that oreilly tutorial on Windows. However on my (gentoo) linux box, I can run webbrick without talking to the db, but if I set the yaml file to point at the db, it won't start: /usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 3, col 2: 'host: localhost' (ArgumentError) from /usr/lib/ruby/1.8/yaml.rb:133:in `load' from ./script/../config/environment.rb:58 from ./script/../config/environment.rb:58 from script/server:42 However, I most certainly do have MySQL running on localhost... I can connect to it just fine... don't know what Ruby's problem is... That's the thing that kills me about so much development documentation... it's 99.9999999% "happy path"... Very rarely does anyone ever bother to take into account common snafus... the kind that just soak up hours and days of your time. And, what really irks me about the railsheads is that they're so giddy and gloaty about how easy it is to whip out the sites with rails. Well, yeah, it's easy to whip out a basic front end to a db... no validation, no style... Now, knocking out a quick prototype that quickly is nice, don't get me wrong. But once the honeymoon's over, you still have to "put out" the ruby code to finishing building your app... and, sorry to all the "ruby reads like english" folks, but I don't usually leave out lots of words when I speak. I also feel that a computer language is much easier to grasp without cryptic magic punctuation marks. But what's really funny is that I still find myself extremely curious about ruby and rails.... well, I'll get there, slowly but surely. Ben [Comment] [Permalink] [Previous][Next]
Re: Ruby On Rails
I'm not a programmer nor am I a linux expert (part-time tinkerer only) and I'm not interested in (nor had I heard of) Ruby on the Rails. However, I was intrigued by your problem solving approach to the installation. I'd love for my math students to view this. They often are looking for an easy 2 second fix to problems given them. Real problems take time and may need a variety of approaches. Also, I have increased appreciation for quality programmers! Thanks for sharing your journey to ... Jeff Hamilton [Comment] [Permalink] [Previous][Next]
Your comments remain your property, but in posting them here you agree to license under the same terms as this site (Creative Commons). If your comment is offensive it will be deleted.
Automated Spam-checking is in effect. If you are a registered user you may submit links and other HTML. Anonymous users cannot post links and will have their content screened - certain words are prohibited and your comment will be analyzed to make sure it makes sense.