13 Feb 2011, 19:08
Generic-user-small

Robert (5 posts)

Any help is appreciated…

I bought the paper copy of // and on page 213 it says that the source code contains a file RUBY_README.txt to help in setting up ruby. I downloaded the source from the http://pragprog.com/titles/bhh5 code section but can’t find such a file. I went ahead and setup a test ubuntu 10.4 LTS server as a LAMP server and used the following to install what I thought would be a working environment–my goal is to work with the chat example to learn web sockets. I’m getting the following error when trying to run ruby server.rb from the source code directory I get the following error:

/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- em-websocket (LoadError) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require’ from server.rb:17

My ubuntu install goes like this (all commands as root):

apt-get install python-software-properties add-apt-repository ppa:ubuntu-on-rails apt-get update apt-get install ruby rubygems irb ri rdoc rake apt-get install build-essential ruby1.8-dev libopenssl-ruby export PATH=/var/lib/gems/1.8/bin:$PATH …restarted terminal gem install em-websocket-server json

What have I done wrong?

13 Feb 2011, 23:00
Generic-user-small

Robert (5 posts)

Of course by ‘//’ I meant to type out the book title “HTML5 & CSS3” by Brian P. Hogan.

15 Feb 2011, 19:41
Bphogan_pragsmall

Brian P. Hogan (145 posts)

Yikes! How that didn’t get into the code repository is beyond me, but I will get someone to fix that!

For now, the blog for the book has the file you need.

http://beyondhtml5andcss3.com/code/RUBY_README.txt

One problem with Ruby on Ubuntu is the packaging system and how it plays with RubyGems. Many people recommend installing Ruby and all related pieces from source, but since you’re just looking to follow along with the book, I recommend installing RubyGems from source. Instructions for making it work are at the above link.

Really sorry that link didn’t get into the code repository, and I’m sorry you’ve had some time wasted. If you get stuck again let me know.

18 Feb 2011, 06:06
Generic-user-small

Robert (5 posts)

Thanks! I’ll see if I can get it figured out. Excited to try.

18 Feb 2011, 16:05
Generic-user-small

Robert (5 posts)

I followed the RUBY_README.txt just fine everything installed. When I run ./Rakefile I get the following: root@zlamprail1:/btdata/ruby/code/html5_websockets# ./Rakefile ./Rakefile: line 1: namespace: command not found ./Rakefile: line 2: task: command not found ./Rakefile: line 3: puts: command not found /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in gem_original_require': no such file to load -- json (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in require’ from server.rb:18 ./Rakefile: line 5: end: command not found ./Rakefile: line 6: end: command not found ./Rakefile: line 8: namespace: command not found ./Rakefile: line 9: task: command not found ./Rakefile: line 10: puts: command not found [2011-02-18 09:00:17] INFO WEBrick 1.3.1 [2011-02-18 09:00:17] INFO ruby 1.8.7 (2010-01-10) [x86_64-linux] [2011-02-18 09:00:17] INFO WEBrick::HTTPServer#start: pid=6540 port=4567

Then I edited the chat.js file to point to my ubuntu box that has ruby loaded on it (I tried the default port in that js file and also tried port 4567 but all it says is connecting. Does the html and .js file need to be loaded on the linux web server? What about the errors I’m getting above?? Thanks

18 Feb 2011, 17:07
Bphogan_pragsmall

Brian P. Hogan (145 posts)

You ran ./Rakefile? Cos that’s not how it works… Rakefile contains tasks the ‘rake’ command uses. I think you want

rake start

instead, which should fire up the chat server as well as a web server.

And I believe that the html file needs to be served from a web server of some sort, rather than just opened in a browser locally.

18 Feb 2011, 21:23
Generic-user-small

Robert (5 posts)

Ok, rake start got me farther but still errors:

root@zlamprail1:/btdata/ruby/code/html5_websockets# rake start (in /btdata/ruby/code/html5_websockets) Starting Flash Policy Server Starting Websocket Chat Server… Starting Frontend Web Server [2011-02-18 14:19:55] INFO WEBrick 1.3.1 [2011-02-18 14:19:55] INFO ruby 1.8.7 (2010-01-10) [x86_64-linux] [2011-02-18 14:19:55] INFO WEBrick::HTTPServer#start: pid=6965 port=4567 /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in gem_original_require': no such file to load -- json (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in require’ from server.rb:18

I loaded the index.html and other items from the public folder on the code repo and It says connecting… I can never connect then it finally says ‘connection close’ after some time. (I tried both ports 4567 and 9394 and neither works)???

  You must be logged in to comment