Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install gvm lead to cd commad failed #439

Open
sheepcat opened this issue Aug 17, 2023 · 4 comments
Open

install gvm lead to cd commad failed #439

sheepcat opened this issue Aug 17, 2023 · 4 comments

Comments

@sheepcat
Copy link

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# rpm -qa |grep bash
bash-4.2.46-34.el7.x86_64

i install gvm by this way :
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

after installd, i logout and relogin , found cd cmd failed:
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /
[root@localhost ~]# pwd
/root

when i delete the dir, it recoverd:
rm -rf /root/.gvm/

@goFrendiAsgard
Copy link

I got a similar issue.

Can you please confirm the value of your $PATH before and after installing gvm?

echo $PATH

In my case, I have a PATH containing space that accidentally replaced by :

https://twitter.com/gofrendiasgard/status/1695596852127941055

@codingcn
Copy link

same issues

/home/chris/.gvm/bin:/home/chris/.config/nvm/versions/node/v14.21.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:/usr/local/go/bin:/home/chris/go/bin
chris@chris-PC:~$ type cd
cd 是函数
cd () 
{ 
    if __gvm_is_function __gvm_oldcd; then
        __gvm_oldcd $*;
    fi;
    local dot_go_version dot_go_pkgset rslt;
    local defaults_go_name defaults_go_pkgset;
    local defaults_resolved=false;
    local defaults_hash;
    defaults_hash=();
    if [[ "$GVM_ROOT" == "" ]]; then
        display_error "GVM_ROOT not set. Please source \$GVM_ROOT/scripts/gvm";
        return $?;
    fi;
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Resolving defaults...";
    defaults_hash=($(__gvm_read_environment_file "${GVM_ROOT}/environments/default"));
    if [[ $? -eq 0 ]]; then
        defaults_resolved=true;
    else
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Can't find default environment. Falling back to system.";
        defaults_hash=($(__gvm_read_environment_file "${GVM_ROOT}/environments/system"));
        if [[ $? -eq 0 ]]; then
            defaults_resolved=true;
        else
            [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Can't find system environment.";
        fi;
    fi;
    if [[ "${defaults_resolved}" == false ]]; then
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Resolving fallback go version and pkgset from all available.";
        local fallback_go_version="$(__gvm_resolve_fallback_version)";
        local fallback_go_pkgset="$(__gvm_resolve_fallback_pkgset "${fallback_go_version}")";
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "=======================================";
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "fallback_go_version => $fallback_go_version";
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "fallback_go_pkgset => $fallback_go_pkgset";
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "=======================================";
        defaults_hash=($(setValueForKeyFakeAssocArray "gvm_go_name" "${fallback_go_version}" "${defaults_hash[*]}"));
        defaults_hash=($(setValueForKeyFakeAssocArray "gvm_pkgset_name" "${fallback_go_pkgset}" "${defaults_hash[*]}"));
        unset fallback_go_version;
        unset fallback_go_pkgset;
        defaults_resolved=true;
    fi;
    defaults_go_name="$(valueForKeyFakeAssocArray "gvm_go_name" "${defaults_hash[*]}")";
    defaults_go_pkgset="$(valueForKeyFakeAssocArray "gvm_pkgset_name" "${defaults_hash[*]}")";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "defaults_go_name => $defaults_go_name";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "defaults_go_pkgset => $defaults_go_pkgset";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    if [[ "${GVM_DEBUG}" -eq 1 ]]; then
        echo "Resolved default go: ${defaults_go_name:-[EMPTY]}";
        echo "Resolved default pkgset: ${defaults_go_pkgset:-[EMPTY]}";
    fi;
    dot_go_version="$(__gvmp_find_closest_dot_go_version)";
    rslt=$?;
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "---------------------------------------";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "dot_go_version => $dot_go_version";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "defaults_go_name => $defaults_go_name";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "---------------------------------------";
    if [[ $rslt -eq 0 ]]; then
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Found dot_go_version: ${dot_go_version}";
        local use_goversion="$(__gvmp_read_dot_go_version "${dot_go_version}")";
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Switching to: ${use_goversion}";
        gvm use "${use_goversion}" || return 1;
        unset use_goversion;
    else
        if [[ -n "${defaults_go_name}" ]]; then
            [[ "${GVM_DEBUG}" -eq 1 ]] && echo "No .go-version found. Using system or default go.";
        else
            if [[ "${GVM_DEBUG}" -eq 1 ]]; then
                echo "No fallback go version could be found.";
                if [[ ! -d "$GVM_ROOT/archive/go" ]]; then
                    echo "$(locale_text_for_key "go_install_prompt")";
                fi;
            fi;
            return 0;
        fi;
    fi;
    dot_go_pkgset="$(__gvmp_find_closest_dot_go_pkgset)";
    rslt=$?;
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "--------------------------------";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "dot_go_pkgset => $dot_go_pkgset";
    [[ "${GVM_DEBUG}" -eq 1 ]] && echo "--------------------------------";
    if [[ $rslt -eq 0 ]]; then
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Found .go-pkgset: ${dot_go_pkgset}";
        local use_gopkgset="$(__gvmp_read_dot_go_pkgset "${dot_go_pkgset}")";
        [[ "${GVM_DEBUG}" -eq 1 ]] && echo "Switching to: ${use_gopkgset}";
        gvm pkgset use "${use_gopkgset}" || return 1;
        unset use_gopkgset;
    else
        if [[ -n "${defaults_go_pkgset}" ]]; then
            [[ "${GVM_DEBUG}" -eq 1 ]] && echo "No .go-pkgset found. Using system or default pkgset.";
            [[ "${GVM_DEBUG}" -eq 1 ]] && echo "----------    defaults_go_pkgset => $defaults_go_pkgset     ----------";
        else
            [[ "${GVM_DEBUG}" -eq 1 ]] && echo "No fallback pkgset could be found.";
        fi;
    fi;
    return 0
}

@clanaid
Copy link

clanaid commented Sep 5, 2023

how to fix it?

@ankitcharolia
Copy link

@clanaid @codingcn @sheepcat : Kindly try out this one. this supports bash and zsh both shells : https://github.com/ankitcharolia/goenv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants