Thursday, June 20, 2013

svn: The POST request returned Invalid XML - It's always the disk

I was debugging a Subversion 1.7/Apache 2.2 problem where a user could check out code without issue, but any time they tried to update, they got the following error:

"svn: E175002: The POST request returned invalid XML in the response: XML parse error at line 3: not well-formed (invalid token)  (/path/to/svn_repository/!svn/me)".

There wasn't much documentation on the Web, and the documentation said that usually an error would appear in the Apache log indicating a file that the user didn't have permission to access.  I checked the permissions and the server disk space and everything was fine.  I even fired up Wireshark and only saw that the XML that came back contained a null element, which I think more recent versions of SVN has fixed.

I racked my brain trying to figure out the issue, but ultimately determined that the issue was with that particular user's disk quota.  They couldn't create any more files, so they got the red herring error message above.  So remember, for this particular error, it's always, always the disk, whether it's permissions, disk space, or quota.

Thursday, April 18, 2013

Bundler, Rails, and root

I was having problems of the form:

/usr/local/share/gems/gems/sqlite3-1.3.7/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

when trying to run a rails app as root, after running bundle install as root.
An article at http://www.petersens.ws/2012/08/ruby-on-rails-and-sqlite3 helped me figure out the problem.  Some of the apps with native extensions don't set GEM_HOME properly as root.  The easiest way to fix this is to run gem uninstall on the offending gem, then run the bundle install as a regular user.  I also ran into this with
posix_spawn (/usr/local/share/gems/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:2:in `require': cannot load such file -- posix_spawn_ext (LoadError))
charlock_holmes (/usr/local/share/gems/gems/charlock_holmes-0.6.9.1/lib/charlock_holmes.rb:1:in `require': cannot load such file -- charlock_holmes/charlock_holmes (LoadError))
yajl_ruby (/usr/local/share/gems/gems/yajl-ruby-1.1.0/lib/yajl.rb:1:in `require': cannot load such file -- yajl/yajl (LoadError))
redcarpet (/usr/local/share/gems/gems/redcarpet-2.2.2/lib/redcarpet.rb:1:in `require': cannot load such file -- redcarpet.so (LoadError))
nokogiri (/usr/local/share/gems/gems/nokogiri-1.5.6/lib/nokogiri.rb:27:in `require': cannot load such file -- nokogiri/nokogiri (LoadError))

In all cases, uninstalling the gem as root, then running bundle install as a regular user fixed it.

Friday, April 5, 2013

Getting a ruby gem to load rake tasks

I had a gem (call it foo_bar) which implemented a Bar module.  It included and ran fine in my Rails project when I added gem "foo_bar" to the module, but I couldn't get the rake tasks to show when I ran rake -T.  After some review, I found that the name of the ruby file that kicked everything off was lib/bar.rb when it should have been lib/foo_bar.rb.  Changing the file name to match the name in the gemspec fixed it.

You will want to check your gem to make sure your
require 'bar'
statements are actually
require 'foo_bar'
statements.