From: Markus Fischer Date: 2010-09-13T05:37:36+09:00 Subject: My experience from setting up a ruby dev environment (was: Re: Ruby packaging in Debian and Ubuntu: Mythbusting and FAQ) Hi Lucas, [warning: this turned out to be a loooong email] thanks for going after this topic, and thanks for caring about Ruby on Debian! I see that people are already actively writing comments on your blog, however I prefer the list to easier keep track of things (I'm doing hard following replies on a flat list like the blog comments). On 12.09.2010 18:29, Lucas Nussbaum wrote: > Feel free to discuss it here, or in the blog comments. (I'm > monitoring both) I'm also one those who replied recently on ruby-core about the Ruby/Debian issue, not because I want to nag about it but I also care about it. I've much settled about using "rvm" these days to avoid the problems I had but I think it's only fair to the immense amount of work you're putting into it when a user like me also provides his share of it, so I thought about getting back and see what problems I had. For the following things, I'm doing this on Lenny inside VMWare, 2.6.26-2-amd64 that is. It's a clean system, i.e. freshly installed and no ruby anywhere. I made a snapshot so I can go anytime back and test things really from the start if I'm doing something wrong. Goal: set up ruby so I can develop with nokogiri (it's one of the common use cases for me) Looking at the available ruby packages (I did with dpkg -l '*ruby*' ) I went with "sudo aptitude install ruby-full", it sounded the most reasonable to me. After the installation, I also installed "libxml2-dev" because due my prior knowledge I know what nokogiri is based on it. Install of that went fine and then I executed "gem list --remote" because I didn't see the nokogiri package on the previous package list: $ gem list --remote bash: gem: command not found So that was the first little wall. I truly was not aware that gem is not part of ruby on Debian. Or in general? I don't know that. Anyway, I cleverly typed dpkg -l '*gem*' to find it, but was surprised: rc imagemagick un imagemagick-doc rc kimagemapeditor un migemo Nothing about ruby and gems anywhere. I checked my sources.list : deb http://ftp.at.debian.org/debian/ lenny main contrib non-free deb-src http://ftp.at.debian.org/debian/ lenny main contrib non-free deb http://security.debian.org/ lenny/updates main contrib non-free deb-src http://security.debian.org/ lenny/updates main contrib non-free deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib non-free deb-src http://volatile.debian.org/debian-volatile lenny/volatile main contrib non-free Looks pretty complete to me. I went on to http://www.debian.org/distrib/packages and searched in "Search the contents of packages" for it, I tried with "bin/gem" in "stable" first and it came up with "jruby-1.0" and "netbeans-ide"; weird I thought. I tried again with "gem" but the result was equally lacking what I was looking for. Next try was to search "Search package directories" in "stable" for "gem" and finally at the end I saw "rubygems" and related packages. So I installed with "sudo aptitude install rubygems". This was very puzzling that gem was not part of ruby or even that ruby-full didn't not contain the rubygems (which due it's name implied it to me). Next thing: find the package, I ran "gem list --remote". I got an awful long list which went by so I need to grep for it to see what's really there. $ gem list --remote|grep nokogiri ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Found 302 (http://gems.rubyforge.org/latest_specs.4.8) Now that was weird. I ran the previous comment again: $ gem list --remote *** REMOTE GEMS *** ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Found 302 (http://gems.rubyforge.org/latest_specs.4.8) Still not good. I vaguely remembered that "gem" is using user prefs for it's things and I discovered ~/.gem/ in my homedir. I removed it and now the remote listing did work; but only once: mfischer@lenny:~$ rm -Rf .gem/ mfischer@lenny:~$ gem list --remote|grep nokogiri glebm-nokogiri (1.4.2.1) jwagener-nokogiri (1.4.1) nokogiri (1.4.3.1, 1.2.3) nokogiri-happymapper (0.3.4) nokogiri-plist (0.3.1) revo-nokogiri (1.4.1) rsolr-nokogiri (0.0.0) rubyjedi-nokogiri_java (1.4.0.20100513161003) superfeedr-nokogiri (1.4.0.20091116183308) mfischer@lenny:~$ gem list --remote|grep nokogiri ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Found 302 (http://gems.rubyforge.org/latest_specs.4.8) Oh my. So gem installation wouldn't work either unless I removed ~/.gem again: $ gem list --remote|grep nokogiri ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Found 302 (http://gems.rubyforge.org/latest_specs.4.8) $ gem install nokogiri ERROR: could not find gem nokogiri locally or in a repository $ rm -Rf .gem/ $ gem install nokogiri ERROR: While executing gem ... (Errno::ENOENT) No such file or directory - /var/lib/gems/1.8/cache/nokogiri-1.4.3.1.gem Or so I thought .... At that point I lost interest in getting things up and running (I tried it twice from a clean VM snapshot). I reverted to clean snapshot and went for the "rvm" way, starting at http://rvm.beginrescueend.com/rvm/install/ . I took me a while to figure out what packages I'm required to have to get "rvm" properly running, which meant I had re-run the rvm installation process multiple times until I got through. That took my about ten minutes (and it was not very fun); in the end I installed "make", "gcc", "bzip2", "git-core", "zlib1g-dev" and "curl" and added this line to end of .bashrc [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" and started a new shell and installed 1.8.7 (the version used as the default package in Debian): $ rvm install 1.8.7 [...] $ rvm use 1.8.7 info: Using /home/mfischer/.rvm/gems/ruby-1.8.7-p302 After that I installed libxml2-dev $ gem install nokogiri and I quickly discovered that I also need libxslt-dev to continue. This is how the final installation looked: $ gem install nokogiri Building native extensions. This could take a while... Successfully installed nokogiri-1.4.3.1 1 gem installed Installing ri documentation for nokogiri-1.4.3.1... No definition for parse_memory No definition for parse_file No definition for parse_with No definition for get_options No definition for set_options Installing RDoc documentation for nokogiri-1.4.3.1... No definition for parse_memory No definition for parse_file No definition for parse_with No definition for get_options No definition for set_options No idea what those "No definition" stuff is about,. $ cat - > test.rb require 'rubygems' require 'nokogiri' p Nokogiri::HTML("

Mr. Belvedere Fan Club

") $ ruby test.rb #, #]>]>]>]> Installation worked. Although getting "rvm" up and running wasn't a piece of cake either, but the problems I faced were purely related to install missing packages, because the errors very obvious to me. But that was not the case why I could run "gem list --remote" only the first time successfully. Package error? Ruby error? I wouldn't know, I'm not that an expert. Collecting the missing packages for getting "rvm" up was cumbersome, in recall from the past that usually many of them are installed already (most notably the compiling chain) on the systems I work one. Next I tried if I can get further with the Ruby 1.9 packages: $ sudo aptitude install ruby1.9-full rubygems1.9 libxml2-dev libxslt-dev I typed those out of my mind because I thought that would be the equal package names, but I was wrong. There's no full for 1.9 on Lenny, this was the proper line: $ sudo aptitude install ruby1.9 ruby1.9-dev rubygems1.9 libxml2-dev libxslt-dev However, running "gem list --remote" twice didn't work either: $ rm -Rf .gem ; gem list --remote|grep nokogiri ; echo "------------------" ; gem list --remote|grep nokogiri glebm-nokogiri (1.4.2.1) jwagener-nokogiri (1.4.1) nokogiri (1.4.3.1, 1.2.3) nokogiri-happymapper (0.3.4) nokogiri-plist (0.3.1) revo-nokogiri (1.4.1) rsolr-nokogiri (0.0.0) rubyjedi-nokogiri_java (1.4.0.20100513161003) superfeedr-nokogiri (1.4.0.20091116183308) ------------------ ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) bad response Found 302 (http://gems.rubyforge.org/latest_specs.4.8) I've no idea what's going on here. Now as to why I didn't report a bug at Debian yet: if I encountered the error in the past (which I don't remember to be honestly) it would have been during working-hours and depending on my available time there I may have not had the time to report the bug. Now that I could reproduce it, shall I create one? I'm not sure where the bug exactly is here... Lucas, thanks for the initiative and for listening. I hope I could help with that mail in anyway. sincerely, - Markus