سؤال

لقد قمت مؤخرًا بإلغاء تثبيت Xcode 4.2 وأعدت تثبيت Xcode 4.3.1.تم تثبيت أدوات سطر الأوامر.ثم قمت بعد ذلك بتثبيت MacPort باستخدام صور قرص "dmg" لـ Lion من macports.org.منذ ذلك الحين، كنت أحصل على sudo: port: command not found بعد كل استخدام للميناء، تابعت هذا و هذا المشنور لخلق .bash_profile الملف (لم يكن موجودا سابقا) ثم ضع فيه ما يلي ولكن دون جدوى.

export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info 

التالي هذا المشنور

➜  ~ git:(master) ✗ rvm install 1.8.7 --with-openssl-dir=/opt/local
You requested building with '/usr/bin/gcc-4.2' but it is not in your path.
➜  ~ git:(master) ✗ vi .rvmrc 

rvm_archflags="-arch x86_64"

export CC="/usr/bin/gcc-4.2"

export CFLAGS="-O2 -arch x86_64"
export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include"

إعادة تسمية .bash_profile ل .profile

➜  ~ git:(master) ✗ vi .bash_profile
➜  ~ git:(master) ✗ mv .bash_profile .profile
➜  ~ git:(master) ✗ mv .profile              
usage: mv [-f | -i | -n] [-v] source target
       mv [-f | -i | -n] [-v] source ... directory
➜  ~ git:(master) ✗ mv -f .bash_profile .profile
mv: rename .bash_profile to .profile: No such file or directory
➜  ~ git:(master) ✗ port
zsh: correct 'port' to 'pr' [nyae]? n
zsh: command not found: port
➜  ~ git:(master) ✗ which port
port not found
➜  ~ git:(master) ✗ 

.profile محتوى:

export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info
هل كانت مفيدة؟

المحلول

تأكد من حذف ~/.bash_profile و~/.bash_login حتى يتمكن الملف الشخصي من العمل.لقد نجح هذا بالنسبة لي http://johnnywey.wordpress.com/2008/04/17/fixing-bash-profile-in-os-x/

نصائح أخرى

أولاً، قد تحتاج إلى تعديل PATH الخاص بنظامك

sudo vi /etc/paths

أضف السطرين التاليين:

/opt/local/bin
/opt/local/sbin

أعد تشغيل المحطة الخاصة بك

يمكنك محاولة الحصول على مصدر ملف ملف التعريف الخاص بك لتحديث بيئتك:

$ source ~/.profile

لقد وجدت الجواب في الموقع الرسمي

$ vi ~/.profile

# add the following line
export PATH=/opt/local/bin:/opt/local/sbin:$PATH

والآن أعد تشغيل الجهاز أو اكتب source !$ (أي ما يعادل source ~/.profile)

إذا كنت تستخدم zsh. يرجى إضافة سلسلة متدفقة إلى السطر "export PATH = "..."" في الملف "~/.zshrc"

:/opt/local/bin:/opt/local/sbin

على الجهاز الخاص بي، المنفذ موجود /opt/local/bin/port - حاول كتابة ذلك في المحطة من تلقاء نفسها.

إذا كنت قد قمت بتثبيت Macports للتو ، فيجب أن تعمل

source ~/.bash_profile

ماذا تستفيد من الجري which port كحساب المستخدم العادي الخاص بك؟جربه من محطة مفتوحة حديثًا.حاول مرة أخرى بعد إعادة التسمية .bash_profile ل .profile.هل تستطيع الركض port كمستخدم عادي، حتى مع عدم وجود الحجج؟

يمكنك بكل بساطة إضافة السطر:

source ~/.profile

في الجزء السفلي من ملف Shell rc الخاص بك - إذا كنت تستخدم bash، فسيكون ~/.bash_profile الخاص بك إذا كنت تستخدم zsh، فسيكون ~/.zshrc الخاص بك

بعد ذلك، افتح نافذة طرفية جديدة واكتبports -v، وسترى الإخراج الذي يبدو كما يلي:

~ [ port -v                                                                                                              ] 12:12 pm
MacPorts 2.1.3
Entering interactive mode... ("help" for help, "quit" to quit)
[Users/sh] > quit
Goodbye

امل ان يساعد.

قد يكون هناك موقف تتم فيه إدارة جهازك بواسطة Puppet أو نحو ذلك.ثم تغيير ملف تعريف الجذر أو ملف .bash_rc لا يعمل على الإطلاق.لذلك يمكنك إضافة ما يلي إلى ملف .profile الخاص بك.بعد ذلك يمكنك استخدام "mydo" بدلاً من "sudo".إنه يعمل بشكل مثالي بالنسبة لي.

function mydo() {
    echo Executing sudo with: "$1" "${@:2}"
    sudo $(which $1) "${@:2}"
}

زيارة صفحتي: http://www.danielkoitzsch.de/blog/2016/03/16/sudo-returns-xyz-command-not-found/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top