Is it possible to force %runscript to use /bin/bash instead of /bin/sh?

423 views
Skip to first unread message

Roberto MOSCA

unread,
Oct 11, 2017, 5:02:55 AM10/11/17
to singu...@lbl.gov
Hi,

I am using an Ubuntu xenial based image on which I install conda. To activate a conda environment I need to be able to run "source activate <env_name>" and conda only supports bash.

I have created a %runscript section in my definition file but the corresponding /singularity file that is created uses sh (#!/bin/sh).

Is it possible to tell singularity to use "#!/bin/bash" instead of "#!/bin/sh"?

Apart from this particular case I see many other situation in which a user might prefer to use another shell for their runscript...

Thanks in advance for your help!

Best,
Roberto

Roberto Mosca, PhD
Structural Bioinformatics and Network Biology
Institute for Research in Biomedicine (IRB Barcelona)
C/ Baldiri Reixac 10, 08028 Barcelona, Spain

Email: robert...@irbbarcelona.org :: 
Tel: +34 93 4039689

David Godlove

unread,
Oct 11, 2017, 10:35:35 AM10/11/17
to singu...@lbl.gov
Hi Roberto,

I've run into the same problem with conda environments in the past. The way that I got around it was to explicitly execute my commands with bash in the runscript like so:

%runscript
/bin/bash <<EOF
    echo "some code here"
EOF 

Hope that helps.  

Dave

On Wed, Oct 11, 2017 at 5:02 AM, Roberto MOSCA <robert...@irbbarcelona.org> wrote:
Hi,

I am using an Ubuntu xenial based image on which I install conda. To activate a conda environment I need to be able to run "source activate <env_name>" and conda only supports bash.

I have created a %runscript section in my definition file but the corresponding /singularity file that is created uses sh (#!/bin/sh).

Is it possible to tell singularity to use "#!/bin/bash" instead of "#!/bin/sh"?

Apart from this particular case I see many other situation in which a user might prefer to use another shell for their runscript...

Thanks in advance for your help!

Best,
Roberto

Roberto Mosca, PhD
Structural Bioinformatics and Network Biology
Institute for Research in Biomedicine (IRB Barcelona)
C/ Baldiri Reixac 10, 08028 Barcelona, Spain

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity+unsubscribe@lbl.gov.

Roberto MOSCA

unread,
Oct 11, 2017, 10:55:43 AM10/11/17
to singu...@lbl.gov
Hi Dave,

thanks again for your answer. It is a viable workaround but I still think that it would be good to have an option to select the default shell to be used. I opened an issue in singularity GitHub to start discussing this point. 

Do you know if there is any reason against it? I have to admit I have not such a deep knowledge of the linux shells to foresee potential problems in selecting an alternative shell for the shebang of the entry point script.

Anyway, thanks again for your help, this is really useful!

Kind regards,
Roberto

Roberto Mosca, PhD
Structural Bioinformatics and Network Biology
Institute for Research in Biomedicine (IRB Barcelona)
C/ Baldiri Reixac 10, 08028 Barcelona, Spain

On Wed, Oct 11, 2017 at 4:34 PM, David Godlove <davidg...@gmail.com> wrote:
Hi Roberto,

I've run into the same problem with conda environments in the past. The way that I got around it was to explicitly execute my commands with bash in the runscript like so:

%runscript
/bin/bash <<EOF
    echo "some code here"
EOF 

Hope that helps.  

Dave
On Wed, Oct 11, 2017 at 5:02 AM, Roberto MOSCA <roberto.mosca@irbbarcelona.org> wrote:
Hi,

I am using an Ubuntu xenial based image on which I install conda. To activate a conda environment I need to be able to run "source activate <env_name>" and conda only supports bash.

I have created a %runscript section in my definition file but the corresponding /singularity file that is created uses sh (#!/bin/sh).

Is it possible to tell singularity to use "#!/bin/bash" instead of "#!/bin/sh"?

Apart from this particular case I see many other situation in which a user might prefer to use another shell for their runscript...

Thanks in advance for your help!

Best,
Roberto

Roberto Mosca, PhD
Structural Bioinformatics and Network Biology
Institute for Research in Biomedicine (IRB Barcelona)
C/ Baldiri Reixac 10, 08028 Barcelona, Spain

Email: roberto.mosca@irbbarcelona.org :: 
Tel: +34 93 4039689

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity...@lbl.gov.

Reply all
Reply to author
Forward
0 new messages