mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
Fix conda script on windows (#198)
* Fix conda script on windows * Check first the casing of the path env var
This commit is contained in:
parent
048017afea
commit
3660f37ea8
2 changed files with 9 additions and 5 deletions
|
@ -2,7 +2,7 @@ def conda-env [env-name] {
|
|||
let conda-info = (conda info --envs --json | from json)
|
||||
let suffix = (if $env-name == "base" {""} else {(["envs" $env-name] | path join)})
|
||||
let env-dir = ([$conda-info.root_prefix $suffix] | path join)
|
||||
let old-path = ($env.PATH | str collect (path-sep))
|
||||
let old-path = ((system-path) | str collect (path-sep))
|
||||
let new-path = (if (windows?) { (conda-create-path-windows $env-dir) } else { (conda-create-path-unix $env-dir) })
|
||||
let new-env = {
|
||||
CONDA_DEFAULT_ENV: $env-name
|
||||
|
@ -15,8 +15,7 @@ def conda-env [env-name] {
|
|||
}
|
||||
|
||||
def conda-create-path-windows [env-dir] {
|
||||
# 1. Conda on Windows needs a few additional Path elements
|
||||
# 2. The path env var on Windows is called Path (not PATH)
|
||||
# Conda on Windows needs a few additional Path elements
|
||||
let env-path = [
|
||||
$env-dir
|
||||
([$env-dir "Scripts"] | path join)
|
||||
|
@ -24,7 +23,7 @@ def conda-create-path-windows [env-dir] {
|
|||
([$env-dir "Library" "bin"] | path join)
|
||||
([$env-dir "Library" "usr" "bin"] | path join)
|
||||
]
|
||||
let new-path = ([$env-path $env.PATH] | flatten | str collect (path-sep))
|
||||
let new-path = ([$env-path (system-path)] | flatten | str collect (path-sep))
|
||||
{
|
||||
PATH: $new-path
|
||||
}
|
||||
|
@ -40,10 +39,15 @@ def conda-create-path-unix [env-dir] {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
def windows? [] {
|
||||
(sys).host.name == "Windows"
|
||||
}
|
||||
|
||||
def system-path [] {
|
||||
if "PATH" in (env).name { $env.PATH } else { $env.Path }
|
||||
}
|
||||
|
||||
def path-sep [] {
|
||||
if (windows?) { ";" } else { ":" }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
let path-name = (if ((sys).host.name == "Windows") { "Path" } else { "PATH" })
|
||||
let path-name = (if "PATH" in (env).name { "PATH" } else { "Path" })
|
||||
let-env $path-name = $env.CONDA_OLD_PATH
|
||||
hide CONDA_PROMPT_MODIFIER
|
||||
hide CONDA_PREFIX
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue