【问题标题】:Unable to install sbt on Mac无法在 Mac 上安装 sbt
【发布时间】:2015-08-30 04:59:13
【问题描述】:

您好,我一直在尝试按照http://www.scala-sbt.org/0.13/tutorial/Manual-Installation.html 的说明在 Mac 上安装 SBT

但是我被困在第一步:

将 sbt-launch.jar 放入 ~/bin。

我想我已经把 sbt 放进了 bin

然后我尝试通过 brew 安装它,安装过程顺利。但是当我检查 sbt 版本以确认安装时。我收到一条新的错误消息:

vtmbpr:~ VT$ brew install sbt
Warning: You are using OS X 10.11.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.
==> Downloading https://dl.bintray.com/sbt/native-packages/sbt/0.13.9/sbt-0.13.9.tgz
######################################################################## 100.0%
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/sbt
Target /usr/local/bin/sbt
already exists. You may want to remove it:
  rm '/usr/local/bin/sbt'

To force the link and overwrite all conflicting files:
  brew link --overwrite sbt

To list all files that would be deleted:
  brew link --overwrite --dry-run sbt

Possible conflicting files are:
/usr/local/bin/sbt
==> Caveats
You can use $SBT_OPTS to pass additional JVM options to SBT:
   SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"

This formula is now using the standard typesafe sbt launcher script.
Project specific options should be placed in .sbtopts in the root of your project.
Global settings should be placed in /usr/local/etc/sbtopts
==> Summary
????  /usr/local/Cellar/sbt/0.13.9: 5 files, 1.2M, built in 7 seconds
vtmbpr:~ VT$ sbt
Error: Unable to access jarfile /usr/local/bin/sbt-launcher.jar
vtmbpr:~ VT$ $ sbt
-bash: $: command not found
vtmbpr:~ VT$ sbt --version
Error: Unable to access jarfile /usr/local/bin/sbt-launcher.jar
vtmbpr:~ VT$ 

对于每个人来说,这可能是一个非常简单的问题,但即使是在 coursera 课程的“获取我的工具设置”阶段卡住了 3 个小时的谷歌学习,这也是令人难以置信的沮丧。


更新为通过 brew 删除和重新安装。我怎么知道 sbt 之后是否运行正常?我尝试运行 sbt --version 但抛出了一系列错误。

vtmbpr:~ VT$ sudo rm /usr/local/bin/sbt
Password:
vtmbpr:~ VT$ port install sbt
-bash: port: command not found
vtmbpr:~ VT$ brew install sbt
Warning: sbt-0.13.9 already installed, it's just not migrated
Warning: You are using OS X 10.11.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.
vtmbpr:~ VT$ sbt
-bash: /usr/local/bin/sbt: No such file or directory
vtmbpr:~ VT$ sbt
-bash: /usr/local/bin/sbt: No such file or directory
vtmbpr:~ VT$ sbt --version
-bash: /usr/local/bin/sbt: No such file or directory
vtmbpr:~ VT$ brew link --overwrite sbt
Linking /usr/local/Cellar/sbt/0.13.9... 1 symlinks created
vtmbpr:~ VT$ sbt
s[info] Set current project to vt (in build file:/Users/VT/)
^R
> sbt --version
[error] Expected ID character
[error] Not a valid command: sbt (similar: set, boot, last)
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Not a valid key: sbt (similar: test, ivy-sbt, state)
[error] sbt --version
[error]    ^

【问题讨论】:

  • 您已将其安装到/usr/local/bin,而不是~/bin
  • 如何找到~/bin 目录?
  • 它可能不存在,您需要创建它。您可以将其保留在当前位置,因为问题看起来像 sbt-launcher.jar 的符号链接不正确。
  • 请原谅我的基本问题,但 ~ 在我的目录中是什么意思?如果我将 sat-launcher.jar 保留在现在的位置,我该如何引导终端去那里找到它? - 如果我正确理解符号链接。
  • 波浪号~/ 后跟正斜杠是用户主目录的缩写。

标签: macos scala sbt


【解决方案1】:

由于您手动安装它然后使用brew 可能存在冲突的文件,您应该先将其删除以开始清理:

sudo rm /usr/local/bin/sbt

然后您可以使用MacPortsHomebrew 重新安装:

Mac 端口

port install sbt

自制

brew install sbt

根据您的环境,您可能需要使用其中任何一个发出sudo 命令。我更喜欢 MacPorts,但您决定使用哪个完全是您的偏好。

如果您不想重新安装 sbt 并尝试强制 brew 链接并覆盖所有冲突的文件,请发出以下命令,希望这会创建正确的符号链接:

brew link --overwrite sbt

【讨论】:

  • 新的错误是用户错误,意味着你尝试的sbt --version命令无效(应该是sbt sbtVersion);现在看起来它已正确安装和链接,请尝试阅读文档...那里有很好的信息:)
猜你喜欢
  • 1970-01-01
  • 2013-12-02
  • 2012-04-09
  • 2020-04-22
  • 2021-01-06
  • 2017-07-20
  • 2013-07-27
  • 2021-07-11
  • 2021-10-03
相关资源
最近更新 更多