“sudo: port: command not found” after installing MacPorts on Snow leopard
I have attempted to install MacPorts in order to upgrade my Rails version so that I can work my way through Agile Web Development with Rails, PragProg (4th, 2011). I have followed the directions in the book, as well as on the MacPorts web site, to perform the install from disk image. It appeared to install correctly, however, running port commands afterwards returned «port: command not found».
I searched Stack Exchange and found this question, so I attempted to install from the command line using «tar xjvf MacPorts-1.9.2.tar.bz2». Again, the install seems to work. I receive the confirmation that MacPorts installed successfully, but I still receive «sudo: port: command not found» error on trying to selfupdate MacPorts (via «sudo port -v selfupdate»).
I think that my error lies in not having the correct path set. I followed the advice in this thread, namely, adding a path (/opt/local) in paths.d, but I still get the error.
If it matters, terminal is set to open shells with default login shell (/usr/bin/login). Should I change this to /bin/bash?
So, is this a MacPorts issue, a $PATH issue, or a StupidUser issue?
Question: Q: sudo: port: command not found
Why does that always happen? I am in Terminal and I am trying to get some bundles for TextMate, and I am trying to install the subversion:
sudo port install subversion
sudo: port: command not found
iMac Intel 20″, Mac OS X (10.4.8)
Posted on Jan 13, 2007 1:49 PM
All replies
Loading page content
Page content loaded
Jan 13, 2007 2:12 PM
Is there anything I can do?
Jan 13, 2007 2:25 PM
Man is the Unix «manual» command. Use it to display the help for any installed command, e.g., man port.
There is a port.rb script that’s part of Ruby on Rails if you have it installed as part of 10.4.8 (may need to install the Developer Tools, not sure of this, however.)
A «port» command is not listed by Apple as a valid command:
Jan 13, 2007 2:31 PM
Well this has nothing to do with Rails,
I have installed XTools 2.0
Jan 13, 2007 2:39 PM
Jan 13, 2007 7:13 PM
You should try to give us a hint of why you think that command should work. For example, who told you to type it and why?
I have the feeling you’re expected to have DarwinPorts installed:
This gives you access to a number of open source software.
XCode does not come with a «port» command.
Jan 13, 2007 11:25 PM
I’m trying to install a bundle for TextMate:
I think I have DarwinPorts because I get:
Welcome to Darwin!
When I open up the terminal.
It has worked in the past for me, so I don’t know why its not working now.
Jan 14, 2007 3:45 AM
Terminal always says «Welcome to Darwin» when it starts. You need to either install DarwinPorts, see this:
or you can use Fink:
There evidently pre-built binaries available. Check the links on the page you referenced.
Francine
Francine
Schwieder
Jan 14, 2007 8:40 AM
Ok, I installed Darwin ports, and then tried to execute this command
sudo port -d selfupdate
and I still get this:
sudo: port: command not found
Jan 14, 2007 8:56 AM
Nick, I’m afraid I never got around to installing Xcode in Tiger (just use a couple of things, and I grabbed just those rather than installing the whole thing) so afraid I can’t help you sort it out. Rafe might be able to, or you can try posting in the UNIX forum:
But it looks to me like the easiest thing would be to grab those pre-compiled binaries the site mentioned. Subversion is here:
Good luck.
Francine
Francine
Schwieder
Как исправить ошибку «Command Not Found» в командной строке на Mac
Продвинутые пользователи Mac, которые часто работают с командной строкой, наверняка не раз сталкивались с ошибкой «command not found». Она может возникать по нескольким причинам. Ниже мы рассмотрим их все и предложим решения.
Три самые распространённые причины ошибки «command not found»:
- Команда, которую вы пытаетесь выполнить, не установлена.
- Команда была удалена или изменена.
- Проблемы с переменной $
К счастью, любую из этих проблем можно решить. Начнём с самой распространённой причины.
Изменение настроек $PATH
Чаще всего ошибка возникает из-за проблем с $PATH. Чтобы исправить её, выполните следующую команду.
После этого выполните нужную команду ещё раз, и теперь она должна сработать.
Если ваша команда расположена в нестандартной папке (/usr/local/sbin), можно добавить новую $PATH в командную строку.
Вот ошибка при попытке выполнить простую команду:
А вот её успешное выполнение после предложенного выше решения:
Иногда проблема возникает из-за неправильной команды экспорта $PATH. Возможно, чтобы изменения вступили в силу, нужно будет перезапустить командную строку. Если после этого ошибка не исчезнет, добавьте команды экспорта $PATH в профиль .bash_profile.
Как установить команду через HomeBrew
Если команда просто не установлена, можно воспользоваться программой Homebrew и установить через неё всё необходимое. Homebrew – отличный инструмент и для других задач, так что он необходим, если вы регулярно работаете в Terminal.
Как восстановить системные файлы
Время от времени пользователи могут случайно удалять системные файлы Mac OS. Из-за этого возникают проблемы с выполнением команд. В данной инструкции вы можете почитать, как восстановить эти файлы.
Установка и работа с менеджером пакетов для Maс OS X (MacPort и Homebrew)
Менеджер пакетов в Mac OS X позволит нам легко работать с пакетам посторонних разработчиков. В этом топике рассмотрим два таких менеджера: MacPort и Homebrew.
1. MacPort
Официальний сайт
На этом же сайте можна найти Mac OS X Package (.pkg) Installer для Mountain Lion, Lion, Snow Leopard и Leopard. Установите подходящий вам пакет и пользуйтесь на здоровье. Есть и другие способы установки, но мы выбрали простой и быстрый. На случей чево, у меня port установился сюда: /opt/local/bin/port.
Требование:
Работать с port придельно просто — ищем в «портах» нужный пакет и устанавливаем его:
Дополнительные команды:
2. Homebrew
Официальная страница
О Homebrew поговорим подробнее…
Требование:
Установка:
После успешной установки виполним следующую команду:
Если в результате этой команди получим ответ: «Your system is raring to brew», тогода все хорошо и можете спокойно начинать работу з brew. В ином случае продолжим…
Если возникла ошибка Warning: Experimental support for using Xcode without the «Command Line Tools», то скорее всего была обновлена «ось», к примеру, с Lion к Mountain Lion, но не была переустановлена Command Line Tools для Xcode.
Если возникла ошибка Error: No such file or directory — /usr/local/Cellar, то нужна создать эту директорию:
После этого опять запускаем команду:
Если мы получим что-то вроде этого:
то исправляем примером так:
Если на этот раз никаких ошибок не произошло, тогда все — можна спокойно работать с Homebrew.
sudo: command not found
Every time I try to use a sudo or ssh command, it returns with this error:
I was messing with Python installs, and am not sure what I did to cause this. How can I permanently fix this?
macOS Sierra 10.12.4 16E195
MacBook Pro 2016
13″ Touchbar
EDIT: here’s the path:
Here is .bash_profile
jackson1442$ echo $PATH ’/usr/local/bin. – Jackson1442 May 2 ’17 at 2:52
2 Answers 2
Your PATH is hosed!
First check your .bash_profile file with:
Prepend lines containing something like export PATH=»/. » with a # to comment them out. Save the file with ctrl O and exit nano with ctrl X
Then check /etc/paths with: /bin/cat /etc/paths .
It should look like this:
You can edit the file with /usr/bin/sudo /usr/bin/nano /etc/paths if required.
If everything is fine enter source
/.bash_profile or close the Terminal window and open a new one.
Now sudo should work again. Then check all #export PATH=. lines in your .bash_profile for potential errors. You may add them to your question to get help here.
Question: Q: -bash: sudo: command not found
I’m using terminal and when I type in:
» sudo diskutil unmountDisk force /dev/disk1″
all it show up was:
«-bash: sudo: command not found»
It’s a Mac OS X v10.10 Yosemite
Posted on Nov 23, 2016 8:11 PM
Helpful answers
This generally means you have managed to mess up your PATH environment variable.
To execute your command you could use
/usr/bin/sudo /usr/sbin/diskutil unmountDisk force /dev/disk1
This is a short term solution.
Chances are you have one of the following shell initialization files and it has a broken export PATH
Use this command to see if you have any of these files:
/bin/ls .bash_profile .bash_login .profile .bashrc
By default none of these files exist in your home directory.
If you have one of these files you can edit it using
Or use a GUI based text editor, such as TextWrangler
You should either fix PATH modification, or remove the broken PATH modification
After making a change to your shell initialization file, you should quit the Terminal session and start a new one so that the modified shell initialization file is re-loaded into the shell.
You could also rename the broken shell initialization file and fix it later.
Or you can just delete it
Again, quit and start a new Terminal session.