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

Install Fails when Directory name has a space in it #3364

Closed
digitaluniverse opened this issue Apr 29, 2021 · 4 comments · Fixed by #3366
Closed

Install Fails when Directory name has a space in it #3364

digitaluniverse opened this issue Apr 29, 2021 · 4 comments · Fixed by #3366
Assignees
Labels
user requested Raised by user on the SCT forum/email/GitHub. Be sure to notify them when fixed in a release.

Comments

@digitaluniverse
Copy link

Description

Install Fails when Directory name has a space in it

Steps to Reproduce

Created a APFS Volume called 'Spine Data'
cd /Volumes/Spine\ Data/
Cloned the Repo to the main directory.
git clone https://github.com/neuropoly/spinalcordtoolbox
cd into spinalcordtoolbox folder
cd spinalcordtoolbox
Run Install
./install_sct
Install to current directory
Y

I just renamed the Volume to 'Spine' to get it working but adding handling for directory names with spaces might be a good idea

@joshuacwnewton joshuacwnewton self-assigned this Apr 29, 2021
@jcohenadad
Copy link
Member

Thank you for reporting this issue @digitaluniverse ! I am linking some related issues below to help the team get more context about how we have been treating this problem up to now:

@joshuacwnewton
Copy link
Member

joshuacwnewton commented Apr 29, 2021

Thank you for opening this issue!

I can reproduce this issue. Below, I've added the full log for ./install_sct -v:

Install log
❯ ./install_sct -v
 Full verbose!
