sigoden/argc

windows 下执行 ./bin/argc shell:setup powershell 没有效果

MinatoHikari opened this issue · 24 comments

已经设置 ARGC_SHELL_PATH 为 scoop 下的 git-bash.exe 路径

Do you have the ARGC_SHELL_PATH set correctly?

If you have installed git using scoop, the bash path should be C:\Users\alice\scoop\shims\bash.exe

You can add the following code to the $PROFILE:

$env:ARGC_SHELL_PATH = $env:USERPROFILE + '\scoop\shims\bash.exe'

Do you have the ARGC_SHELL_PATH set correctly?

If you have installed git using scoop, the bash path should be C:\Users\alice\scoop\shims\bash.exe

You can add the following code to the $PROFILE:

$env:ARGC_SHELL_PATH = $env:USERPROFILE + '\scoop\shims\bash.exe'

Yes, I have set the ARGC_SHELL_PATH, and Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete in $PROFILE

fnm env --use-on-cd | Out-String | Invoke-Expression
set HTTP_PROXY=http://127.0.0.1:7890
set HTTPS_PROXY=http://127.0.0.1:7890
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Import-Module posh-git

After running ./bin/argc shell:setup powershell in git-bash, nothing was changed in $PROFILE

argc shell:setup powershell merely generates a guide and code for configuring PowerShell, which you need to manually copy into the $PROFILE.

Did you successfully execute the command ./bin/argc shell:setup powershell?

image

Did you successfully execute the command ./bin/argc shell:setup powershell?

image

After adding these code it works.
But each time I press tab windows terminal will popup a git-bash window to run the completion, it takes about 1s and really annoying

weird, it only happends when using pnpm, other commands are fine.

I have never encountered the problem you mentioned.

argc-completions-07

Try running pnpm in git-bash and see if it also pops up a window

Try running pnpm in git-bash and see if it also pops up a window

It also popup.
vim ~/.profile

export ARGC_COMPLETIONS_ROOT='/c/projects/github/argc-completions'
export ARGC_COMPLETIONS_PATH='/c/projects/github/argc-completions/completions'
alias argc='/c/projects/github/argc-completions/bin/argc.exe'
source <(argc --argc-completions bash pnpm)

run pnpm --help in git-bash (do not tirgger tab completion, just run it), does it pops up a window? @MinatoHikari

run pnpm --help in git-bash (do not tirgger tab completion, just run it), does it pops up a window? @MinatoHikari

no.

Can you take a screenshot for me to debug? @MinatoHikari

Is it possible that the version of Bash is causing syntax incompatibilities? @MinatoHikari

$ cat Argcfile.sh 
#!/usr/bin/env bash

set -e

# @cmd
ls() {
    echo To implement command: ls
}

eval "$(argc --argc-eval "$0" "$@")"

Create Argcfile.sh file as above, then run argc --help in powershell, check if there are any similar errors.

If there's the same error, please print the version information of bash

 $ bash --version
GNU bash, version 5.2.15(1)-release (x86_64-pc-msys)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

@sigoden
There is same error.
My bash version is 5.2.21(1)-release (x86_64-pc-msys)

I have also tested with the scoop version of bash and was unable to reproduce the issue. @MinatoHikari
image

Your situation is very strange. Bash should not throw this syntax error.

I opened a Windows Sandbox, retried all the processes, and did not find any issues.

Try reinstalling git and argc-completions。 About the issue with git-bash on your system. I'm really out of ideas.

Sorry.

我这里语言采用了beta unicode utf-8, 因为path里有中文,有没有可能是这个引起的

I'm not sure. The scripts in the completions directory can all be run with bash, such as bash ./completions/pnpm.sh.

You can debug it yourself.

@sigoden
我把 .sh 文件内的 ls() 改成 function ls
不再报错,但是还是会弹出一个 git bash --login -i 的弹窗,导致提示非常慢

Will running the following command throw an error? @MinatoHikari

 bash -c 'ls() { echo run ls; }; ls'

you can directly download pnpm.sh and execute it in the bash, to see if there are any errors. @MinatoHikari

If there are no problems, then it's your git encoding problem

@sigoden 找到问题了,ARGC_SHELL_PATH 错误设置成了 git-bash.exe.

搜索到这个问题,设置好 windows terminal 以后又去检查了一下这个环境变量,发现写错了

microsoft/terminal#13317