When running overlay use .venv/bin/activate.nu, the following spews into stderr;
Error: nu::shell::env_var_not_a_string
× 'PATH' is not representable as a string.
╭─[/home/paperdev/coding/py/project/.venv/bin/activate.nu:57:30]
56 │ let new_env = {
57 │ $path_name : $new_path
· ────┬────
· ╰── value not representable as a string
58 │ VIRTUAL_ENV : $virtual_env
╰────
help: The 'PATH' environment variable must be a string or be convertible to a string.
Either make sure 'PATH' is a string, or add a 'to_string' entry for it in ENV_CONVERSIONS.
In this state, I can only call deactivate.
We instead, expect to see the following:
❯ overlay use .venv/bin/activate.nu
❯ which python3
╭───┬─────────┬────────────────────────────────────────────────────┬──────────╮
│ # │ command │ path │ type │
├───┼─────────┼────────────────────────────────────────────────────┼──────────┤
│ 0 │ python3 │ /home/paperdev/coding/py/project/.venv/bin/python3 │ external │
╰───┴─────────┴────────────────────────────────────────────────────┴──────────╯
Environment
Provide at least:
OS: NixOS through WSL2
Shell: Nushell version 0.95
pip list of the host python where virtualenv is installed:
❯ python3 -m pip list
/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3: No module named pip
❯ lol
❯ which virtualenv | get 0.path
/nix/store/27p5s7kgpw5kkwaypx5rx7cyjlbhgc9s-python3.12-virtualenv-20.26.2/bin/virtualenv
**Output of the virtual environment creation**
( I am certain this has zero relevance to this bug, but I'll add it as it's part of the template)
```console
❯ virtualenv .venv -vvv --with-traceback
131 setup logging to NOTSET [DEBUG report:36]
135 find interpreter for spec PythonSpec(path=/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12) [INFO builtin:72]
136 filesystem is case-sensitive [DEBUG info:25]
136 proposed PythonInfo(spec=CPython3.12.4.final.0-64, exe=/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12, platform=linux, version='3.12.4 (main, Jun 6 2024, 18:26:44) [GCC 13.3.0]', encoding_fs_io=utf-8-utf-8) [INFO builtin:79]
136 accepted PythonInfo(spec=CPython3.12.4.final.0-64, exe=/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12, platform=linux, version='3.12.4 (main, Jun 6 2024, 18:26:44) [GCC 13.3.0]', encoding_fs_io=utf-8-utf-8) [DEBUG builtin:81]
177 create virtual environment via CPython3Posix(dest=/home/paperdev/coding/py/project/.venv, clear=False, no_vcs_ignore=False, global=False) [INFO session:50]
178 create folder /home/paperdev/coding/py/project/.venv/bin [DEBUG _sync:12]
178 create folder /home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages [DEBUG _sync:12]
179 write /home/paperdev/coding/py/project/.venv/pyvenv.cfg [DEBUG pyenv_cfg:33]
179 home = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin [DEBUG pyenv_cfg:38]
179 implementation = CPython [DEBUG pyenv_cfg:38]
179 version_info = 3.12.4.final.0 [DEBUG pyenv_cfg:38]
179 virtualenv = 20.26.2 [DEBUG pyenv_cfg:38]
179 include-system-site-packages = false [DEBUG pyenv_cfg:38]
179 base-prefix = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4 [DEBUG pyenv_cfg:38]
179 base-exec-prefix = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4 [DEBUG pyenv_cfg:38]
179 base-executable = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12 [DEBUG pyenv_cfg:38]
180 symlink /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12 to /home/paperdev/coding/py/project/.venv/bin/python [DEBUG _sync:32]
180 create virtualenv import hook file /home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages/_virtualenv.pth [DEBUG api:91]
180 create /home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages/_virtualenv.py [DEBUG api:94]
180 ============================== target debug ============================== [DEBUG session:52]
181 debug via /home/paperdev/coding/py/project/.venv/bin/python /nix/store/27p5s7kgpw5kkwaypx5rx7cyjlbhgc9s-python3.12-virtualenv-20.26.2/lib/python3.12/site-packages/virtualenv/create/debug.py [DEBUG creator:200]
180 {
"sys": {
"executable": "/home/paperdev/coding/py/project/.venv/bin/python",
"_base_executable": "/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12",
"prefix": "/home/paperdev/coding/py/project/.venv",
"base_prefix": "/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4",
"real_prefix": null,
"exec_prefix": "/home/paperdev/coding/py/project/.venv",
"base_exec_prefix": "/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4",
"path": [
"/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/site-packages",
"/nix/store/27p5s7kgpw5kkwaypx5rx7cyjlbhgc9s-python3.12-virtualenv-20.26.2/lib/python3.12/site-packages",
"/nix/store/287fcmw9m2f1i5m14x9035jgvs323gih-python3.12-distlib-0.3.8/lib/python3.12/site-packages",
"/nix/store/z1mkigwrlmb617k2j1zfl76ld6yyamsj-python3.12-filelock-3.15.1/lib/python3.12/site-packages",
"/nix/store/lfkvfwrg6cqj6zhk2cnfhmq2xbcczhl4-python3.12-platformdirs-4.2.2/lib/python3.12/site-packages",
"/nix/store/2zklsq0l0s055dmdzkygrsx5hcf31vj4-python3.12-ruff-lsp-0.0.54/lib/python3.12/site-packages",
"/nix/store/mjb4mvqf4rmfam62w3j4094ghadgwvxp-python3.12-packaging-24.1/lib/python3.12/site-packages",
"/nix/store/c67mp90ld90fvlxyw10h72klijcrvb7d-python3.12-pygls-1.3.1/lib/python3.12/site-packages",
"/nix/store/kcvvc57vq30hk99vpx7s80l614s0jcr9-python3.12-lsprotocol-2023.0.1/lib/python3.12/site-packages",
"/nix/store/kmizj06riwf7lf5h9dap31qdch91qaxm-python3.12-attrs-23.2.0/lib/python3.12/site-packages",
"/nix/store/sy2bgrv7dfiyr4279mm5g28bsibnlf4h-python3.12-cattrs-23.2.3/lib/python3.12/site-packages",
"/nix/store/c2739vy5hwhxjn0l41c5xx7mr5j11jp9-python3.12-typeguard-4.3.0/lib/python3.12/site-packages",
"/nix/store/566nvy79f5arsnlgbsiwb4cyjxy1sw60-python3.12-typing-extensions-4.12.2/lib/python3.12/site-packages",
"/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python312.zip",
"/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12",
"/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/lib-dynload",
"/home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages"
],
"meta_path": [
"<class '_virtualenv._Finder'>",
"<class '_frozen_importlib.BuiltinImporter'>",
"<class '_frozen_importlib.FrozenImporter'>",
"<class '_frozen_importlib_external.PathFinder'>"
],
"fs_encoding": "utf-8",
"io_encoding": "utf-8"
},
"version": "3.12.4 (main, Jun 6 2024, 18:26:44) [GCC 13.3.0]",
"makefile_filename": "/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/config-3.12-x86_64-linux-gnu/Makefile",
"os": "<module 'os' (frozen)>",
"site": "<module 'site' (frozen)>",
"datetime": "<module 'datetime' from '/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/datetime.py'>",
"math": "<module 'math' from '/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/lib-dynload/math.cpython-312-x86_64-linux-gnu.so'>",
"json": "<module 'json' from '/nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/lib/python3.12/json/__init__.py'>"
} [DEBUG session:53]
199 add seed packages via FromAppData(download=False, pip=bundle, via=copy, app_data_dir=/home/paperdev/.local/share/virtualenv) [INFO session:57]
200 got embed update of distribution %s from ('pip', PosixPath('/home/paperdev/.local/share/virtualenv/wheel/3.12/embed/3/pip.json')) [DEBUG via_disk_folder:131]
201 got embed update of distribution %s from ('pip', PosixPath('/home/paperdev/.local/share/virtualenv/wheel/3.12/embed/3/pip.json')) [DEBUG via_disk_folder:131]
201 install pip from wheel /nix/store/27p5s7kgpw5kkwaypx5rx7cyjlbhgc9s-python3.12-virtualenv-20.26.2/lib/python3.12/site-packages/virtualenv/seed/wheels/embed/pip-24.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:49]
201 Attempting to acquire lock 139751853049088 on /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any.lock [DEBUG _api:320]
201 Lock 139751853049088 acquired on /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any.lock [DEBUG _api:323]
202 Attempting to release lock 139751853049088 on /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any.lock [DEBUG _api:353]
202 Lock 139751853049088 released on /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any.lock [DEBUG _api:356]
202 copy /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any/pip-24.0.virtualenv to /home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages/pip-24.0.virtualenv [DEBUG _sync:40]
202 copy directory /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any/pip-24.0.dist-info to /home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages/pip-24.0.dist-info [DEBUG _sync:40]
204 copy directory /home/paperdev/.local/share/virtualenv/wheel/3.12/image/1/CopyPipInstall/pip-24.0-py3-none-any/pip to /home/paperdev/coding/py/project/.venv/lib/python3.12/site-packages/pip [DEBUG _sync:40]
334 generated console scripts pip3.12 pip3 pip pip-3.12 [DEBUG base:43]
334 add activators for Bash, CShell, Fish, Nushell, PowerShell, Python [INFO session:63]
338 write /home/paperdev/coding/py/project/.venv/pyvenv.cfg [DEBUG pyenv_cfg:33]
338 home = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin [DEBUG pyenv_cfg:38]
338 implementation = CPython [DEBUG pyenv_cfg:38]
338 version_info = 3.12.4.final.0 [DEBUG pyenv_cfg:38]
338 virtualenv = 20.26.2 [DEBUG pyenv_cfg:38]
338 include-system-site-packages = false [DEBUG pyenv_cfg:38]
339 base-prefix = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4 [DEBUG pyenv_cfg:38]
339 base-exec-prefix = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4 [DEBUG pyenv_cfg:38]
339 base-executable = /nix/store/z7xxy35k7620hs6fn6la5fg2lgklv72l-python3-3.12.4/bin/python3.12 [DEBUG pyenv_cfg:38]
339 created virtual environment CPython3.12.4.final.0-64 in 208ms
creator CPython3Posix(dest=/home/paperdev/coding/py/project/.venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, via=copy, app_data_dir=/home/paperdev/.local/share/virtualenv)
added seed packages: pip==24.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator [WARNING __main__:19]
Solution
src/virtualenv/activation/nushell/activate.nu --- Text
44 ) 44 )
45 45
46 let venv_path = ([$virtual_env $bin] | path join) 46 let venv_path = ([$virtual_env $bin] | path join)
47 let new_path = ($env | get $path_name | prepend $venv_path) 47 let new_path = ($env | get $path_name | prepend $venv_path | str join ':')
48 48
49 # If there is no default prompt, then use the env name instead 49 # If there is no default prompt, then use the env name instead
50 let virtual_env_prompt = (if ('__VIRTUAL_PROMPT__' | is-empty) { 50 let virtual_env_prompt = (if ('__VIRTUAL_PROMPT__' | is-empty) {
Issue
When running overlay use .venv/bin/activate.nu
, the following spews into stderr;In this state, I can only call
deactivate
.We instead, expect to see the following:
Environment
Provide at least:
pip list
of the host python wherevirtualenv
is installed:❯ which virtualenv | get 0.path /nix/store/27p5s7kgpw5kkwaypx5rx7cyjlbhgc9s-python3.12-virtualenv-20.26.2/bin/virtualenv
Solution