This small fix prepends the `INCLUDE` environment variable instead of
overriding it.
This is important if one has already added paths to this environment,
for example, in cases where one needs a common set of codebase that gets
included in all C/C++ projects (such as utility functions and such).
nu_msvs doesn't work at all on my setup, vswhere return empty string
when called from nushell, the only way i made it to work is calling it
from powershell
on json parsing side
installationPath is not an array, and vswhere return an array of
installations is not correct
e.g
```json
[
{
"instanceId": "406fd398",
"installDate": "2024-04-25T13:16:29Z",
"installationName": "VisualStudioPreview/17.14.0-pre.5.0+36025.13",
"installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Preview",
"installationVersion": "17.14.36025.13",
"productId": "Microsoft.VisualStudio.Product.BuildTools",
"productPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Preview\\Common7\\Tools\\LaunchDevCmd.bat",
"state": 4294967295,
"isComplete": true,
"isLaunchable": true,
"isPrerelease": true,
"isRebootRequired": false,
"displayName": "Visual Studio Build Tools 2022",
"description": "Visual Studio Build Tools vous permet de générer des applications MSBuild natives et managées sans passer par l'IDE Visual Studio. Il existe des options pour installer les compilateurs et bibliothèques Visual C++, ainsi que la prise en charge d'ATL, de MFC et de C++/CLI.",
"channelId": "VisualStudio.17.Preview",
"channelUri": "https://aka.ms/vs/17/pre/channel",
"enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
"installedChannelId": "VisualStudio.17.Preview",
"installedChannelUri": "https://aka.ms/vs/17/pre/channel",
"releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=661273#17.14.0-pre.5.0",
"resolvedInstallationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Preview",
"thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288",
"updateDate": "2025-04-29T20:49:54.8401699Z",
"catalog": {
"buildBranch": "d17.14",
"buildVersion": "17.14.36025.13",
"id": "VisualStudioPreview/17.14.0-pre.5.0+36025.13",
"localBuild": "build-lab",
"manifestName": "VisualStudioPreview",
"manifestType": "installer",
"productDisplayVersion": "17.14.0 Preview 5.0",
"productLine": "Dev17",
"productLineVersion": "2022",
"productMilestone": "Preview",
"productMilestoneIsPreRelease": "True",
"productName": "Visual Studio",
"productPatchVersion": "0",
"productPreReleaseMilestoneSuffix": "5.0",
"productSemanticVersion": "17.14.0-pre.5.0+36025.13",
"requiredEngineVersion": "3.14.2074.57458"
},
"properties": {
"campaignId": "",
"channelManifestId": "VisualStudio.17.Preview/17.14.0-pre.5.0+36025.13",
"includeRecommended": "0",
"nickname": "",
"setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe"
}
}
]
```
This PR updates the `modules/virtual_environments/nu_conda_2/conda.nu`
script to address several issues encountered with newer versions of
Mamba/Conda and Nushell.
**Problem:**
The existing script failed when used with recent Mamba versions (e.g.,
Mamba 2.x) due to changes in the JSON output format of `mamba info
--json`. Specifically:
* The key for environment directories is now `"envs directories"`
instead of `"envs_dirs"`.
* The key for the base environment path is now `"base environment"`
instead of `"root_prefix"`.
* The `mamba info --envs --json` command returns minimal information,
requiring separate calls to `mamba info --json` to get necessary details
like `envs_dirs` and `root_prefix`.
Additionally, several Nushell syntax errors were present:
* Incorrect syntax for assigning the result of a multi-branch `if/else`
expression to a variable using `let`.
* Incorrect usage of `run-external`, attempting to pass flags like
`--json` directly instead of as separate string arguments.
* The `--no-banner` flag is not supported by `mamba info`.
These issues resulted in errors like `Cannot find column 'envs_dirs'`,
`Could not find environment named '...'`, `keyword_missing_arg`, and
`unknown_flag`.
**Solution:**
This PR implements the following fixes:
1. **Updated `load-conda-info-env`:**
* Detects Mamba/Conda/Micromamba correctly.
* For Mamba, makes separate calls to `mamba info --json` and `mamba info
--envs --json`.
* Explicitly extracts `envs_dirs` and `root_prefix` using the correct
key names (`"envs directories"`, `"base environment"`) observed in Mamba
2.x output.
* For Conda, assumes `conda info --json` provides all necessary keys
(`envs_dirs`, `root_prefix`, `envs`).
* Includes basic logic for Micromamba (parsing text output).
* Constructs the `$env.CONDA_INFO` record reliably with the required
keys.
2. **Corrected Nushell Syntax:**
* Fixed the `let cmd_base = ...` assignment by wrapping the `if/else`
expression in parentheses `()`.
* Fixed all `run-external` calls to pass the command and arguments as
separate strings (e.g., `run-external "mamba" "info" "--json"`).
3. **Removed Unsupported Flag:** Removed `--no-banner` from `mamba info`
calls.
4. **Improved Error Handling:** Added checks in `activate` to ensure
`$env.CONDA_INFO` was loaded successfully. Changed `error make` to
`print --stderr` and `return null` in `check-if-env-exists` for
potentially smoother failure modes.
5. **Minor Improvements:** Cleaned up PATH manipulation, improved the
completer function, added comments.
**Testing:**
This version has been tested successfully with:
* Mamba 2.1.0
* Nushell 0.103.0
* Activating environments by name (`activate myenv`) and by full path
(`activate /path/to/myenv`).
* Deactivating environments (`deactivate`).
It should also work correctly with standard Conda installations.
Micromamba support is based on the original script's logic and may
require further testing.
Fixes issues like those encountered during the debugging session leading
to this PR.
Noticed an issue in `conda.nu`.
It modified `$env.PATH` from list of string to a string, without
**expanding** it. It may be a problem if I have a path which is
relative:
```nushell
$env.PATH = ($env.PATH | split row (char esep) | prepend '~/.cargo/bin')
```
After activating an env, it's impossible to find executables in
`~/.cargo/bin`. So this pr is going to make sure the path is expanded
while converting.
For more context:
https://github.com/nushell/nushell/pull/14615?notification_referrer_id=NT_kwDOAVOaGrQxMzkwODcxMjU3NjoyMjI1NjE1NA#issuecomment-2552696978
Just as a heads up, I haven't really tested this since a lot of it is
stuff I don't use or know how to set up without some reading up. I have
tested the nu_conda_2 change since I have a python project that I use
that for, and I could look into testing more of it if needed.
I've tried finding (naively using `/sys\W/`) all the usage of the old
plain `sys` calls and replacing them with alternates as appropriate,
which mostly has been to swap a `(sys).host.name` call into a
`$nu.os-info.name` one, since it'll be tad faster and more consistent
across platforms with naming (especially as the value comes from the
[rust stdlib](https://doc.rust-lang.org/std/env/consts/constant.OS.html)
and is very predictable).
Fixes#897
I like to activate nu_msvs in my config by default and don't need a
message that tells me the command has been run when doing this. This
commit adds a --silent option so there's no message displayed when
running the command.
This PR makes the location of vswhere more programmatic by looking where
it's supposed to be located on the file system instead of relying on it
being in your path.
I changed `export-env {}` at the beginning to a custom command to avoid
having `export-env` run when loading the module
because:
1. I couldn't use `nu_msvs activate` because it depends on env vars
being set that were hidden with `nu_msvs deactivate`
2. It seems that `export-env` executed at `use`, leaves `$env.FILE_PWD`
available in the environment which I think may be
a bug. So, putting it in a custom command avoids that.
This updates the nu_msvs module. There were several things that I didn't
think looked proper for Windows so I changed them an hopefully made this
module a tiny bit better.
1. fix: update `(sys).host` to `sys host` to work for 0.94.x
2. fix: handle incorrect behaviors when re-importing nu_conda or nu_msvs
3. doc: update minimum requirements of nushell in README.md
This PR is part of porting all old scripts #221 and includes the
`virtual_environments` module
## 5 files changed
- `conda.nu`: removed, already in
`modules/virtual_enviromnents/conda/nu_conda.nu`
- `conda_deactivate.nu`: also removed, has already been merged with
`nu_conda.nu`
- `README.nu`: removed, similar info in
`modules/virtual_enviromnents/README.md`
- `venv.nu`: ported to `modules/virtual_enviromnents/venv/venv.nu`
- `venv_deactivate.nu`: ported to
`modules/virtual_enviromnents/venv/venv_deactivate.nu`
I used [typos](https://github.com/crate-ci/typos/).
I manually checked all the corrections and they seem safe to me.
There are still some left, but those in this PR are good
I wasn't sure if this was on purpose or not but the conda environments
were simply "activate" and "deactivate" instead of "conda activate" and
"conda deactivate" as they would be normally in bash/zsh.
Due to the potential name conflicts I think it's better to leave these
as the more specific `conda activate` and let the user define an alias
in their file with `alias activate = conda activate`
I initially tried to get Micromamba to work with Nushell by using the
script from [this
issue](https://github.com/nushell/nu_scripts/issues/578). But even after
fixing the syntax errors I couldn't activate any env.
With these modifications, Micromamba seems to be working fine.
Please note that I'm far from a Nu expert so my code might not be very
idiomatic. If that is the case please tell me so and I'll be happy to do
the necessary changes.
I have been using the script myself for a while, so I am fairly
confident that it works. I would prefer if I could make mamba activate
work out of the box but putting aliases in the file doesn't seem to
work, so If anyone knows how to make that work, that would be great.
1. feat(nu_conda): add `nu_conda list` to list available envs
2. fix: use `print` instead of `echo` to print warnings
3. doc: change minimum support version to 0.83.0
* refactor: ✨ move in one commit
Eveything in modules should probably be changed to `exported` defs.
The idea is to move everything first to keep proper history.
* refactor: 📝 add modules readme (wip)
* refactor: ✨ small move
* refactor: 📝 changed nestring, updated modules readme
* refactor: 📝 to document or not to document
* fix: 🐛 themes
replaced the template to use `main` and regenerated them
from lemnos themes.
* Revert "fix: 🐛 themes"
This reverts commit 4918d3633c8d2d81950a0ed0cfd9eb84241bc886.
* refactor: ✨ introduce sourced
- Created a source `root` in which sourcable demos are stored.
Some might get converted to modules later on.
- Moved some files to bin too.
* fix: 🐛 fehbg.nu
* fix: 🐛 modules/after.nu
* moved some other stuff around
---------
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>