Skip to content

Commit

Permalink
Friendly error message for users with special characters in user name…
Browse files Browse the repository at this point in the history
…s on Windows (#200)

* installation on Windows with special characters in user names; issue #199

* check non-ASCII character or a space on Windows during _install_conda

* fix instructions for special characters in your user name
  • Loading branch information
Alexander-Barth authored Jun 25, 2023
1 parent 0a0cc48 commit fe6c94c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,38 @@ pkg> build Conda
Note that Conda.jl 1.6 and above will use miniforge by default on x86_64, aarch64
and ppc64le systems.
## Troubleshooting
### Installation with special characters in user names
If you have a special character in your user name (like an umlaut or an accent) the installation which defaults to
directory `C:\Users\<username>\.julia\Conda\3` will fail on Windows. A space in your user name will also fail on any platform.
This is a [known issue](https://github.com/conda/conda/issues/10239). The work-around is to install Miniconda to a user-writable directory outside of the home directory.
Before installing `Conda.jl`, choose a directory without space and without special characters and set the environment variable `CONDA_JL_HOME` as follows inside a julia session:
```julia
ENV["CONDA_JL_HOME"] = raw"C:\Conda-Julia\3"
using Pkg
Pkg.build("Conda")
```
After restarting Julia, you can verify the new installation directory:
```julia
using Conda
@show Conda.ROOTENV
```
If you use `IJulia` or `PyCall`, they need to be re-build:
```julia
using Pkg
Pkg.build("PyCall")
Pkg.build("IJulia")
```
## Bugs and suggestions
Conda has been tested on Linux, OS X, and Windows.
Expand Down
10 changes: 5 additions & 5 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ USE_MINIFORGE = lowercase(get(ENV, "CONDA_JL_USE_MINIFORGE", DefaultDeps.USE_MIN

if isdir(ROOTENV) && MINICONDA_VERSION != DefaultDeps.MINICONDA_VERSION
error("""Miniconda version changed, since last build.
However, a root enviroment already exists at $(ROOTENV).
Setting Miniconda version is not supported for existing root enviroments.
To leave Miniconda version as, it is unset the CONDA_JL_VERSION enviroment variable and rebuild.
To change Miniconda version, you must delete the root enviroment and rebuild.
WARNING: deleting the root enviroment will delete all the packages in it.
However, a root environment already exists at $(ROOTENV).
Setting Miniconda version is not supported for existing root environments.
To leave Miniconda version as, it is unset the CONDA_JL_VERSION environment variable and rebuild.
To change Miniconda version, you must delete the root environment and rebuild.
WARNING: deleting the root environment will delete all the packages in it.
This will break many Julia packages that have used Conda to install their dependancies.
These will require rebuilding.
""")
Expand Down
17 changes: 17 additions & 0 deletions src/Conda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ _quiet() = get(ENV, "CI", "false") == "true" ? `-q` : ``
function _install_conda(env::Environment, force::Bool=false)
if force || !isfile(Conda.conda)
@assert startswith(abspath(Conda.conda), abspath(PREFIX)) "CONDA_EXE, $(conda), does not exist within $PREFIX"

if (' ' PREFIX) || (Sys.iswindows() && !isascii(PREFIX))
error("""Conda.jl cannot be installed to its default location $(PREFIX)
as Miniconda does not support the installation to a directory with a space or a
non-ASCII character on Windows. The work-around is to install Miniconda to a
user-writable directory by setting the CONDA_JL_HOME environment variable. For
example on Windows:
ENV["CONDA_JL_HOME"] = raw"C:\\Conda-Julia\\3"
using Pkg
Pkg.build("Conda")
The Julia session need to be restarted. More information is available at
https://github.com/JuliaPy/Conda.jl.
""")
end

@info("Downloading miniconda installer ...")
INSTALLER_DIR = tempdir()
if Sys.isunix()
Expand Down

0 comments on commit fe6c94c

Please sign in to comment.