task icon indicating copy to clipboard operation
task copied to clipboard

Doesn't work while trying to source script providing required functions

Open anton-fomin opened this issue 2 years ago • 1 comments

  • Task version: v3.7.0 (h1:8dDFv12/Lxi6PHkYNIIm7N6v6oRGxePpLK67LuMh/Rs=)
  • Operating System: linux

Prerequisites

Install NVM as described here https://github.com/nvm-sh/nvm#installing-and-updating

Example Taskfile showing the issue

version: '3'

tasks:
  nvm-install:
    cmds:
      - |
        [ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm";
        [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh";
        [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh";
        nvm install

The problem

It doesn't work

> task nvm-install
task: [nvm-install] [ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm";
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh";
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh";
nvm install

task: Failed to run task "nvm-install": exit status 3

I tried to replace . with source without any change. -verbose doesn't give any additional information.

That is required for my workflow to make sure the commands run with correct node version

anton-fomin avatar Aug 18 '21 12:08 anton-fomin

This may be an issue with mvdan/sh which is the shell parser that Go is using

ghostsquad avatar May 16 '22 00:05 ghostsquad

I just tried using go-task for the first time on a project and immediately ran into this problem with not being able to source the nvm.sh POSIX script in a go-task task definition ... :disappointed:

Did you ever find a way to make nvm work with go-task?

cwegener avatar May 25 '23 07:05 cwegener