soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
6.94k stars 391 forks source link

Problem when running Trans in the windows 10 bash app , "Translator not found" #376

Closed huangjiaqi1997 closed 3 years ago

huangjiaqi1997 commented 3 years ago

I installed the gcc/make component with mingw, and installed translate-shell from Git. However, it seems that if I enter any trans command, the following will be prompted. Why?

$ trans -V [ERROR] Translator not found: google Run '-list-engines / -S' to see a list of available engines.

$ trans -list-engines [ERROR] Translator not found: google Run '-list-engines / -S' to see a list of available engines.

Thank you.

soimort commented 3 years ago

Can you check the actual path and size of trans (by using which trans, ls -l or alike)?

huangjiaqi1997 commented 3 years ago

Yes

$ which trans
/usr/local/bin/trans
$ ls -l
total 100
drwxr-xr-x 1 1 197609     0 11月  2 20:30 build/
-rwxr-xr-x 1 1 197609 11601  5月 11 23:02 build.awk*
-rw-r--r-- 1 1 197609   921  5月 11 23:02 CONTRIBUTING.md
-rw-r--r-- 1 1 197609   315  5月 11 23:02 Dockerfile
-rw-r--r-- 1 1 197609  2142  5月 11 23:02 google-translate-mode.el
drwxr-xr-x 1 1 197609     0  5月 11 23:02 include/
-rw-r--r-- 1 1 197609  1211  5月 11 23:02 LICENSE
-rw-r--r-- 1 1 197609  1121  5月 11 23:02 Makefile
drwxr-xr-x 1 1 197609     0  5月 11 23:02 man/
-rw-r--r-- 1 1 197609   304  5月 11 23:02 metainfo.awk
-rw-r--r-- 1 1 197609 31664  5月 11 23:02 README.md
-rw-r--r-- 1 1 197609 14007  5月 11 23:02 README.template.md
drwxr-xr-x 1 1 197609     0  5月 11 23:02 test/
-rwxr-xr-x 1 1 197609  2292  5月 11 23:02 test.awk*
-rwxr-xr-x 1 1 197609   527 11月  2 20:31 translate*
-rwxr-xr-x 1 1 197609   424  5月 11 23:02 translate.awk*
-rwxr-xr-x 1 1 197609    57  5月 11 23:02 translate-shell.plugin.zsh*
-rw-r--r-- 1 1 197609   883  5月 11 23:02 WAIVER
drwxr-xr-x 1 1 197609     0  5月 11 23:02 wiki/
soimort commented 3 years ago

The size of trans?

huangjiaqi1997 commented 3 years ago

Is it this one?

1@LAPTOP-H24M967K MINGW64 /d/code/translate-shell-stable/build
$ ls -l
total 160
-rwxr-xr-x 1 1 197609 160269 11月  2 20:31 trans*
soimort commented 3 years ago

Is it this one?

I mean the size of /usr/local/bin/trans, not the current folder.

soimort commented 3 years ago

But in any case, please try ./translate -V (in the git directory) first and see if it works.

huangjiaqi1997 commented 3 years ago
$ ls -l /usr/local/bin/trans
-rwxr-xr-x 1 1 197609 160269 11月  2 20:58 /usr/local/bin/trans*
soimort commented 3 years ago

Does ./translate -V work then?

huangjiaqi1997 commented 3 years ago

But in any case, please try ./translate -V (in the git directory) first and see if it works.

$ ./translate -V
[WARNING] Your locale codeset (zh_CN.UTF-8@cjknarrow) is not UTF-8.
[ERROR] Translator not found: google
        Run '-list-engines / -S' to see a list of available engines.
soimort commented 3 years ago

Please repeat the following steps and report the result to me at once:

$ git clone https://github.com/soimort/translate-shell
$ cd translate-shell/
$ ./translate -V
$ make
$ build/trans -V
huangjiaqi1997 commented 3 years ago
1@LAPTOP-H24M967K MINGW64 /d/code/translate-shell-stable - 副本 - 副本
$ ./translate -V
[WARNING] Your locale codeset (zh_CN.UTF-8@cjknarrow) is not UTF-8.
Translate Shell       0.9.6.12

