-
Notifications
You must be signed in to change notification settings - Fork 379
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
Update shell_init for nushell #3771
base: main
Are you sure you want to change the base?
Conversation
In nushell, PATH variable is a list, not a string. After load-env, must set $env.PATH to a list.
Perhaps @cvanelteren could help to look at my this PR? It should fix issue on nushell 0.101.0 on mac. But still problematic on windows 11.
|
I approve this msg ;-). On linux I haven't had any issues without this fix however. Can confirm that it should be a list. I dunno how windows uses the path, haven't used in in a while. Where does it put |
Both return When set it to string, nu 0.89.0 on Ubuntu path still works, but nu 0.101.0 on mac will fail. I'm not sure it's nu version issue or OS issue. What I can confirm now is that setting it to list works on both. :P I will feedback more about windows later. |
Hmm strange I am using 0.101.0 and I haven't had any issues yet, but for sure it should be a list. Is the other issue you mentioned related or not? |
I think the issue on windows is more related to the path separator, it's not Thus, However, except the first PATH variable, the other variable has #ask mamba how to setup the environment and set the environment
(^($env.MAMBA_EXE) shell activate --shell nu $name
| str replace --regex '\s+' '' --all
| str replace ';CONDA_' ';;;;CONDA_' --all
| split row ";;;;"
| parse --regex '(.*)=(.+)'
| transpose --header-row
| into record
| load-env
)
$env.Path = $env.PATH | split row (char esep) And The last line also need to use I would submit another PR for win if I figure out why |
Can you open the PR for changes? I think I fixed the issue for you. |
Think I more or less confirmed what go wrong on win:
I could "hack" the script to sth like: def --env "mamba activate" [name: string] {
#add condabin when base env
if $env.MAMBA_SHLVL? == null {
$env.MAMBA_SHLVL = 0
$env.PATH = ($env.PATH | prepend $"($env.MAMBA_ROOT_PREFIX)/condabin")
}
#ask mamba how to setup the environment and set the environment
(^($env.MAMBA_EXE) shell activate --shell nu $name
| str replace ';CONDA_' ';;;;CONDA_' --all
| split row ";;;;"
| parse --regex '(.*) = (.+)'
| transpose --header-row
| into record
| load-env
)
$env.Path = $env.PATH | split row (char esep)
$env.PATH = $env.Path
# update prompt
# if ($env.CONDA_PROMPT_MODIFIER? != null) {
# $env.PROMPT_COMMAND = {|| $env.CONDA_PROMPT_MODIFIER + (do $env.PROMPT_COMMAND_BK)}
# }
}
def --env "mamba deactivate" [] {
#remove active environment except base env
if $env.CONDA_PROMPT_MODIFIER? != null {
# unset set variables
for x in (^$env.MAMBA_EXE shell deactivate --shell nu
| str replace ';CONDA_' ';;;;CONDA_' --all
| str replace ';hide-env' ';;;;hide-env' --all
| split row ";;;;") {
if ("hide-env" in $x) {
hide-env ($x | parse "hide-env {var}").var.0
} else if $x != "" {
let keyValue = ($x
| parse '{key} = {value}'
)
load-env {$keyValue.0.key: $keyValue.0.value}
$env.Path = $env.PATH | split row (char esep)
$env.PATH = $env.Path
}
}
# reset prompt
# $env.PROMPT_COMMAND = $env.PROMPT_COMMAND_BK
}
} And both @cvanelteren I am not sure why you use In above script, I also commented out the part handling prompt, because I'm using starship, which has built in support for conda: https://starship.rs/config/#conda (My hacky script actually will add addition Not sure if it's desired to modify user's prompt in mamba's nushell support. |
This is not the way. I can add my changes if the PR is open for edits which it currently is not. |
I'm not sure how to open this PR for edit, the I've also invited you to my fork, guess that could also let you commit to this PR? @cvanelteren Thank you for the help! |
Can you add write access to your fork, then I can push directly |
hmm it didn't sync the changes. You should have them on the repo however |
Oh nvm it did. Check this build and see if it solves your issue. |
libmamba/src/core/shell_init.cpp
Outdated
@@ -515,7 +516,7 @@ namespace mamba | |||
if $env.CONDA_PROMPT_MODIFIER? != null { | |||
# unset set variables | |||
for x in (^$env.MAMBA_EXE shell deactivate --shell nu | |||
| split row ";") { | |||
| split row (if $nu.os-info.name == "windows" { ";" } else { ";" }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be (if $nu.os-info.name == "windows" { ";" } else { ":" })
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't the separator ; on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah, but the else part, it should be :
, I guess line 519 should be the same as line 500
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right you are correct ;-) Fixed!
See your changes, think it will solve the path separator issue. But No sure why all space need to be removed. In my env, I just use |
Hmm it's been quite some time since I originally wrote this. Not sure why I remove the white spaces. You can merge your changes back in. The main thing I changed is that the problem was that the variables were added always with |
I think the variable assignment requires some cleaning with the white spaces -- at least that is my hunch. |
But feel free to experiment. I think it is pretty close ;-) |
Thank for the help! I will do more testing and learn how to compile C++ project first :) |
Aah yes, the great journey. Let me know if you need more support. Good luck! |
:) Seems support is indeed needed. It's quite fun for me to learn about ninja / cmake / clang etc, and I managed to build mamba on Mac. But, no luck for me to use MSVC to build mamba on win. I've dig into But no luck.
or quickly failed:
Is the quick fail due to invalid cache of sccache? I've no idea how to clean sccache. Still trying to figure out, and once I do. I guess I could send another PR to remove the warning msg: |
Did you follow the instructions on their website: https://mamba.readthedocs.io/en/latest/developer_zone/dev_environment.html |
Yup, so I managed to build on Mac. But their website had make it clear that "These instructions have some inaccuracies on Windows." :), guess MSVC is different from clang, and there is no instruction for building with MSVC. |
You have too many machines ;-)
…On Tue, 28 Jan 2025 at 19:06, Weng Wei ***@***.***> wrote:
Did you follow the instructions on their website:
https://mamba.readthedocs.io/en/latest/developer_zone/dev_environment.html
Yup, so I managed to build on Mac.
But their website had make it clear that "These instructions have some
inaccuracies on Windows." :), guess MSVC is different from clang, and there
is no instruction for building with MSVC.
—
Reply to this email directly, view it on GitHub
<#3771 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEUVDV4XVUSJQU76LEX6YAT2M7BJ7AVCNFSM6AAAAABV6J2DL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJZG4YTQNRTHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
- Casper van Elteren | Computational & Complexity Scientist
- Checkout my website <http://thefriendlyghost.nl> for contact info and
current projects!
|
In nushell, PATH variable is a list, not a string.
Thus, after load-env, must set $env.PATH to a list. Otherwise, all PATH are lost.
Tested on nushell 0.101.0 on mac.