How can i Upgrade a package if nix profile is

I have been using Nix with Ubuntu, and I have set up the unstable channel. Likewise

I have some packages and I want to upgrade:

nix-env --upgrade glab
error: profile '/home/avargas/.local/state/nix/profiles/profile' is incompatible with 'nix-env'; please use 'nix profile' instead

For nix profile:

nix profile list | grep glab  -A 1 -B2

Index:              7
Store paths:        /nix/store/w84qk3lfzpk1n74nfsrdyw5kqffs7379-glab-1.37.0

Im not allowed to upgrade

❯ nix profile upgrade nixpkgs#glab
warning: 'nixpkgs#glab' does not match any packages
warning: Use 'nix profile list' to see the current profile.

❯ nix profile upgrade glab
warning: 'glab' does not match any packages
warning: Use 'nix profile list' to see the current profile.

❯ nix profile upgrade unstable#glab
warning: 'unstable#glab' does not match any packages
warning: Use 'nix profile list' to see the current profile.

how can I upgrade packages like glab ?

nix-env is the older style of command for managing profiles; nix profile is the newer style. Once the profile has been changed using nix profile, nix-env can’t be used to manage the profile.

Your guesses all seem reasonable, but unfortunately the command is less than intuitive.

Using the Index in that output of nix profile list would work. i.e.

nix profile upgrade 7

If the nix profile list output shows a Flake attribute, e.g. Flake attribute: legacyPackages.x86_64-linux.gthumb, then that value can also be used as the argument to nix profile upgrade.

thank you for your response but it doesn’t work:

ix profile upgrade 7 --debug
evaluating file '/derivation-internal.nix'
warning: '7' is not a valid index
warning: Use 'nix profile list' to see the current profile.
performing daemon worker op: 40
querying info about missing paths...
starting pool of 24 threads
performing daemon worker op: 46
querying info about missing paths...
starting pool of 24 threads
entered goal loop
created 608 symlinks in user environment
performing daemon worker op: 39
acquiring write lock on '/nix/var/nix/temproots/299831'

Im succesfull doing

nix profile remove 7
nix profile install nixpkgs#glab -I nixpkgs=channel:unstable