入力ソース ~/.bashrc エラー dircolors\lesspipe: コマンドが見つかりません 解決策

質問

入力

source ~/.bashrc

次のエラーが報告されます

Command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found

解決

コマンドラインに入力します

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

この方法により、bin の下のコマンド ( source、ls など)をこのコマンド ラインで通常どおりに使用できるようになります。

恒久的な解決策

まず、コマンドラインで上記のエクスポートを実行します。

次に、ユーザー ディレクトリ内の .bashrc ファイルを変更し、間違いを犯した場合は元に戻し、何が間違っているのかわからない場合は最後の変更をキャンセルします。

vim ~/.bashrc

export ... $PATH ... のステートメントが正しいかどうかを観察することに重点を置きます。

たとえば、私の以前の間違いは、cuda ツールを設定するときに PATH を追加するのを忘れたことです。

問題が発生した場合、私の .bashrc は次のようになります。

...

export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
export PATH=/home/zhoug/cuda-10.2/lib64/

ご覧のとおり、4 行目の途中に $PATH を追加していないため、エラーが発生しました。

前に述べたように、次のように変更します。

export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
export PATH=$PATH:/home/zhoug/cuda-10.2/lib64/

これらの行を削除して、最後に元の行に変更してください。

...

# export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
# export PATH=/home/zhoug/cuda-10.2/lib64/

次に、変更した .bashrc をソースします

source ~/.bashrc

システムコマンドは通常の状態に戻ります。

理由

これを見ると、.bashrc とソースを更新した後もわかるはずです。

vim ~/.bashrc
source ~/.bashrc

システムがエクスポートのパス PATH を解析したときに、正しい場所が解決されませんでした。

その 99.99% は、.bashrc の変更を変更していないことが原因である可能性があります。

この場合、システム コマンドを実行したい場合は、たとえば ls が必要な場合にのみ実行できます。

/usr/bin/ls

したがって、.bashrc ファイルに修正し直す必要があり、次のように vim を使用する必要があります。

/usr/bin/vim ~/.bashrc

しかし、あなたが遭遇する最も困難な問題は、この方法でソースを取得したい場合に、冒頭で述べたエラーが報告されることです。

/usr/bin/source
Command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found

考えられる理由は、source が結合されたコマンドであり、この結合されたコマンドが実行されるときに、lesspipe および dircolors を呼び出すときに正しい PATH パスが依然として必要であることです。

この問題に対しては、私が述べた回避策がうまく機能します。

参考

Linux エラー: -bash: パス xx: そのようなファイルまたはディレクトリの解決策はありません

おすすめ

転載: blog.csdn.net/m0_46948660/article/details/129702261