V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
KokongW
V2EX  ›  macOS

Homebrew install mtr 问题

  •  
  •   KokongW · 2014-05-03 16:33:23 +08:00 · 4276 次点击
    这是一个创建于 3653 天前的主题,其中的信息可能已经有所发展或是发生改变。
    遇到了一个错误,由于自己也不是很懂,发上来问问V友们!

    $ brew install mtr
    Warning: A newer Command Line Tools release is available
    The standalone package can be obtained from
    https://developer.apple.com/downloads/,
    or it can be installed via Xcode's preferences.
    ==> Downloading ftp://ftp.bitwizard.nl/mtr/mtr-0.85.tar.gz
    Already downloaded: /Library/Caches/Homebrew/mtr-0.85.tar.gz
    ==> Downloading https://github.com/traviscross/mtr/commit/edd425.diff
    Already downloaded: /Library/Caches/Homebrew/mtr--patch-c1ed669cdf65d607f75abc729a333b180ee42343.diff
    ==> Patching
    patching file asn.c
    patching file curses.c
    patching file display.c
    patching file dns.c
    patching file getopt.c
    patching file getopt1.c
    patching file gtk.c
    patching file mtr.c
    patching file net.c
    patching file raw.c
    patching file report.c
    patching file select.c
    patching file split.c
    ==> ./configure --prefix=/usr/local/Cellar/mtr/0.85 --without-gtk --without-glib
    ==> make install
    ==> Caveats
    mtr requires superuser privileges. You can either run the program
    via `sudo`, or change its ownership to root and set the setuid bit:

    sudo chown root:wheel /usr/local/Cellar/mtr/0.85/sbin/mtr
    sudo chmod u+s /usr/local/Cellar/mtr/0.85/sbin/mtr

    In any case, you should be certain that you trust the software you
    are executing with elevated privileges.
    ==> Summary
    ? /usr/local/Cellar/mtr/0.85: 8 files, 160K, built in 22 seconds
    15 条回复    2015-03-29 00:58:57 +08:00
    jakwings
        1
    jakwings  
       2014-05-03 16:50:57 +08:00
    这不是错误,只是善意的提示。第一条提示是说苹果开发者官网提供了一个命令行工具包(包含 llvm 啥的)。可以不管它。

    第二次提示:要运行 mtr 需要 root 权限,假如你不想每次都用 sudo 输入密码再运行,可以执行它提供的那两条命令来为那个程序添加 set_uid 属性,在运行时临时借用 root 的权限而无需输入密码。
    KokongW
        2
    KokongW  
    OP
       2014-05-03 19:23:28 +08:00
    @jakwings 但似乎的确是安装失败了:
    mtr: command not found
    blacktulip
        3
    blacktulip  
       2014-05-03 19:25:48 +08:00
    @KokongW

    看提示
    mtr requires superuser privileges. You can either run the program
    via `sudo`, or change its ownership to root and set the setuid bit:

    你自己不是贴了嘛

    用 sudo
    blacktulip
        4
    blacktulip  
       2014-05-03 19:27:00 +08:00
    或者你用 sudo /usr/local/Cellar/mtr/0.85/sbin/mtr 试试,还是不行就是路径没设好
    jakwings
        5
    jakwings  
       2014-05-03 20:18:00 +08:00
    @KokongW hash -r 刷新一下程序位置绑定信息?
    chen7897499
        6
    chen7897499  
       2014-05-03 20:21:44 +08:00
    输入brew doctor
    然后加权限sudo chown root:wheel /usr/local/Cellar/mtr/0.85/sbin/mtr
    sudo chmod u+s /usr/local/Cellar/mtr/0.85/sbin/mtr
    然后再mtr
    KokongW
        7
    KokongW  
    OP
       2014-05-03 20:32:54 +08:00
    @chen7897499 -bash: mtr: command not found

    还是一样呢。
    KokongW
        8
    KokongW  
    OP
       2014-05-03 20:33:43 +08:00
    @blacktulip 还是不行
    KokongW
        9
    KokongW  
    OP
       2014-05-03 20:34:01 +08:00
    @jakwings 还是依旧
    jakwings
        10
    jakwings  
       2014-05-03 21:07:40 +08:00
    @KokongW 将下面这句添加到 ~/.bashrc 的最后,然后重新运行 bash 。
    PATH="/usr/local/Cellar/mtr/0.85/sbin:$PATH"
    nodejx
        11
    nodejx  
       2014-05-03 21:07:43 +08:00
    ls -al `which mtr`
    lrwxr-xr-x 1 teacher admin 35 Jan 17 21:28 /usr/local/bin/mtr -> /usr/local/Cellar/mtr/0.85/sbin/mtr
    KokongW
        12
    KokongW  
    OP
       2014-05-03 21:35:33 +08:00
    @jakwings vim ~/.bashrc 看到里面是空白的,需要新建文件。路径在那儿?

    重新运行bash怎么做?

    小弟不太懂,烦请指点。
    jakwings
        13
    jakwings  
       2014-05-03 21:44:21 +08:00   ❤️ 1
    @KokongW 好吧,我只解释最后一次了,然后你得自己去查 Unix/Linux 系统的入门资料了。要完全解释很花时间。

    不修改 ~/.bashrc 了,直接 vim ~/.bash_profile ,在文件末尾添加 10 楼那句命令,保存。
    然后不用重启 bash ,直接执行 source ~/.bash_profile ; hash -r

    ~ 是 $HOME 的简写,bash 会自动扩展成 $HOME 的内容。echo $HOME 就可以知道是哪个文件夹了,就是用户文件夹的根目录。
    runcelim
        14
    runcelim  
       2014-05-04 23:30:37 +08:00
    sudo ln -s /usr/local/Cellar/mtr/0.85/sbin/mtr /usr/local/bin
    meteor
        15
    meteor  
       2015-03-29 00:58:57 +08:00
    echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
    我是看到brew doctor报这个waring, 加上就好了.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2266 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:13 · PVG 18:13 · LAX 03:13 · JFK 06:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.