web-dev-qa-db-ja.com

.bash_profileを壊しました

Mac OSXマシンに何かをインストールしようとしているときに、〜/ .bash_profileファイルが壊れたと思います。私はそれを編集しました、そして突然、私がターミナルを開くとき、私は何も実行することができず、ファイルをリストすることさえできません:

$ ls
-bash: ls: command not found

大野! emacsを開いて〜/ .bash_profileを編集しようとしましたが、できません:

$ emacs ~/.bash_profile
-bash: emacs: command not found
$ port install emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Computing dependencies for emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Fetching emacs
--->  Attempting to fetch emacs-23.2.tar.gz from http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Verifying checksum(s) for emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Extracting emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Configuring emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Building emacs
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Staging emacs into destroot
MacPorts running without privileges. You may be unable to complete certain actions (eg install).
--->  Installing emacs @23.2_1
Error: Target org.macports.install returned: MacPorts requires root privileges for this action
Error: Status 1 encountered during processing.
Before reporting a bug, first run the command again with the -d flag to get complete output.

Sudoを使用することはできません。また、Finderを変更して隠しファイルを表示し、そこから開くこともできません。

$ Sudo port install emacs
-bash: Sudo: command not found
$ defaults write com.Apple.Finder AppleShowAllFiles YES
-bash: defaults: command not found

助けて! 〜/ .bash_profileを開いて修正するにはどうすればよいですか?

4
AP257

PATHを修正するまで、コマンドへのフルパスを使用します。

/bin/ls
/path/to/emacs

等.

$ /usr/bin/vi ~/.bash_profile

... HOMEも破損していないと仮定します。それ以外の場合は、cdを適切な場所に移動して編集します。

3
Fred

このコマンドを実行してbashプロファイルを修正し、ユーザー名を次のように置き換えます。

/usr/bin/Sudo /usr/bin/nano /Users/YOURUSERNAME/.bash_profile

パスを編集するときは、新しいパス文字列の最後に:$ PATHを含めることを忘れないでください。このように読む必要があります:

export PATH = "/my/new/path:$PATH"

これが問題の原因である可能性があります。

0
Gremlin

おそらくPATH環境変数が破損しています...

Finderを使用して、textwranglerなどでファイルを開きます。

0
hvgotcodes