+ getopts :iydbvh opt
+ trap detectKeyboardInterrupt INT
+ trap finish EXIT
+ print info '
*******************************
* Welcome to SCT installation *
*******************************
'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32m
*******************************
* Welcome to SCT installation *
*******************************
\033[0m\n'


*******************************
* Welcome to SCT installation *
*******************************


+ fetch_os_type
+ print info 'Checking OS type and version...'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32mChecking OS type and version...\033[0m\n'

Checking OS type and version...

+ OSver=unknown
++ uname -a
+ uname_output='Linux XPS-15-9560 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux'
+ echo 'Linux XPS-15-9560 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux'
Linux XPS-15-9560 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
+ echo 'Linux XPS-15-9560 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux'
+ grep -i darwin
+ echo 'Linux XPS-15-9560 5.8.0-50-generic #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux'
+ grep -i linux
+ OS=linux
+ check_requirements
+ print info 'Checking requirements...'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32mChecking requirements...\033[0m\n'

Checking requirements...

++ command -v curl
+ [[ -n /usr/bin/curl ]]
+ gcc --version
+ print info 'OK!'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32mOK!\033[0m\n'

OK!

+ [[ -e spinalcordtoolbox/version.txt ]]
++ cat spinalcordtoolbox/version.txt
+ SCT_VERSION=dev
+ [[ -z '' ]]
+ [[ -d .git ]]
+ SCT_INSTALL_TYPE=in-place
+ get_shell_rc_path
+ [[ /usr/bin/zsh == *\b\a\s\h* ]]
+ [[ /usr/bin/zsh == *\/\s\h* ]]
+ [[ /usr/bin/zsh == *\z\s\h* ]]
+ THE_RC=bash
+ RC_FILE_PATH=/home/joshua/.zshrc
+ echo -e '\nSCT version ......... dev'

SCT version ......... dev
+ echo -e 'Installation type ... in-place'
Installation type ... in-place
+ echo -e 'Operating system .... linux (unknown)'
Operating system .... linux (unknown)
+ echo -e 'Shell config ........ /home/joshua/.zshrc'
Shell config ........ /home/joshua/.zshrc
+ REPORT_STATS=no
+ '[' -z '' ']'
+ print question 'To improve user experience and fix bugs, the SCT development team is using a
report system to automatically receive crash reports and errors from users.
These reports are anonymous.

Do you agree to help us improve SCT? [y]es/[n]o: '
+ type=question
+ shift
+ case "$type" in
+ echo -e -n '\n\033[0;92mTo improve user experience and fix bugs, the SCT development team is using a
report system to automatically receive crash reports and errors from users.
These reports are anonymous.

Do you agree to help us improve SCT? [y]es/[n]o: \033[0m'

To improve user experience and fix bugs, the SCT development team is using a
report system to automatically receive crash reports and errors from users.
These reports are anonymous.

Do you agree to help us improve SCT? [y]es/[n]o: + read -r REPORT_STATS
n
+ [[ n =~ [Yy](es)? ]]
+ print info '--> Crash reports will not be sent.'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32m--> Crash reports will not be sent.\033[0m\n'

--> Crash reports will not be sent.

+ [[ in-place == \i\n\-\p\l\a\c\e ]]
+ SCT_DIR='/home/joshua/Desktop/Test Directory/spinalcordtoolbox'
+ true
+ keep_default_path=
+ [[ ! '' =~ ^([Yy](es)?|[Nn]o?)$ ]]
+ print info 'SCT will be installed here: [/home/joshua/Desktop/Test Directory/spinalcordtoolbox]'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32mSCT will be installed here: [/home/joshua/Desktop/Test Directory/spinalcordtoolbox]\033[0m\n'

SCT will be installed here: [/home/joshua/Desktop/Test Directory/spinalcordtoolbox]

+ keep_default_path=yes
+ '[' -z '' ']'
+ print question '
Do you agree? [y]es/[n]o: '
+ type=question
+ shift
+ case "$type" in
+ echo -e -n '\n\033[0;92m
Do you agree? [y]es/[n]o: \033[0m'


Do you agree? [y]es/[n]o: + read -r keep_default_path
y
+ [[ ! y =~ ^([Yy](es)?|[Nn]o?)$ ]]
+ [[ y =~ ^[Yy] ]]
+ break
+ add_to_path=
+ [[ ! '' =~ ^([Yy](es)?|[Nn]o?)$ ]]
+ add_to_path=yes
+ '[' -z '' ']'
+ print question 'Do you want to add the sct_* scripts to your PATH environment? [y]es/[n]o: '
+ type=question
+ shift
+ case "$type" in
+ echo -e -n '\n\033[0;92mDo you want to add the sct_* scripts to your PATH environment? [y]es/[n]o: \033[0m'

Do you want to add the sct_* scripts to your PATH environment? [y]es/[n]o: + read -r add_to_path
n
+ [[ ! n =~ ^([Yy](es)?|[Nn]o?)$ ]]
+ mkdir -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox'
+ [[ -d /home/joshua/Desktop/Test Directory/spinalcordtoolbox ]]
+ [[ ! -w /home/joshua/Desktop/Test Directory/spinalcordtoolbox ]]
+ [[ bash == \b\a\s\h ]]
+ DISPLAY_UPDATE_PATH='export PATH="/home/joshua/Desktop/Test Directory/spinalcordtoolbox/bin:$PATH"'
+ [[ -z '' ]]
+ export MPLBACKEND=Agg
+ MPLBACKEND=Agg
+ [[ /home/joshua/Desktop/Test Directory/spinalcordtoolbox != \/\h\o\m\e\/\j\o\s\h\u\a\/\D\e\s\k\t\o\p\/\T\e\s\t\ \D\i\r\e\c\t\o\r\y\/\s\p\i\n\a\l\c\o\r\d\t\o\o\l\b\o\x ]]
+ print info 'Skipping copy of source files (source and destination folders are the same)'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32mSkipping copy of source files (source and destination folders are the same)\033[0m\n'

Skipping copy of source files (source and destination folders are the same)

+ [[ -x /home/joshua/Desktop/Test Directory/spinalcordtoolbox/bin ]]
+ cd '/home/joshua/Desktop/Test Directory/spinalcordtoolbox'
+ [[ ! -f spinalcordtoolbox/version.txt ]]
+ print info 'Installing conda...'
+ type=info
+ shift
+ case "$type" in
+ echo -e '\n\033[0;32mInstalling conda...\033[0m\n'

Installing conda...

+ run rm -rf '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python'
+ print code rm -rf '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python'
+ type=code
+ shift
+ case "$type" in
+ echo -e '\n\033[0;34mrm -rf /home/joshua/Desktop/Test Directory/spinalcordtoolbox/python\033[0m\n'

rm -rf /home/joshua/Desktop/Test Directory/spinalcordtoolbox/python

+ rm -rf '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python'
+ run mkdir -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python'
+ print code mkdir -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python'
+ type=code
+ shift
+ case "$type" in
+ echo -e '\n\033[0;34mmkdir -p /home/joshua/Desktop/Test Directory/spinalcordtoolbox/python\033[0m\n'

mkdir -p /home/joshua/Desktop/Test Directory/spinalcordtoolbox/python

+ mkdir -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python'
+ case $OS in
+ download /tmp/tmp.B02ywAbuYm/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
+ command -v wget
+ run wget -O /tmp/tmp.B02ywAbuYm/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
+ print code wget -O /tmp/tmp.B02ywAbuYm/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
+ type=code
+ shift
+ case "$type" in
+ echo -e '\n\033[0;34mwget -O /tmp/tmp.B02ywAbuYm/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh\033[0m\n'

wget -O /tmp/tmp.B02ywAbuYm/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

+ wget -O /tmp/tmp.B02ywAbuYm/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
--2021-04-29 13:09:07--  https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8203, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 94235922 (90M) [application/x-sh]
Saving to: ‘/tmp/tmp.B02ywAbuYm/miniconda.sh’

/tmp/tmp.B02ywAbuYm 100%[===================>]  89.87M  8.78MB/s    in 11s     

2021-04-29 13:09:18 (8.53 MB/s) - ‘/tmp/tmp.B02ywAbuYm/miniconda.sh’ saved [94235922/94235922]

+ run bash /tmp/tmp.B02ywAbuYm/miniconda.sh -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python' -b -f
+ print code bash /tmp/tmp.B02ywAbuYm/miniconda.sh -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python' -b -f
+ type=code
+ shift
+ case "$type" in
+ echo -e '\n\033[0;34mbash /tmp/tmp.B02ywAbuYm/miniconda.sh -p /home/joshua/Desktop/Test Directory/spinalcordtoolbox/python -b -f\033[0m\n'

bash /tmp/tmp.B02ywAbuYm/miniconda.sh -p /home/joshua/Desktop/Test Directory/spinalcordtoolbox/python -b -f

+ bash /tmp/tmp.B02ywAbuYm/miniconda.sh -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python' -b -f
ERROR: did not recognize option 'Directory/spinalcordtoolbox/python', please try -h
+ die 'ERROR: Command failed.'
+ print error 'ERROR: Command failed.'
+ type=error
+ shift
+ case "$type" in
+ echo -e '\n\033[0;31mERROR: Command failed.\033[0m\n'

ERROR: Command failed.

+ exit 1
+ finish
+ value=1
+ cd '/home/joshua/Desktop/Test Directory/spinalcordtoolbox'
+ [[ 1 -eq 0 ]]
+ [[ 1 -eq 99 ]]
+ print error 'Installation failed!\n
Please copy the output of this Terminal (starting with the command install_sct) and upload it as a .txt attachment in a new topic on SCT'\''s forum:\n
--> http://forum.spinalcordmri.org/c/sct'
+ type=error
+ shift
+ case "$type" in
+ echo -e '\n\033[0;31mInstallation failed!\n
Please copy the output of this Terminal (starting with the command install_sct) and upload it as a .txt attachment in a new topic on SCT'\''s forum:\n
--> http://forum.spinalcordmri.org/c/sct\033[0m\n'

Installation failed!

Please copy the output of this Terminal (starting with the command install_sct) and upload it as a .txt attachment in a new topic on SCT's forum:

--> http://forum.spinalcordmri.org/c/sct

+ rm -rf /tmp/tmp.B02ywAbuYm
+ exit 1

The culprit is this line:

https://github.com/neuropoly/spinalcordtoolbox/blob/35e914cd99f6f8750e648a109f63318520cf91c0/install_sct#L587-L588

Which results in:

> bash /tmp/tmp.B02ywAbuYm/miniconda.sh -p '/home/joshua/Desktop/Test Directory/spinalcordtoolbox/python' -b -f
ERROR: did not recognize option 'Directory/spinalcordtoolbox/python', please try -h

The environment variable appears to be properly enclosed in double-quotes, but because the value is being used as an argument, I believe we need to add a second set of quotes.

> echo "$TEST_DIRECTORY"
/home/joshua/Desktop/Test Directory
> echo ""$TEST_DIRECTORY""  # Note: Nesting double-quotes doesn't work
/home/joshua/Desktop/Test Directory
> echo '"$TEST_DIRECTORY"'  # Note: Nesting ' and " this way doesn't substitute the env variable
"$TEST_DIRECTORY"
> echo "'$TEST_DIRECTORY'"
'/home/joshua/Desktop/Test Directory'

However, when I try this, I get the following new error:

> bash Miniconda3-latest-Linux-x86_64.sh -p "'$TEST_DIRECTORY'" -b -f
ERROR: Cannot install into directories with spaces

So, even if we fix the quotes, we won't be able to get around this on Anaconda's end. From the -h of the miniconda script:

> bash Miniconda3-latest-Linux-x86_64.sh -h

usage: Miniconda3-latest-Linux-x86_64.sh [options]

Installs Miniconda3 py38_4.9.2

-b           run install in batch mode (without manual intervention),
             it is expected the license terms are agreed upon
-f           no error if install prefix already exists
-h           print this help message and exit
-p PREFIX    install prefix, defaults to /home/joshua/miniconda3, must not contain spaces.
-s           skip running pre/post-link/install scripts
-u           update an existing installation
-t           run package tests after installation (may install conda-build)

There is an open issue on Anaconda's end for this here: ContinuumIO/anaconda-issues#716

@jcohenadad
Copy link
Member

thank you for doing all the digging @joshuacwnewton 🙏

@joshuacwnewton
Copy link
Member

joshuacwnewton commented Apr 29, 2021

I like the idea proposed in #2785.

Checking $SCT_DIR for spaces earlier on would let us catch the issue before spending time downloading the Miniconda script, and would allow us to give a clearer explanation for why spaces are not permitted (e.g. by linking to the Anaconda issue).

I can open up a PR for this to close both issues.

@joshuacwnewton joshuacwnewton added the user requested Raised by user on the SCT forum/email/GitHub. Be sure to notify them when fixed in a release. label Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user requested Raised by user on the SCT forum/email/GitHub. Be sure to notify them when fixed in a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants