Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spaces in filenames cause much confusion and angst #722

Open
o-smirnov opened this issue May 20, 2021 · 0 comments
Open

spaces in filenames cause much confusion and angst #722

o-smirnov opened this issue May 20, 2021 · 0 comments

Comments

@o-smirnov
Copy link
Collaborator

No sane person would put a space into their filename anyway (but it is allowed!), and in this case it wasn't even a legit filename but an error in the config file, but the result was very confusing:

# running cd /home/manaka/masters/.stimela_workdir-1621499929267005 && singularity run --workdir /home/manaka/masters/.stimela_workd
ir-1621499929267005 --containall  --bind /home/manaka/masters/.stimela_workdir-1621499929267005/stimela_parameter_files/listobs_ms0-
14037095377404016214999292730052.json:/stimela_mount/configfile:ro --bind /home/manaka/caracaldir/venv2/lib/python3.6/site-packages/
stimela/cargo/cab/casa_listobs/src:/stimela_mount/code:ro --bind /home/manaka/masters/.stimela_workdir-1621499929267005/passwd:/etc/
passwd:rw --bind /home/manaka/masters/.stimela_workdir-1621499929267005/group:/etc/group:rw --bind /home/manaka/caracaldir/venv2/bin/stimela_runscript:/singularity:ro --bind /home/manaka/masters:/stimela_mount/msdir:rw --bind /home/manaka/masters/input:/stimela_mount/input:ro --bind /home/manaka/masters/test :/stimela_mount/output:rw --bind /home/manaka/masters/test /tmp:/stimela_mount/output/tmp:rw /home/manaka/masters/stimela_casa_1.6.3.sif /singularity
# FATAL:   could not open image /home/manaka/masters/.stimela_workdir-1621499929267005/:/stimela_mount/output:rw: failed to retrieve path for /home/manaka/masters/.stimela_workdir-1621499929267005/:/stimela_mount/output:rw: lstat /home/manaka/masters/.stimela_workdir-1621499929267005/:: no such file or directory

I think the space in the filename is causing the shell to treat a single bind specification as two separate arguments, and that ends up confusing the singularity command.

I think the solution is to invoke xrun with shell=False, because then every item in the argument list is passed as a single argument to the underlying executable, untouched. Running with shell=True ought to be avoided as much as possible anyway. Why have an unnecessary and meddling middleman? There's other "creative" ways in which the shell can screw up our command line. If shell=True is required for whatever reason, then shlex.quote() should be applied to the arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant