dsa-ou / m269-installer

Software installation script and instructions for M269
https://dsa-ou.github.io/m269-installer/
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Spaces in path break installation #12

Closed mwermelinger closed 1 year ago

mwermelinger commented 1 year ago

From an error reported by a tutor, it seems a space in the M269 folder path (e.g. when using OneDrive) causes the Windows m269-23j alias to think there are extra arguments in the command line.

Need to replicate error on Windows and Unix to confirm spaces are an issue. If so, make sure the scripts / aliases handle such path names. Might be as easy as putting " around the path name?

mwermelinger commented 1 year ago

In macOS, if M269 folder path has space, the script exits with error that folder \<name up to first space> doesn't exist.

densnow commented 1 year ago

I think it is the same on Linux: tried to install from /home/<user>/OU/folder with_space/m269-23j and got error:

/home/<user>/OU/folder can't be your M269 folder: it doesn't exist or isn't a folder.
densnow commented 1 year ago

"Quoting" $FOLDER and using double square brackets in the first if statement (inside is_m269_folder()) means that the full path including whitespace is used. E.g

# install.sh line 54
if [[ ! -d $1 ]]
# install.sh line 77
is_m269_folder "$FOLDER"

A further set of quotes is needed around the $1 argument when using basename . E.g.

# install.sh line 57
elif [[ $(basename "$1") != [Mm]269-23[Jj] ]]

The script runs after this, but the whitespace issue reoccurs for the aliases. However, adding some "escaped" quotes appeared to fix the problem.

M269="cd \"$FOLDER\";source $VENV/bin/activate"
NB="jupyter notebook \"$FOLDER\"&"
ALLOWED="python3.10 \"$FOLDER/allowed.py\" -c \"$FOLDER/m269.json\"" 

Maybe something similar could work on Windows, but I have already had my recommended daily dose of Windows today :smile:

mwermelinger commented 1 year ago

Many thanks! I've committed your suggestions. @DanielVernall @cameron-s-scott would one of you be willing to fix and test the Windows script for folder names with spaces?