V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
jyounn
V2EX  ›  问与答

homebrew,搞了一天终于把这个 tomcat 给装上了!

  •  1
     
  •   jyounn · 2019-10-17 20:14:14 +08:00 · 3596 次点击
    这是一个创建于 1843 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天用到 tomcat,然后发现自己的版本是 8,而最新版本已经是 9 了,想着就用最新的. 卸载了 8 然后悲剧了,一直安装不了,摸了一天鱼,终于搞定了,记录一下!

    1.下载 tomcat,发现一直失败

    dashudeMacBook-Pro:~ dashu$ brew install tomcat
    ==> Downloading https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
    ==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
    
    curl: (22) The requested URL returned error: 404 Not Found
    Trying a mirror...
    ==> Downloading https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.tar.gz
    ^C^C
    dashudeMacBook-Pro:~ dashu$
    

    2.看下了输出,奇怪,为什么国内镜像不行,反而转欧美镜像了(有墙下载不下来很正常啊!)

    于是去看下国内镜像,果然,国内镜像确实不存在

    3.那就按照提示用 9.0.27 版本呗,想着指定 url 下载吧!

    结果还是悲剧...百度之,ruby 字符解析问题?(我不会 ruby 语法啊,搞不懂)

    dashudeMacBook-Pro:~ dashu$ brew install "https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz"
    ######################################################################## 100.0%
    ######################################################################## 100.0%
    Error: apache-tomcat-9.0.27.tar.gz: /Users/dashu/Library/Caches/Homebrew/Formula/apache-tomcat-9.0.27.tar.gz:1: Invalid char `\x1F' in expression
    /Users/dashu/Library/Caches/Homebrew/Formula/apache-tomcat-9.0.27.tar.gz:1: invalid multibyte char (UTF-8)
    

    4.搜索了半天 ruby “invalid multibyte char”,毫无头绪···.(中间也试了很多其他猜想,不赘述了)

    我还真不信了,一直都是通过 homebrew 安装软件的啊.于是想前向不行,后向试试? 试着安装 7,诶!还真行~

    dashudeMacBook-Pro:~ dashu$ brew install tomcat7
    ==> Downloading https://www.apache.org/dyn/closer.cgi?path=tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
    ==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
    ######################################################################## 100.0%
    ==> Caveats
    tomcat@7 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    If you need to have tomcat@7 first in your PATH run:
      echo 'export PATH="/usr/local/opt/tomcat@7/bin:$PATH"' >> ~/.bash_profile
    
    
    To have launchd start tomcat@7 now and restart at login:
      brew services start tomcat@7
    Or, if you don't want/need a background service you can just run:
      catalina run
    ==> Summary
    🍺  /usr/local/Cellar/tomcat@7/7.0.96: 634 files, 13.6MB, built in 14 seconds
    

    5.到这里,朋友们回觉得:终于安装好 tomcat 了,任务完成!可以继续安心摸鱼···但楼主决不是求安逸的人,一定要搞明白 WHY!

    灵机一动,brew 其实运行的是 git 仓库里的 ruby 脚本,这样看来莫不是仓库里的代码不是最新的? 于是 brew update 搞起

    dashudeMacBook-Pro:~ dashu$ brew update
    fatal: unable to access 'https://github.com/Homebrew/homebrew-cask/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
    fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
    Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!
    Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
    Updated 1 tap (homebrew/cask-versions).
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
    No changes to formulae.
    

    6.哦吼,问题就是它--更新不了 ruby 脚本!

    百度之,やっぱり! 需要将 git 远程仓库地址也修改成国内镜像,解决方案简单,修改之.

    cd "$(brew --repo)" 
    git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
    
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" 
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
    
    

    7.再试一次“brew update”.完美,更新成功

    dashudeMacBook-Pro:homebrew-core dashu$ brew update
    Updated 2 taps (homebrew/core and homebrew/cask).
    ==> New Formulae
    ...(其他更新内容太多,就不贴了)
    

    8.见证奇迹的时刻.-)

    dashudeMacBook-Pro:homebrew-core dashu$ brew info tomcat
    tomcat: stable 9.0.27
    Implementation of Java Servlet and JavaServer Pages
    https://tomcat.apache.org/
    Not installed
    From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/tomcat.rb
    ==> Requirements
    Required: java >= 1.8 ✔
    ==> Caveats
    To have launchd start tomcat now and restart at login:
      brew services start tomcat
    Or, if you don't want/need a background service you can just run:
      catalina run
    ==> Analytics
    install: 7,501 (30 days), 17,972 (90 days), 72,461 (365 days)
    install_on_request: 6,671 (30 days), 16,066 (90 days), 63,395 (365 days)
    build_error: 0 (30 days)
    dashudeMacBook-Pro:homebrew-core dashu$ brew install tomcat
    ==> Downloading https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
    ==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
    ######################################################################## 100.0%
    ==> Caveats
    To have launchd start tomcat now and restart at login:
      brew services start tomcat
    Or, if you don't want/need a background service you can just run:
      catalina run
    ==> Summary
    🍺  /usr/local/Cellar/tomcat/9.0.27: 640 files, 14.8MB, built in 9 seconds
    

    希望能帮助遇到同样问题的小伙伴们.

    14 条回复    2020-02-13 10:17:36 +08:00
    jyounn
        1
    jyounn  
    OP
       2019-10-17 20:15:00 +08:00
    第一次发帖,还不是上图...大家见谅
    zhoulouzi
        2
    zhoulouzi  
       2019-10-17 20:40:47 +08:00
    Good
    julyclyde
        3
    julyclyde  
       2019-10-18 12:09:36 +08:00
    我提炼一下:
    tuna 已经不提供 9024 了
    你想办法更新了 brew 之后,开始下载 9027
    jyounn
        4
    jyounn  
    OP
       2019-10-18 15:48:12 +08:00
    @julyclyde 大佬总结得很精屁
    julyclyde
        5
    julyclyde  
       2019-10-18 16:33:17 +08:00
    @jyounn 第一遍没看懂,又仔细看了一遍
    然后猜想估计别人也跟我第一遍一样,干脆总结一下
    efaun
        6
    efaun  
       2019-10-19 06:38:44 +08:00
    docker 大法好
    jyounn
        7
    jyounn  
    OP
       2019-10-21 15:01:53 +08:00
    @julyclyde 😓看来以后开头应该先总结一句
    jyounn
        8
    jyounn  
    OP
       2019-10-21 15:03:08 +08:00
    @efaun 这和用啥没关系吧.虽然没研究过 docker,但是原理应该一样,需要不定期更新?
    efaun
        9
    efaun  
       2019-10-21 15:07:19 +08:00
    @jyounn #8 docker 一键部署了呗,不用配置了
    jyounn
        10
    jyounn  
    OP
       2019-10-21 15:45:07 +08:00
    @efaun 了解了下,docker 是应用容器管理工具.和 homebrew 这个包管理工具功能不太一样吧.
    efaun
        11
    efaun  
       2019-10-21 15:50:23 +08:00
    @jyounn #10 我的意思是,你自己安装 tomcat,相当于安装一个软件不停点下一步,用 docker,相当于绿色软件下载即用,当然这也看个人喜好,也有人就是享受自己配置的感觉
    jyounn
        12
    jyounn  
    OP
       2019-10-21 16:16:24 +08:00
    @efaun 好嘞
    xmsec
        13
    xmsec  
       2020-02-13 10:02:32 +08:00
    遇到相同的问题,最后发现是版本更新后 brew 的信息没有更新,下载失败。可以 brew edit tomcat 修改,然后再装。
    不确定如何修改,比如,可以先 brew bump-formula-pr --url=http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz tomcat,然后可以在 https://github.com/Homebrew/homebrew-core/pulls 看到提交的 pr,按照 pr 修改即可。
    xmsec
        14
    xmsec  
       2020-02-13 10:17:36 +08:00
    上面这个方法针对 brew update 之后也无法安装的情况,因为软件更新后 brew 的仓库信息还没有来得及更新。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1415 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:28 · PVG 01:28 · LAX 10:28 · JFK 13:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.