【问题标题】:scala - bash: hw.scala: Permission deniedscala - bash:hw.scala:权限被拒绝
【发布时间】:2013-08-14 19:01:24
【问题描述】:

我根据这篇文章Getting started 安装了带有 sbt 的 scala。

但是当我创建简单的启动项目Hello world 时,我遇到了奇怪的输出:

nazar_art@nazar-desctop:~$ find .sbt
.sbt
.sbt/.lib
.sbt/.lib/0.12.1
.sbt/.lib/0.12.1/sbt-launch.jar
.sbt/boot
.sbt/boot/update.log
nazar_art@nazar-desctop:~$ cd hello
nazar_art@nazar-desctop:~/hello$ echo 'object Hi { def main(args: Array[String]) = println("Hi!") }' > hw.scala
bash: hw.scala: Permission denied
nazar_art@nazar-desctop:~/hello$ sbt
java.io.FileNotFoundException: /home/nazar_art/.sbt/boot/update.log (Permission denied)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
    at java.io.FileWriter.<init>(FileWriter.java:90)
    at xsbt.boot.Update.<init>(Checks.java:51)
    at xsbt.boot.Launch.update(Launch.scala:266)
    at xsbt.boot.Launch$$anonfun$jnaLoader$1.apply(Launch.scala:111)
    at scala.Option.getOrElse(Option.scala:108)
    at xsbt.boot.Launch.jnaLoader$2f324eef(Launch.scala:106)
    at xsbt.boot.Launch.<init>(Launch.scala:85)
    at xsbt.boot.Launcher$.apply(Launch.scala:281)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:31)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.FileNotFoundException: /home/nazar_art/.sbt/boot/update.log (Permission denied)

我不明白为什么会发生这种情况,因为我是 su
任何建议。

编辑:

我使用chmod 777 更新.log。 但是现在当我尝试运行 sbt 时,我有:

-rwxrwxrwx 1 root root 63 Aug 13 11:17 hw.scala
nazar_art@nazar-desctop:~/hello$ sudo echo 'object Hi { def main(args: Array[String]) = println("Hi!") }' > hw.scala
nazar_art@nazar-desctop:~/hello$ sbt
Error occurred during initialization of VM
Could not reserve enough space for object heap
  • 如何解决这个问题?

【问题讨论】:

    标签: java scala sbt filenotfoundexception


    【解决方案1】:

    'ls -l ~/.sbt/boot' 返回什么?

    【讨论】:

    • 返回-rw-r--r-- 1 root root 0 Aug 13 10:42 update.log
    • 拥有它:su chown -R nazar_art ~/.sbt
    • 对于您的新问题,请尝试将每个stackoverflow.com/questions/15280839/… 的堆大小减少到 1G
    • 运气好吗?我有点怀疑只是因为 sbt 在权限更改之前在 JVM 中运行,尽管存在 IO 错误。也许尝试以 su 身份运行 sbt,因为 root 拥有一切。
    【解决方案2】:

    您的第一个问题似乎已解决。对于您遇到的第二个错误,请添加

    导出 SBT_OPTS="-Xmx2G"

    然后重试(根据您的开发环境更改 2G 部分)。 Sbt 抱怨缺乏 JVM 堆大小,所以你需要增加这些。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 2018-07-19
      • 2018-02-05
      • 2015-04-28
      • 2018-02-03
      相关资源
      最近更新 更多