platform              MINGW64_NT-10.0-18363
terminal type         xterm
bi-di emulator        [N/A]
gawk (GNU Awk)        5.0.0
fribidi (GNU FriBidi) [NOT INSTALLED]
audio player          [NOT INSTALLED]
terminal pager        less
web browser           xdg-open
user locale           zh_CN.UTF-8@cjknarrow (Chinese Simplified)
home language         zh-CN
source language       auto
target language       zh-CN
translation engine    google
proxy                 [NONE]
user-agent            Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
ip version            [DEFAULT]
theme                 default
init file             [NONE]

Report bugs to:       https://github.com/soimort/translate-shell/issues

1@LAPTOP-H24M967K MINGW64 /d/code/translate-shell-stable - 副本 - 副本
$ make
[OK] Task build completed.

1@LAPTOP-H24M967K MINGW64 /d/code/translate-shell-stable - 副本 - 副本
$ build/trans -V
[ERROR] Translator not found: google
        Run '-list-engines / -S' to see a list of available engines.
huangjiaqi1997 commented 3 years ago

When I execute git clone https://github.com/soimort/translate-shell, git bash reports an error,

$ git clone https://github.com/soimort/translate-shell
Cloning into 'translate-shell'...
remote: Enumerating objects: 93, done.
remote: Counting objects: 100% (93/93), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 4668 (delta 47), reused 65 (delta 33), pack-reused 4575
Receiving objects: 100% (4668/4668), 2.53 MiB | 1.03 MiB/s, done.
Resolving deltas: 100% (2976/2976), done.
error: invalid path 'include/Translators/*.awk'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

So, I downloaded the stable branch on github and used this

soimort commented 3 years ago

Ok, then it's a corrupted clone you're building from.

I've heard that filenames with special characters (i.e. *.awk) are supported on NTFS in POSIX namespace, but clearly not in this case. That's the reason git clone got you a corrupted repository...

One possible way to circumvent this restriction is to set the flag

$ git config core.protectNTFS false

Please test if this works. (do the git clone again after setting the above flag)

huangjiaqi1997 commented 3 years ago
1@LAPTOP-H24M967K MINGW64 /d/code
$ git clone https://github.com/soimort/translate-shell
Cloning into 'translate-shell'...
remote: Enumerating objects: 93, done.
remote: Counting objects: 100% (93/93), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 4668 (delta 47), reused 65 (delta 33), pack-reused 4575
Receiving objects: 100% (4668/4668), 2.53 MiB | 21.00 KiB/s, done.
Resolving deltas: 100% (2976/2976), done.
error: invalid path 'include/Translators/*.awk'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

1@LAPTOP-H24M967K MINGW64 /d/code
$ cd translate-shell

1@LAPTOP-H24M967K MINGW64 /d/code/translate-shell (develop)
$ git config core.protectNTFS false

1@LAPTOP-H24M967K MINGW64 /d/code/translate-shell (develop)
$ git restore --source=HEAD :/
error: unable to create file include/Translators/*.awk: Invalid argument

I used git config --global core.protectNTFS false, but it still doesn't work:

1@LAPTOP-H24M967K MINGW64 /d/code
$ git config --global core.protectNTFS false

1@LAPTOP-H24M967K MINGW64 /d/code
$ git clone https://github.com/soimort/translate-shell
Cloning into 'translate-shell'...
remote: Enumerating objects: 93, done.
remote: Counting objects: 100% (93/93), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 4668 (delta 47), reused 65 (delta 33), pack-reused 4575
Receiving objects: 100% (4668/4668), 2.53 MiB | 1.58 MiB/s, done.
Resolving deltas: 100% (2976/2976), done.
error: unable to create file include/Translators/*.awk: Invalid argument
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
soimort commented 3 years ago

Thanks for the information. I'll probably have to get rid of those special filenames in the repository then.