srushti/goldberg

Portability issues / suggestions

Opened this issue · 6 comments

I'm running Goldberg on FreeBSD, which works nicely, however, a few things that I stumbled upon:

I had to add the following to the Gemfile

--- orangenschale.orig/Gemfile  2012-07-12 05:14:44.000000000 -0500
+++ orangenschale/Gemfile   2012-07-31 23:35:07.692017900 -0500
@@ -33,3 +33,5 @@
   gem 'rspec-http', '~> 0.9.0'
   gem 'simplecov'
 end
+gem 'bigdecimal'
+

Bash comes usually only by default in Linux distros - although available for pretty much all decent operating systems, Goldberg makes very few uses of the shell, so sticking to plain old 'sh' syntax (symlinked to bash, anyways, on most Linuxes) is more portable:

--- orangenschale.orig/app/models/command.rb    2012-07-12 05:14:44.000000000 -0500
+++ orangenschale/app/models/command.rb 2012-07-15 04:42:22.936706900 -0500
@@ -10,7 +10,7 @@
   end

   def execute
-    command_to_exec = %{/usr/bin/env bash -c "#{@cmd.gsub(/"/, '\"')}"}
+    command_to_exec = %{/usr/bin/env sh -c "#{@cmd.gsub(/"/, '\"')}"}
     Goldberg.logger.info "Executing #{command_to_exec}"
     if block_given?
       yield execute_with_output(command_to_exec), $?.success?
@@ -21,7 +21,7 @@
   end

   def fork
-    command = %{/usr/bin/env bash -c "#{@cmd.gsub(/"/, '\"')}"}
+    command = %{/usr/bin/env sh -c "#{@cmd.gsub(/"/, '\"')}"}
     Goldberg.logger.info "Forking: #{command}"
     @process = ChildProcess.build(command)
     @process.start

Same goes for script/goldberg-build, where the shebang line should use sh, and the 'return -1' statements should be 'return 1' or so - sorry for not having a patch, I wasn't sure if you use -1 specifically for something, ... so just pointing it out.

Hmm. Sounds good on the bash/sh thing. Let me ask our shell scripting expert @gja to pick up that aspect of it. @gja Could you look into this please?

Also, on the bigdecimal thing. Could you tell me what error you get that made you add that gem?

Mh, I don't remember about the bigdecimal - I think bundler literally told me that bigdecimal is not in the bundle. Should I recheck?

Hmm, that's weird. @pahnin had said something similar but nothing fails for me (either locally or on our hosted server). I'll just do some research on this. I wonder if it has something to do with the ruby version being used. What ruby are you running this on?

ruby 1.9.3p194
gem 1.8.24

gja commented

@Cslag, About the bash thing:

While the script itself is not using any BASHisms, rvm is documented not to work with bourne shell or dash (yuck)

Good news. rvm-auto-ruby seems like the new way to run code in a particular ruby, and works pretty much like rbenv shims. Unfortunately, I don't have an rvm machine to test it on.

If we can use rvm-auto-ruby instead of rvm use, then we can get rid of the BASH dependency.

Hm, didn't think about that. But do I really need rvm to run goldberg? Personally, I don't, in my installation, so I guess it's not a requirement.