deprec, capserverext, and Ubuntu 6.10 – "sh: [[: not found"

While trying to get Deprec and Capistrano Server Extensions (tutorial) working with Ubuntu 6.10, I ran into a number of hurdles. One was this error when running any variant of deploy (during the svn co command):

** [out :: hostname] sh: [[: not found

Googling got me this thread in the Slicehost forums. Capistrano assumes that the default shell is bash, but that is no longer true for recent versions of Ubuntu. Edgy onwards are apparently using dash as the default.

To fix this, add a task named :set_shell_to_bash to deploy.rb. You can then run this task at the appropriate time using an after_ or before_ callback:


task :after_setup_ssh_keys_for_admin_user do
set_shell_to_bash
end

desc "Make sure the deployment user's shell is bash"
task :set_shell_to_bash do
sudo_with_input "chsh -s `which bash` #{user}"
end

Update: Saimon, the author of Capistrano Server Extensions, informs me that the default shell on Edgy and upwards is not actually dash, something I should have checked before blathering about it.

I’m not sure why my deployment user had dash as the shell, but I will see if I can reproduce the situation.

Advertisements
Leave a comment

4 Comments

  1. Saimon

     /  April 25, 2007

    Hi Mathew,

    Thanks for bringing this to my attention.

    I’ve been investigating and it seems that ubuntu has changed /bin/sh to link to /bin/dash rather than /bin/bash.

    However, after further investigation it still appears that the default login shell for normal users (and root) is /bin/bash (at least in feisty) so I’m still confused as to why your deployment user’s shell was set to dash (perhaps it was just ubuntu 6.10).

    In any case, I like you’re solution and will incorporate it into the next release of capserverext.

    Btw, please let me know of any other issues you came across while using capserverext.

    Regards,

    Saimon

  2. Saimon

     /  April 25, 2007

    Hi Mathew,Thanks for bringing this to my attention.I’ve been investigating and it seems that ubuntu has changed /bin/sh to link to /bin/dash rather than /bin/bash. However, after further investigation it still appears that the default login shell for normal users (and root) is /bin/bash (at least in feisty) so I’m still confused as to why your deployment user’s shell was set to dash (perhaps it was just ubuntu 6.10).In any case, I like you’re solution and will incorporate it into the next release of capserverext.Btw, please let me know of any other issues you came across while using capserverext.Regards,Saimon

  3. Spacen Jasset

     /  May 27, 2007

    Hello,

    I have the same problem. Why does capistrano need to use the [[ keyword anyway, can’t it just use [ instead ?

    sh is more of a ‘standard’ shell and since dash aims/is POSIX conformant wouldn’t that be the way to go. Most rc scripts rely on /bin/sh for this reason too.

    http://en.wikipedia.org/wiki/Debian_Almquist_shell

    Regards,

    Jason

  4. Spacen Jasset

     /  May 27, 2007

    Hello, I have the same problem. Why does capistrano need to use the [[ keyword anyway, can’t it just use [ instead ?sh is more of a ‘standard’ shell and since dash aims/is POSIX conformant wouldn’t that be the way to go. Most rc scripts rely on /bin/sh for this reason too.http://en.wikipedia.org/wiki/Debian_Almquist_shellRegards,Jason

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: