moovweb / gvm

Go Version Manager
http://github.com/moovweb/gvm
MIT License
10.11k stars 526 forks source link

ERROR: Unrecognized command line argument: 'use' #188

Open ryan-williams opened 8 years ago

ryan-williams commented 8 years ago

After previously having successfully run gvm use go1.6:

$ gvm install go1.5.3
Installing go1.5.3...
 * Compiling...
$ gvm use go1.5.3
ERROR: Unrecognized command line argument: 'use'
$ gvm install go1.4.3
Installing go1.4.3...
 * Compiling...
$ gvm use go1.4.3
ERROR: Unrecognized command line argument: 'use'
$ gvm version
Go Version Manager v1.0.22 installed at /Users/ryan/.gvm
gogames commented 8 years ago

got the same issue, cannot figure out why.

gogames commented 8 years ago

I am deploying go app from fabric and it is something like:

def deploy():
    local('gvm use go1.6')
    # do something to deploy

However it is not able to use specific version go. Please help to resolve this issue.

sebito91 commented 8 years ago

Try this out, I just added it to my config with the same issues and seems to be working now.

FILE: ~/.gvm/scripts/gvm-default

. "$GVM_ROOT/scripts/env/use"

bodepd commented 8 years ago

Running into the same thing here when I try to setup gvm from a bash script.

bodepd commented 8 years ago

I peeked a little more. The issue is in the code that checks to see if subcommands are valid:

if [ -f "$GVM_ROOT/scripts/$command" ];

(looking for scripts/use which doesn't exist, the script does exist at $GVM_ROOT/scripts/env/use)

what is the difference between these two directories?

njappboy commented 8 years ago

Same issue here. When trying to run bash shell scripts via the vagrant non-privileged user (vagrant user). @bodepd did you ever resolve the issue?

mingrammer commented 7 years ago

I have same issue. When i use the 'gvm use' or 'gvm pkgset use' in bash script, the error is occur

SimonXming commented 7 years ago

Are you guys installed 'zsh' version but using in 'bash' or instead?

mcandre commented 7 years ago

Same error on my machine, a fresh macOS 10.12 Sierra install. Using bash 4.4 from Homebrew, and the provided gvm bash curl install command.

I think direnv is getting in the way, see direnv/direnv#128.

bartoszmajsak commented 7 years ago

I'm also struggling with the same problem when trying to use gvm use in the shell script. Workaround which works for me is to source it in the script itself.

[[ -s "$GVM_ROOT/scripts/gvm" ]] && source "$GVM_ROOT/scripts/gvm"
scriptnull commented 7 years ago

Using Ubuntu 14.04 and default terminal.

on executing gvm use go1.4 on terminal, it works.

But fails with the above error, if the command is used in a makefile or shell script.

fubarhouse commented 7 years ago

+1

I've made a wonderful, wonderful Ansible automation role which doesn't seem to work, but executing from the shell works fine. Here's the output - but I really want a solution so I can publish this for the world (and me) to use.

fatal: [localhost]: FAILED! => {
    "changed": true,
    "cmd": "gvm use go1.7.4 --default",
    "delta": "0:00:00.032705",
    "end": "2016-12-20 07:37:11.950701",
    "failed": true,
    "invocation": {
        "module_args": {
            "_raw_params": "gvm use go1.7.4 --default",
            "_uses_shell": true,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "warn": true
        },
        "module_name": "command"
    },
    "rc": 1,
    "start": "2016-12-20 07:37:11.917996",
    "stderr": "ERROR: Unrecognized command line argument: 'use'",
    "stdout": "",
    "stdout_lines": [],
    "warnings": []
}
alonek1 commented 7 years ago

same error here, raspberian works from terminal but not from shell or python code !

liuziyuan commented 6 years ago
#!/bin/sh
mkdir $1
cd $1
gvm pkgset create --local
gvm pkgset use --local
#####

this is a base shell script. has the ERROR: Unrecognized command line argument: 'use' issue. but the gvm pkgset use --local command could run on ubuntu terminal

mosaic101 commented 6 years ago

restart your terminal or

source  ~/.gvm/scripts/gvm
robinmitra commented 5 years ago

This is still happening! Doesn't seem to work in a Makefile even after sourcing gvm.

birdypme commented 5 years ago

restart your terminal or

source  ~/.gvm/scripts/gvm

This fixed my Jenkins build, but having to do it manually looks weird.

Before that I also tried to use a local zsh by adding #!/usr/bin/zsh to my shell script, but I'm still getting the "Unrecognized command line argument: 'use'" message.

imulab commented 1 year ago

Encountering it on v1.0.22

A temporary fix would be to cp ~/.gvm/scripts/env/use ~/.gvm/scripts and give it execution rights.

snxl commented 7 months ago
source  ~/.gvm/scripts/gvm

it works for me

nicklasfrahm commented 1 month ago

None of the suggestions above work for me. I am sourcing the gvm script right after installing it via curl and I am still getting the error. What worked for me was the following:

gvm use "$stable_version" --default >/dev/null || true

It is nasty but works in this context.

mcandre commented 2 weeks ago

Migrated to ASDF. Works beautifully on assorted Unix environments. Supports a wide variety of programming languages and development tools.