Program Tip

sudo : 포트 : 명령을 찾을 수 없습니다.

programtip 2020. 12. 2. 21:46
반응형

sudo : 포트 : 명령을 찾을 수 없습니다.


최근에 Xcode 4.2를 제거하고 Xcode 4.3.1을 다시 설치했습니다. 명령 줄 도구가 설치됩니다. 그런 다음 macports.org에서 Lion 용 "dmg"디스크 이미지를 사용하여 MacPort를 설치했습니다. 내가 얻고 있었다, 때문에 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

.profile이 작동 할 수 있도록 ~ / .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를 사용하는 경우 '~ / .zshrc'파일의 'export PATH = "..."'줄에 흐르는 문자열을 추가하십시오.

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

내 컴퓨터에 포트가 /opt/local/bin/port있습니다. 터미널에 직접 입력 해보세요.


방금 macports를 설치 한 경우 실행하면 작동합니다.

source ~/.bash_profile

which port일반 사용자 계정으로 실행하면 무엇을 얻 습니까? 새로 개봉 한 단말기에서 사용해보세요. 로 이름 .bash_profile바꾼 후 다시 시도하세요 .profile. port인수 없이도 일반 사용자로 실행할 수 있습니까 ?


간단하게 다음 줄을 추가 할 수 있습니다.

source ~/.profile

To the bottom of your shell rc file - if you are using bash then it would be your ~/.bash_profile if you are using zsh it would be your ~/.zshrc

Then open a new Terminal window and type ports -v you should see output that looks like the following:

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

Hope that helps.


there might be the situation your machine is managed by Puppet or so. Then changing root .profile or .bash_rc file does not work at all. Therefore you could add the following to your .profile file. After that you can use "mydo" instead of "sudo". It works perfectly for me.

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

Visit my page: http://www.danielkoitzsch.de/blog/2016/03/16/sudo-returns-xyz-command-not-found/

참고URL : https://stackoverflow.com/questions/9694395/sudo-port-command-not-found

반응형