Open csoja opened 8 years ago
Lets use this issue @mingwandroid as a placeholder for any issue related to spaces
I just experienced this issue with Anaconda3 5.0.0 and Python 3 on Windows 10 as described in https://github.com/ContinuumIO/anaconda-issues/issues/1029
What is the status of this issue? One of my students just hit this issue on Windows.
Should be fixed, but really, try not to use paths with spaces if you can avoid it.
The default directory structure and anaconda-installation location on Windows has space in it for the average user. I know not to do this myself, but it is hard to deftly instruct some ~200 high school students in an online course towards this end.
Was there ever a PR that resolved this?
I just tried ignoring the alert about spaces in usernames and following through with the installation. After working for a few hours, Anaconda Prompt ended up losing track of my virtual environments.
Using thinks like C:\Users\CHRISC~1\Anaconda3 as an installation path doesn't work. Installer treats ~ as an illegal character.
Installing as root uses C:\ProgramData\Anaconda3 by default on Windows 10, which solves the issue of spaces in the path. If this continues to work as a temporary solution, I am fine with it.
It looks like the required changes to the Unix installer.sh
are fairly minor. Basically, you just need to tell it to use the bash getopts
built-in rather than the getopt
command (which doesn't handle spaces), add a few missing "
marks, and disable some code that checked for spaces in the prefix.
Here is a minimal hack to illustrate this, which works on my machine. (I just disabled the byte-count check here.)
--- old.sh 2018-11-05 16:35:53.000000000 -0500
+++ new.sh 2018-11-05 16:35:40.000000000 -0500
@@ -76,7 +76,7 @@
-t run package tests after installation (may install conda-build)
"
-if which getopt > /dev/null 2>&1; then
+if false; then
OPTS=$(getopt bfhp:sut "$*" 2>/dev/null)
if [ ! $? ]; then
printf "%s\\n" "$USAGE"
@@ -164,7 +164,7 @@
fi
# verify the size of the installer
-if ! wc -c "$THIS_PATH" | grep 38019315 >/dev/null; then
+if wc -c "$THIS_PATH" | grep 38019319 >/dev/null; then
printf "ERROR: size of %s should be 38019315 bytes\\n" "$THIS_FILE" >&2
exit 1
fi
@@ -297,7 +297,7 @@
fi
fi # !BATCH
-case "$PREFIX" in
+case "PREFIX" in
*\ * )
printf "ERROR: Cannot install into directories with spaces\\n" >&2
exit 1
@@ -342,8 +342,8 @@
fi
PRECONDA="$PREFIX/preconda.tar.bz2"
-bunzip2 -c $PRECONDA | tar -xf - --no-same-owner || exit 1
-rm -f $PRECONDA
+bunzip2 -c "$PRECONDA" | tar -xf - --no-same-owner || exit 1
+rm -f "$PRECONDA"
PYTHON="$PREFIX/bin/python"
MSGS="$PREFIX/.messages.txt"
@@ -364,7 +364,7 @@
fi
PKG_PATH="$PREFIX"/pkgs/$1
PKG="$PKG_PATH".tar.bz2
- mkdir -p $PKG_PATH || exit 1
+ mkdir -p "$PKG_PATH" || exit 1
bunzip2 -c "$PKG" | tar -xf - -C "$PKG_PATH" --no-same-owner || exit 1
"$PREFIX/pkgs/python-3.7.0-hc167b69_0/bin/python" -E -s \
"$PREFIX"/pkgs/.install.py $INST_OPT --root-prefix="$PREFIX" --link-dist="$1" || exit 1
@@ -422,7 +422,7 @@
cat "$MSGS"
rm -f "$MSGS"
-$PYTHON -E -s "$PREFIX/pkgs/.cio-config.py" "$THIS_PATH" || exit 1
+"$PYTHON" -E -s "$PREFIX/pkgs/.cio-config.py" "$THIS_PATH" || exit 1
printf "installation finished.\\n"
if [ "$PYTHONPATH" != "" ]; then
I agree that other command-line tools may have bugs for paths with spaces, but I don't think the installer should refuse to install. Give a warning at most.
(If I wanted to submit a PR for this, where would I submit to? I'm not sure which repo the miniconda installer is in.)
From my current perspective (the amount of collatoral damage this would cause), I'm not sure fixing this is in anyone's best interests.
Are you aware that we do text based prefix replacement in things like bash scripts when necessary? PATHs and env vars?, so a file may contain:
export GDAL_ROOT=/opt/conda/anaconda1anaconda2anaconda3
and we replace that with:
export GDAL_ROOT=/home/Ray Donnelly/anaconda1anaconda2anaconda3
.. what happens when we inspect GDAL_ROOT?
echo $GDAL_ROOT
/home/Ray
Aah oops, ok, you could make a PR to conda to 'fix' this based on detecting the filetype - adding quotes to some files will break them - and suffer the knock-ons but where does it end?
Then you have the issue of Unix tools that we provide that were written with the explicit assumption that spaces would not be supported in file paths. What happens when someone tries to build a conda package using GNU make (one of these tools)? Support requests?
BTW, on Windows, this issue is far less of an issue since Windows software is coded (or the WIndows specific parts are coded) so that spaces in paths work and often so that trivial relocation works. Unforutunately much of the Unix world is oriented towards installing to a known fixed prefix (often space-incompatible) and we are left to deal with that as best we can.
My original complaint was Windows-based. Definitely still an issue.
The trick with Windows is to select “install as root” so that you minimize the chance of spaces in the path.
If you do want to submit a PR the URL is here: https://github.com/conda/constructor
@chrisconlan you didn't provide any reproducible steps for your problem, it's far too nebulous for us to look into as things stand. You say it's definitely still an issue, at what version of Miniconda or Anaconda does that statement stand?
FWIW I don't believe we have a big problem on Windows around spaces, based on my own testing.
If you can provide a simple reproduction case we can try to look into it. You say 'virtualenv' specifically though, do you mean conda environments here?
@chrisconlan if you want to continue this it would be best to open a new issue here and fill in the template details.
I wanted to raise the issue but I don’t have time to gut my Windows machine.
Feel free to ignore me if you don’t think it’s an issue anymore.
Oh I'm not ignoring you, we just have our priorities.
Understood.
Can you answer about the nature of the envs. you had trouble with? Knowing which software (conda, virtualenv, venv, pipenv) caused you trouble is fundamental to being able to fix it;
If I remember correctly, I had just factory reset a windows machine, and I was trying to install Anaconda again.
I opted to install on a user level and not global/root level, which caused Anaconda to install on C:\Users\Chris Conlan\Anaconda3. I got the warning about spaces, but proceeded anyway.
I only used conda environments, not venv or virtualenv, and then I started to notice my conda environments would persist for one session then disappear the next. This was through the Anaconda Promot only, and through activate.bat.
I uninstalled and reinstalled Anaconda as global/root on Windows to C:\ProgramData\Anaconda3 and had no problems.
That’s the best I got. Hope it helps.
Yes, that's helpful, thanks.
I was having similar problems by installing Miniconda in my Users folder (which contains a space). So I did a complete uninstall and reinstalled Miniconda in C:\Miniconda3 (as is suggested here). This new installation should not have anything to do with my User directory, as it is (should be?) completely detached. Yet somehow whenever I try to activate an environment, I get similar errors like this.
Here's my output:
D:\ALL_WORKSPACES\vizwiz-api> conda activate nb
Access is denied.
The system cannot find the file C:\Users\Nilavra.
Could Not Find C:\Users\Nilavra Bhattacharya\AppData\Local\Temp\conda-9484.tmp
D:\ALL_WORKSPACES\vizwiz-api> conda --version
conda 4.6.14
D:\ALL_WORKSPACES\vizwiz-api> where conda
C:\Miniconda3\condabin\conda.bat
C:\Miniconda3\Scripts\conda.exe
Is there still no solution to this? I am tired of updating my conda packages every now and then to see if the issue is fixed. Can this be fixed? How can I help?
It is simple to understand the problem. Bear with me please, I got a brand new laptop, DELL G3 15 with windows 10 preinstalled. I installed chrome and downloaded the LATEST anaconda installer. I opened anaconda prompt not power shell not cmd. I created an environment and activated it. It all worked nice and good, then I restarted my machine (unfortunately) and opened the anaconda prompt but this error was showing:
(base) C:\Users\Jawad Arshad>conda activate
Access is denied.
The system cannot find the file C:\Users\Jawad.
Could Not Find C:\Users\Jawad Arshad\AppData\Local\Temp\conda-17029.tmp
My user profile has a space in it and now I cannot activate any environment. I don't want to make a new user nor do I want to reinstall my windows. I did reinstall anaconda on root but still this issue persists.
Opening the anaconda prompt as an admin gives this error:
@chrisconlan you didn't provide any reproducible steps for your problem, it's far too nebulous for us to look into as things stand. You say it's definitely still an issue, at what version of Miniconda or Anaconda does that statement stand?
FWIW I don't believe we have a big problem on Windows around spaces, based on my own testing.
If you can provide a simple reproduction case we can try to look into it. You say 'virtualenv' specifically though, do you mean conda environments here?
@mingwandroid Hope it is not too nebulous now.
You may have old activate scripts that aren't getting updated for whatever reason when you update conda.
Try running conda init
Our test suite uses paths with spaces throughout, and this should work in conda 4.6.14. The only thing I'm aware of that might break it would be old stuff still lying around somehow. Sometimes I've seen the start menu keep old shortcuts to anaconda prompt, even though new shortcuts have replaced the old on disk. We haven't found a solution to that, other than to use an alternate program for the start menu (https://superuser.com/a/987952/184799). Hacks to refresh the start menu database might work, too: https://superuser.com/questions/955139/some-start-menu-shortcuts-are-missing-on-windows-10/967016#967016
On Sat, Jun 8, 2019, 06:00 Jawad Arshad notifications@github.com wrote:
Is there still no solution to this? I am tired of updating my conda packages every now and then to see if the issue is fixed. Can this be fixed? How can I help?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ContinuumIO/anaconda-issues/issues/716?email_source=notifications&email_token=AAAJL6PTWCWIC4VPCIDABITPZOGMHA5CNFSM4B6U3HV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXHSPWA#issuecomment-500115416, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAJL6IYVAW7HNUQYUJTZZDPZOGMHANCNFSM4B6U3HVQ .
You may have old activate scripts that aren't getting updated for whatever reason when you update conda. Try running
conda init
Our test suite uses paths with spaces throughout, and this should work in conda 4.6.14. The only thing I'm aware of that might break it would be old stuff still lying around somehow. Sometimes I've seen the start menu keep old shortcuts to anaconda prompt, even though new shortcuts have replaced the old on disk. We haven't found a solution to that, other than to use an alternate program for the start menu (https://superuser.com/a/987952/184799). Hacks to refresh the start menu database might work, too: https://superuser.com/questions/955139/some-start-menu-shortcuts-are-missing-on-windows-10/967016#967016 … On Sat, Jun 8, 2019, 06:00 Jawad Arshad @.***> wrote: Is there still no solution to this? I am tired of updating my conda packages every now and then to see if the issue is fixed. Can this be fixed? How can I help? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#716?email_source=notifications&email_token=AAAJL6PTWCWIC4VPCIDABITPZOGMHA5CNFSM4B6U3HV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXHSPWA#issuecomment-500115416>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAJL6IYVAW7HNUQYUJTZZDPZOGMHANCNFSM4B6U3HVQ .
The output of "conda init":
I find it hard to use the information given in the links you have provided. But I did make sure that I have removed everything and installed the anaconda clean again. I face similar problems with the windows cmd.
This is still a problem with the Linux miniconda installer. If $PREFIX has a space in it it half-works and then crashes:
It also incorrectly makes a second folder:
$ ls ..
my/ 'my install dir'/
If -p
has a space in it, the getopt
call in the installer doesn't quote things right and it crashes even sooner:
[tmp.aarljEag68]$ bash Miniconda3-latest-Linux-x86_64.sh -p './path with spaces' -b -f
ERROR: did not recognize option 'with', please try -h
The installer is even aware of the issue but just ignores it:
[...]
if [ "$user_prefix" != "" ]; then
case "$user_prefix" in
*\ * )
printf "ERROR: Cannot install into directories with spaces\\n" >&2
exit 1
;;
*)
eval PREFIX="$user_prefix"
;;
esac
fi
fi # !BATCH
case "$PREFIX" in
*\ * )
printf "ERROR: Cannot install into directories with spaces\\n" >&2
exit 1
;;
esac
[...]
This is the version:
# NAME: Miniconda3
# VER: py38_4.9.2
# PLAT: linux-64
# LINES: 578
# MD5: d84cff5da9dc8f4cd1a947cd13521f66
@kousu I'm seeing exactly the same. I've got the following patch that should fix most of the issues, but not sure where to open a pull request:
--- Miniconda3-latest-Linux-x86_64.sh 2021-05-06 16:31:10.770625898 +0100
+++ Miniconda3-latest-Linux-x86_64.sh 2021-05-06 17:15:56.855432100 +0100
@@ -77,7 +77,7 @@
"
if which getopt > /dev/null 2>&1; then
- OPTS=$(getopt bfhp:sut "$*" 2>/dev/null)
+ OPTS=$(getopt bfhp:sut "$@" 2>/dev/null)
if [ ! $? ]; then
printf "%s\\n" "$USAGE"
exit 2
@@ -348,13 +348,6 @@
fi
fi # !BATCH
-case "$PREFIX" in
- *\ * )
- printf "ERROR: Cannot install into directories with spaces\\n" >&2
- exit 1
- ;;
-esac
-
if [ "$FORCE" = "0" ] && [ -e "$PREFIX" ]; then
printf "ERROR: File or directory already exists: '%s'\\n" "$PREFIX" >&2
printf "If you want to update an existing installation, use the -u option.\\n" >&2
@@ -363,7 +356,6 @@
REINSTALL=1
fi
-
if ! mkdir -p "$PREFIX"; then
printf "ERROR: Could not create directory: '%s'\\n" "$PREFIX" >&2
exit 1
@@ -441,20 +433,20 @@
"$CONDA_EXEC" constructor --prefix "$PREFIX" --extract-tarball < "$POSTCONDA" || exit 1
rm -f "$POSTCONDA"
-rm -f $PREFIX/conda.exe
-rm -f $PREFIX/pkgs/env.txt
+rm -f "$CONDA_EXEC"
+rm -f "$PREFIX/pkgs/env.txt"
-rm -rf $PREFIX/install_tmp
+rm -rf "$PREFIX/install_tmp"
export TMP="$TMP_BACKUP"
-mkdir -p $PREFIX/envs
+mkdir -p "$PREFIX/envs"
if [ -f "$MSGS" ]; then
cat "$MSGS"
fi
rm -f "$MSGS"
# handle .aic files
-$PREFIX/bin/python -E -s "$PREFIX/pkgs/.cio-config.py" "$THIS_PATH" || exit 1
+"$PREFIX/bin/python" -E -s "$PREFIX/pkgs/.cio-config.py" "$THIS_PATH" || exit 1
printf "installation finished.\\n"
if [ "$PYTHONPATH" != "" ]; then
@@ -493,9 +485,9 @@
else
if [[ $SHELL = *zsh ]]
then
- $PREFIX/bin/conda init zsh
+ "$PREFIX/bin/conda" init zsh
else
- $PREFIX/bin/conda init
+ "$PREFIX/bin/conda" init
fi
fi
printf "If you'd prefer that conda's base environment not be activated on startup, \\n"
I think I found the right repository, created a PR: https://github.com/conda/constructor/pull/449
This issue is fixed. Please confirm.
Sorry, it's not fixed yet, or at least the fix hasn't made it to miniconda yet:
And it still mis-creates a spare directory (just named my/
):
There are cases on UNIX where a user wants to be able install Anaconda on a path that has spaces. (@maysonicboom) (Currently the installer does not support this and gives the user the correct warning message.)