Search code examples
shellfish

How to erase a variable set in universal scope in fish shell?


I had set GOROOT as an universal varaible with the command

set -x -U GOROOT /usr/local/go

Which is now causing problems and i want it unset, I did try to erase with set -e GOROOT and several other things, but that only erased for that specific shell session if I started a new session it was still there, could someone help me with this, Im relatively new to Fish.

Output of set --show GOROOT is:

$GOROOT: set in global scope, exported, with 1 elements
$GOROOT[1]: |/usr/local/go/bin/go|

Solution

  • set -e will erase the variable in the lowest scope.

    Since this variable is both universal and exported, you also inherit a global copy from the parent process, and global scope is below universal scope.

    So you need to either erase it twice (once for global, once for universal), or explicitly specify the scope:

    set -e -U GOROOT