-
Notifications
You must be signed in to change notification settings - Fork 216
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
Persistent manifest path/context when in a pixi shell
#1038
Comments
I think this would enable all the use-cases I care about (which would allow me to switch to |
It would be nice if it were possible to show (part of) the manifest-path and environment in the prompt of the shell so the user was more aware of which project the shell was associated with. Not necessary, but a nice-to-have IMHO. |
Currently, my shell (macos running zsh with omz) prompt shows me the |
I don't have any pixi info in my prompt but I'm using |
I'm also using starship, project env name will show after entering the env via
notice |
I confirm that works for me! 🚀 Makes sense if you think of opening a shell as being like activating an environment (which it would be if this proposal were implemented!) |
The only question I have is what should happen if you want to run tasks from another 'pixi.toml' that's is not the original activated one :)? |
I think in that case, you would just have to explicitly use the |
Could something like having pixi read from environment variables for manifest path ( Then I quickly tested this by mucking with
pixi on main is 📦 v0.17.1 via 🦀 v1.76.0 took 55s
❯
cargo run info
Finished dev [unoptimized + debuginfo] target(s) in 0.39s
Running `target/debug/pixi info`
Pixi version: 0.17.1
Platform: osx-arm64
Virtual packages: __unix=0=0
: __osx=14.4=0
: __archspec=1=arm64
Cache dir: /Users/akerney/Library/Caches/rattler/cache
Auth storage: /Users/akerney/.rattler/credentials.json
Project
------------
Manifest file: /Users/akerney/Geek/pixi/pixi.toml
Config locations:
Last updated: 22-03-2024 13:46:21
Environments
------------
Environment: default
Features: default
Channels: conda-forge
Dependency count: 11
Dependencies: pre-commit, rust, openssl, pkg-config, git, pytest, jsonschema, pydantic, pyyaml, cffconvert, tbump
Target platforms: linux-64, osx-64, osx-arm64, win-64
Tasks: bump, test-schema, lint, install, build, test, generate-schema, test-all
Environment: docs
Features: docs, default
Channels: conda-forge
Dependency count: 17
Dependencies: mkdocs, mkdocs-material, mdx_truly_sane_lists, pillow, cairosvg, mike, pre-commit, rust, openssl, pkg-config, git, pytest, jsonschema, pydantic, pyyaml, cffconvert, tbump
Target platforms: osx-arm64, osx-64, linux-64, win-64
Tasks: deploy-dev, build-docs, build, bump, generate-schema, install, test-schema, test-all, test, deploy-latest, docs, lint
pixi on main [!] is 📦 v0.17.1 via 🦀 v1.76.0
❯
cargo run shell --manifest-path /Users/akerney/GMRI/NERACOOS/NERACOOS_ERDDAP_K8S/pixi.toml
Compiling pixi v0.17.1 (/Users/akerney/Geek/pixi)
Finished dev [unoptimized + debuginfo] target(s) in 7.21s
Running `target/debug/pixi shell --manifest-path /Users/akerney/GMRI/NERACOOS/NERACOOS_ERDDAP_K8S/pixi.toml`
. "/var/folders/n6/hl07fcc55ys7mbybt01gb8r80000gn/T/pixi_env_M3e.sh"
pixi on main [!] is 📦 v0.17.1 via 🦀 v1.76.0
❯ . "/var/folders/n6/hl07fcc55ys7mbybt01gb8r80000gn/T/pixi_env_M3e.sh"
(sea-eagle)
pixi on main [!] is 📦 v0.17.1 via 🦀 v1.76.0 via 🅒 sea-eagle
❯ pixi info
Pixi version: 0.17.1
Platform: osx-arm64
Virtual packages: __unix=0=0
: __osx=14.4=0
: __archspec=1=arm64
Cache dir: /Users/akerney/Library/Caches/rattler/cache
Auth storage: /Users/akerney/.rattler/credentials.json
Project
------------
Version: 0.1.0
Manifest file: /Users/akerney/GMRI/NERACOOS/NERACOOS_ERDDAP_K8S/pixi.toml
Config locations:
Last updated: 19-03-2024 11:02:21
Environments
------------
Environment: default
Features: default
Channels: conda-forge
Dependency count: 27
Dependencies: python, cftime, dagster-postgres, dagster-k8s, dagster, dask, fsspec, ioos_qc, pandas, pydantic, pystac, python-frontmatter, yaml, requests, sentry-sdk, shapely, xarray, netcdf4, pint, ipykernel, matplotlib, erddapy, uvicorn, xpublish-edr, fastapi, xpublish, xpublish-opendap
Target platforms: osx-arm64
Tasks: install-kernel
(sea-eagle)
pixi on main [!] is 📦 v0.17.1 via 🦀 v1.76.0 via 🅒 sea-eagle
❯ pixi info --manifest-path .
Pixi version: 0.17.1
Platform: osx-arm64
Virtual packages: __unix=0=0
: __osx=14.4=0
: __archspec=1=arm64
Cache dir: /Users/akerney/Library/Caches/rattler/cache
Auth storage: /Users/akerney/.rattler/credentials.json
(sea-eagle)
pixi on main [!] is 📦 v0.17.1 via 🦀 v1.76.0 via 🅒 sea-eagle
❯ pixi info --manifest-path ./pixi.toml
Pixi version: 0.17.1
Platform: osx-arm64
Virtual packages: __unix=0=0
: __osx=14.4=0
: __archspec=1=arm64
Cache dir: /Users/akerney/Library/Caches/rattler/cache
Auth storage: /Users/akerney/.rattler/credentials.json
Project
------------
Manifest file: /Users/akerney/Geek/pixi/pixi.toml
Config locations:
Last updated: 22-03-2024 13:46:21
Environments
------------
Environment: default
Features: default
Channels: conda-forge
Dependency count: 11
Dependencies: pre-commit, rust, openssl, pkg-config, git, pytest, jsonschema, pydantic, pyyaml, cffconvert, tbump
Target platforms: win-64, linux-64, osx-arm64, osx-64
Tasks: lint, generate-schema, test-schema, test-all, bump, install, test, build
Environment: docs
Features: docs, default
Channels: conda-forge
Dependency count: 17
Dependencies: mkdocs, mkdocs-material, mdx_truly_sane_lists, pillow, cairosvg, mike, pre-commit, rust, openssl, pkg-config, git, pytest, jsonschema, pydantic, pyyaml, cffconvert, tbump
Target platforms: linux-64, osx-64, win-64, osx-arm64
Tasks: build-docs, deploy-latest, test-schema, test, docs, generate-schema, build, deploy-dev, lint, test-all, bump, install |
He @abkfenris, this is indeed the simplest version of it, to get some warning however i would like to add some more logic to the discovery code. PR's are welcome! |
Cool! I'll give it a shot. Would It also looks like there is already a |
Nice! @abkfenris Yeah give it an initial try with You can see what pixi is setting in an environment using |
fixes: prefix-dev#1038 Initial attempt to support persistent shell manifest context. When running `pixi shell` the `PIXI_PROJECT_MANIFEST` environment variable is set, and other commands that take `--manifest_path` will read from there. If the environment variable is set, and the path hasn't been overridden, Pixi will emit a warning. `WARN pixi::project: Using manifest `/Users/akerney/GMRI/NERACOOS/NERACOOS_ERDDAP_K8S/pixi.toml` from `PIXI_PROJECT_MANIFEST` environment variable`.
Ok, I've made a draft PR #1055. It's working for subsequent commands, at least until the manifest is changed, and then the environment variable is getting reset after the change and the context is lost. |
fixes: prefix-dev#1038 Using `Project::discover` to detect if Pixi's manifest path has been set by an environment variable in another `pixi shell` instance. `PIXI_IN_SHELL` is also set to be explicit that this should be an activated environment. A warning is emitted before a command when the project is loaded if the discovered path is different from the one given by the environment variable, along with a warning after most commands in case their outputs are longer and scroll the initial warning off the terminal. This is an alternate take on prefix-dev#1055
Problem description
After activating a
pixi shell
, pixi should maintain the context of that shell even if you move to another directory. @baszalmstra described the desired behavior nicely in #1021 (reply in thread):Locking the context of the subshell would allow a user to run commands like
pixi list
,pixi run
, etc from outside of the project directory without having to specify the--manifest-path
flag.It is also desirable that the context should include the specific environment if a non-default env was selected when starting the shell (e.g.
pixi shell -e fooenv
). This is related to #893.The text was updated successfully, but these errors were encountered: