Cygwin 錯誤 - 無法執行「/bin/bash」:沒有這樣的檔案或目錄

Cygwin 錯誤 - 無法執行「/bin/bash」:沒有這樣的檔案或目錄

C:\Cygwin64我剛剛在 Windows 7 上下載並安裝了 Cygwin。但是,按一下桌面捷徑打開mintty.exe,然後顯示錯誤:

無法運行“/bin/bash”:沒有這樣的檔案或目錄

儘管事實上我安裝了所有基本文件,其中bash應該是的一部分 - 即使不是,安裝程式後來將其顯示為必需的套件並自行安裝。那麼有人知道這裡發生了什麼事嗎?這可能是我在最後一天嘗試成功安裝 Cygwin 的第四次嘗試;我開始覺得我不應該擁有它。

答案1

我設法透過另一個安裝對此進行排序 - 這次我選擇從網路下載並安裝(安裝程式中的選項 1),而不是單獨下載檔案並從本地儲存的資料夾安裝(選項 2 和 3)。我不確定為什麼選擇這些選項會給我帶來不完整的安裝,但我現在可以bash毫無錯誤地運行。

答案2

直接從網路進行預設全新安裝後,我遇到了同樣的問題。

我通過轉到“C:\cygwin64\bin”並複製“ash.exe”並將副本重命名為“bash.exe”來解決它。

(我純粹是偶然嘗試這個,只是因為缺少 bash 並且我發現了這個不祥的 ash 檔案)

答案3

問題

如果您願意,可以跳到下面查看這兩個解決方案,尤其是第二個,它對我有用。

我剛剛在恢復電腦的損壞部分後遇到了這個問題(在目錄System32損壞之後 - 哎呀!)這種事情以前發生過(由於其他情況),我仍然有C:\cygwin64包含資料夾的目錄,並且至少其他一些文件仍然存在。

以前,我總是能夠透過運行簡單地重新安裝setup-x86_64.exe(我把我的放在C:\cygwin64)。之後,bash就會回來。我總是使用線上選項來運行它https://mirrors.kernel.org,但即使我只bash在安裝 GUI 中選擇,我也會遇到這個問題,儘管我的錯誤出現為

/bin/bash: Exit 126.
Failed to run '/bin/bash': No such file or directory

Cygwin 終端機(模擬器)帶有上面指定的文本,即“/bin/bash: Exit 126. Failed to run '/bin/bash': No such file or directory”

檢查我的bin目錄表明,確實bash丟失了。從命令提示字元 ( CMD)

C:\Windows\System32>C:\cygwin64\Cygwin
'bash' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>dir C:\cygwin64\bin\bas*
 Volume in drive C is ██████████
 Volume Serial Number is ██████████

 Directory of C:\cygwin64\bin

File Not Found

C:\cygwin64\bin>

請注意,我通常透過以下任一方式運行 Cygwin:

  1. 使用桌面捷徑,與從 (Windows) 命令提示字元執行以下命令相同
C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -

或者

  1. 使用該Cygwin.bat文件。我將首先顯示文件內容,然後顯示我嘗試運行它的結果。
C:\Windows\System32>type C:\cygwin64\Cygwin.bat
@echo off

C:
chdir C:\cygwin64\bin

bash --login -i

C:\Windows\System32>C:\cygwin64\Cygwin
'bash' is not recognized as an internal or external command,
operable program or batch file.

C:\cygwin64\bin>

第一個(失敗的嘗試)解決方案

尋找bash-<version>.tar.xz

我之前從 下載過https://mirrors.kernel.org,所以我有一個資料夾,

C:\cygwin64\http%3a%2f%2fmirrors.kernel.org%2fsourceware%2fcygwin%2f

進一步探索,我發現了一個名為bash-4.4.12-3.tar.xz的tarball

C:\cygwin64\http%3a%2f%2fmirrors.kernel.org%2fsourceware%2fcygwin%2f\x86_64\release\bash

製作完整路徑

C:\cygwin64\http%3a%2f%2fmirrors.kernel.org%2fsourceware%2fcygwin%2f\x86_64\release\bash\bash-4.4.12-3.tar.xz

我最終打開了這個7zip,雖然你可以使用WinRAR或其他類似的東西。

(我對 Windows 上現在如何使用它進行了一些咆哮tar,但使用它對提取不起作用。你可以看到咆哮這裡如果您想了解有關Windows 10 的tar更多curl資訊)我將 tarball 複製/貼上到桌面,然後右鍵單擊並選擇「展開到」兩次以了解內部內容。我將所有內容複製到

C:\Users\bballdave025\Desktop\bash-4.4.12-3\

這時我可以看看裡面有什麼。然後,我將內部檔案的位置與執行 Cygwin 的電腦上的檔案位置進行比較。我找到了所有文件,然後我計劃將它們移動到適當的位置。

對其他一些人來說,也許有些人來自git bash(喜歡這張海報)(已存檔) 或mingw/ msys2(例如這張海報)(已存檔),請注意,我的錯誤表示系統無法找到/bin/bash- 與您的錯誤可能引用的方式不同/usr/bin/bash,因此會有一些差異。

C:\Users\bballdave025\Desktop\bash-4.4.12-3>tree /a /f .
Folder PATH listing for volume ██████████ OS
Volume serial number is ██████████ ██████████
C:\USERS\BBALLDAVE025\DESKTOP\BASH-4.4.12-3
|
+---etc               \   . On the working computer's version, I found
|   \---postinstall    }-' C:\cygwin64\etc\postinstall\bash.sh.done
|           bash.sh   /   I'm going to move the file from where you
|                       see it to _my_ C:\cygwin64\etc\postinstall.sh
|                     Then I'll run it, and if the tests pass, I'll
|                   rename it to bash.sh.done . I'll do that after
|                 moving all the others.
|
\---usr                 
    +---bin              
    |       bash.exe     \     
    |       bashbug       }---  I'll move these three files into 
    |       sh.exe       /      _my_  C:\cygwin64\bin   FIRST (1)
    |
    +---include
    |   \---bash                      \    . I'll move this bash
    |           <lots of *.h files>    }--' directory and all its
    |                                 /  constituent header (*.h)
    |                                  files to _my_ directory,
    |                                      C:\cygwin64\usr\include\
    |
    +---lib
    |       libbash.dll.a  }- I'll move this one file to _my_
    |                     /                         C:\cygwin64\lib\
    |
    |
    |                                          \
    \---share                                   \
        +---doc                                  :
        |   +---bash                              \
        |   |   +---<lots of bash doc stuff>       :
        |   |                                      |
        |   \---Cygwin                             : 
        |           bash.README                    |   .-I'll put the
        |                                      _.-'  _/ doc, info,
        +---info                              /   _-'  locale, and
        |       bash.info.gz                  \_/'  man directories
        |                                   --'   in _my_
        |                                  /  C:\cygdrive64\usr\share\
        +---locale                         `--------...____   directory,  
        |   +---<lots of locales which have the same  >    :  which is 
        |   |   <structure underneath; the last locale>   /  where they
        |   |   <(serving as an example) is below     >  :  were in the
        |   \---zh_TW                                   /   working
        |       \---LC_MESSAGES                        /    version.
        |               bash.mo                       /
        |                                            :
        \---man                                     /
            \---man1                               :
                    <lots of PROGRAM.gz files>    /
                                                 /                              

是的,我希望能回來,但我想得到一些答案並保存。

第二種解決方案

我的一個朋友就遇到這樣的情況。管理員設定了她的帳戶,並且管理員在其中留下了“他的鉤子”,這意味著他擁有某種所有權。由於那位管理員不再在我們原來的地方工作,我們必須找到一種方法來解決所有問題。

首先,我們嘗試刪除所有內容,但總是有一些文件和資料夾我們無法刪除 - 它們屬於該管理員(順便說一句,他是一個非常好的人。)我們甚至無法刪除如果我們以管理員身份執行刪除,則刪除(File Manager -> C -> Windows -> explorer.exe右鍵單擊,然後“以管理員身份運行”,轉到目錄C:\cygwin64並嘗試刪除...沒有骰子。)

為了最終讓事情正常工作,我們必須以管理員身份進入,更改基本目錄和所有其他目錄的權限,之後我們可以刪除該C:\cygwin目錄,重新創建它,放入setup-86_64.execygwin64目錄,然後運行設定。你嘗試只更改整個目錄的權限,然後bash使用setup-x86_64.exeGUI 重新安裝,但是當我嘗試這樣做然後進入 Cygwin 終端時,我得到了這樣的東西。

bballdave025@MY_MACHINE ~
$ wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
--2020-04-26 13:08:26--  https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.68.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.68.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13765 (13K) [text/plain]
apt-cyg: Permission denied

Cannot write to ‘apt-cyg’ (Permission denied).

bballdave025@MY_MACHINE ~
$ stat .
  File: .
  Size: 0               Blocks: 24         IO Block: ██████████  directory
Device: ██████████/██████████   Inode: ██████████  Links: 1
Access: (0575/dr-xrwxr-x)  Uid: (██████████/   bballdave025)   Gid: (██████████/Unknown+Group)
Access: 2020-03-25 06:44:06.256806800 █████
Modify: 2020-03-25 06:44:04.686424000 █████
Change: 2020-04-26 09:23:47.452255300 █████
 Birth: 2019-12-26 12:34:40.017177300 █████

bballdave025@MY_MACHINE ~
$ stat /
  File: /
  Size: 0               Blocks: 4          IO Block: ██████████  directory
Device: ██████████/██████████   Inode: ██████████  Links: 1
Access: (0775/drwxrwxr-x)  Uid: (██████████/   bballdave025)   Gid: (██████████/Unknown+Group)
Access: 2020-04-26 09:34:23.227577100 █████
Modify: 2020-04-26 09:34:23.227577100 █████
Change: 2020-04-26 12:55:46.658249200 █████
 Birth: 2019-06-25 06:49:31.485205900 █████

bballdave025@MY_MACHINE ~
$ chmod u+w .
chmod: changing permissions of '.': Permission denied

bballdave025@MY_MACHINE ~
$ # It's not going to be very useful like this.

順便說一句,這也chmod -R u+w /導致了許多錯誤。Permission denied

如果您有文件需要恢復,現在可能是第二好的恢復機會。

刪除的一種方法是按照以下指示進行操作這個應用程式教程已歸檔)。您需要管理員權限才能CMD以管理員身分執行。

您也可以使用 Windows 資源管理器執行此操作,但您可能需要以管理員身分執行資源管理器。我也嘗試過像這樣更改權限,但沒有成功。

從類型選單中搜索cmd,然後以管理員身份執行。請參閱下面的螢幕截圖。

以管理員身分執行 CMD 的步驟

取得所有權

takeown /r /d y /f C:\cygwin64

請注意,該命令的兩個組成詞是“TAKE OWN”而不是“TAKE DOWN”。另請注意,此命令可能需要很長時間,對我來說大約需要 5-20 分鐘幾乎完全安裝已歸檔)。

接下來,我們將授予每個人完整的權限。

icacls C:\cygwin64 /t /grant Everyone:F

我們可以再次嘗試返回並安裝/重新安裝bash,但我不喜歡剛完成的操作帶來的安全影響。

如果您有文件需要恢復,現在可能是第二好的恢復機會。我的意思是,如果您此時bash使用GUI安裝或重新安裝,或者即使您只使用 Windows 檔案總管,這也是您最好的機會。setup-x86_64

我寧願刪除這個 Cygwin 並重新安裝。如果您已嘗試恢復任何可以恢復的文件,請繼續執行以下命令。

rmdir /s /q C:\cygwin64

刪除之後,重新安裝前,請確保使用

Windows+R然後regedit,然後刪除/刪除和Software\Cygwin資料夾中的所有內容。HKEY_LOCAL_MACHINEHKEY-CURRENT-USER

答案4

  1. 運行 Cygwin:安裝程式-x86_64.exe

  2. 選擇:下載而不安裝

    這將下載 Cygwin 終端檔案到您的目標資料夾中http://cygwin.mirror.constant.com/

    例子:C:\目標資料夾>http://cygwin.mirror.constant.com/>

  3. 跑步再次西格溫:安裝程式-x86_64.exe。現在,選擇:安裝本地目錄, 點選 下一個, 點選下一個, 點選下一個, 然後結束

  4. 去:http://cygwin.mirror.constant.com/資料夾下有兩個子資料夾:

    諾阿奇 x86_64

  5. 打開x86_64資料夾

  6. 打開發布資料夾

  7. 打開巴什資料夾(有一個壓縮文件,例如:**bash-4.4.12-

  8. tar.xz** 文件

    解壓縮壓縮的 bash 文件,會出現兩個資料夾(ETC使用者)。

  9. 打開ETC資料夾並複製bash.sh文件並將其貼到C:\cygwin64\bin資料夾

相關內容