Search code examples
shellubuntufish

Fish shell error


I installed nvm which inserted some lines to my .profile, I modified them to work with fish shell instead of bash:

if [ "$BASH" ]
  if [ -f ~/.bashrc ]
    . ~/.bashrc
  end
end

mesg n or true

export NVM_DIR="/root/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] and . "$NVM_DIR/nvm.sh"  # This loads nvm

.. but I still get this error:

root@server011 ~# source /root/.profile
[: the last argument must be ']'

Solution

  • There is a missing semicolon:

    [ -s "$NVM_DIR/nvm.sh" ] ; and . "$NVM_DIR/nvm.sh"
                             ^
    

    I'm not sure if nvm.sh is fish-compatible. If it is not, fish won't be able to source it.

    In that case, you might try fnm or this plugin.