Portability issues / suggestions #143

Open
ghost opened this Issue Aug 1, 2012 · 6 comments

Comments

Projects
None yet
2 participants
@ghost

ghost commented Aug 1, 2012

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.

@srushti

This comment has been minimized.

Show comment Hide comment
@srushti

srushti Aug 1, 2012

Owner

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?

Owner

srushti commented Aug 1, 2012

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?

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Aug 1, 2012

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

ghost commented Aug 1, 2012

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

@srushti

This comment has been minimized.

Show comment Hide comment
@srushti

srushti Aug 1, 2012

Owner

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?

Owner

srushti commented Aug 1, 2012

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?

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Aug 1, 2012

ruby 1.9.3p194
gem 1.8.24

ghost commented Aug 1, 2012

ruby 1.9.3p194
gem 1.8.24

@gja

This comment has been minimized.

Show comment Hide comment
@gja

gja Aug 21, 2012

Contributor

@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.

Contributor

gja commented Aug 21, 2012

@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.

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Aug 21, 2012

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.

ghost commented Aug 21, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment