Intellij 无法导入 SBT 项目

Posted

技术标签:

【中文标题】Intellij 无法导入 SBT 项目【英文标题】:Intellij Fails to Import SBT project 【发布时间】:2015-08-31 11:48:22 【问题描述】:

我正在尝试将 sbt 项目导入 intellij 14,但是,这是我打开项目时得到的:

错误:导入 SBT 项目时出错: ...

at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
    at sbt.MainLoop$.runLogged(MainLoop.scala:24)
    at sbt.StandardMain$.runManaged(Main.scala:53)
    at sbt.xMain.run(Main.scala:28)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:129)
    at xsbt.boot.Launch$.run(Launch.scala:109)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36)
    at xsbt.boot.Launch$.launch(Launch.scala:117)
    at xsbt.boot.Launch$.apply(Launch.scala:19)
    at xsbt.boot.Boot$.runImpl(Boot.scala:44)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
[error] java.io.FileNotFoundException: /home/karthik/Play2.4/Directory/target/.history 
(Permission denied)
[error] Use 'last' for the full log.

查看完整登录/home/karthik/.IdeaIC14/system/log/sbt.last.log

这是我的 sbt.last.log 文件

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support 
was removed in 8.0
[info] Loading project definition from /home/karthik/Play2.4/Rocket_Singh/project
[info] Set current project to Rocket_Singh 
(in build file:/home/karthik/Play2.4/Rocket_Singh/)
[Rocket_Singh] $ java.io.FileNotFoundException: 
/home/karthik/Play2.4/Rocket_Singh/target/.history (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
    at jline.console.history.FileHistory.flush(FileHistory.java:87)
    at sbt.JLine.readLineWithHistory(LineReader.scala:28)
    at sbt.JLine.sbt$JLine$$unsynchronizedReadLine(LineReader.scala:19)
    at sbt.JLine$$anonfun$readLine$1.apply(LineReader.scala:16)
    at sbt.JLine$$anonfun$readLine$1.apply(LineReader.scala:16)
    at sbt.JLine$$anonfun$withJLine$1.apply(LineReader.scala:114)
    at sbt.JLine$$anonfun$withJLine$1.apply(LineReader.scala:112)
    at sbt.JLine$.withTerminal(LineReader.scala:86)
    at sbt.JLine$.withJLine(LineReader.scala:112)
    at sbt.JLine.readLine(LineReader.scala:16)
    at sbt.BasicCommands$$anonfun$shell$1.apply(BasicCommands.scala:164)
    at sbt.BasicCommands$$anonfun$shell$1.apply(BasicCommands.scala:160)
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:29)
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:29)
    at sbt.Command$.process(Command.scala:92)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
    at sbt.State$$anon$1.process(State.scala:184)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.MainLoop$.next(MainLoop.scala:98)
    at sbt.MainLoop$.run(MainLoop.scala:91)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
    at sbt.MainLoop$.runLogged(MainLoop.scala:24)
    at sbt.StandardMain$.runManaged(Main.scala:53)
    at sbt.xMain.run(Main.scala:28)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:129)
    at xsbt.boot.Launch$.run(Launch.scala:109)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36)
    at xsbt.boot.Launch$.launch(Launch.scala:117)
    at xsbt.boot.Launch$.apply(Launch.scala:19)
    at xsbt.boot.Boot$.runImpl(Boot.scala:44)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
[error] java.io.FileNotFoundException: 
/home/karthik/Play2.4/Rocket_Singh/target/.history (Permission denied)
[error] Use 'last' for the full log.

【问题讨论】:

那么,您能否包含来自 /home/karthik/.IdeaIC14/system/log/sbt.last.log 的完整日志? :) 【参考方案1】:
/home/karthik/Play2.4/Directory/target/.history (Permission denied)
/home/karthik/Play2.4/Rocket_Singh/target/.history (Permission denied)

这些消息表明您无权访问这些路径。检查运行 intellij 的用户是否对.history 有写权限。在 Linux 中,您可以这样做:

cd /home/karthik/Play2.4/Directory/target/
ls -l

如果.history 是一个文件,则响应类似于

-rw-rw-r-- 1 karthik karthik  961 Aug 30 18:26 .history

rw表示读写,2个名字是用户名和组名

【讨论】:

当我检查权限是这样的。我现在需要做什么? -rw-r--r-- 1 根根 29 Aug 31 12:50 .history 这意味着只有root才能在这个文件夹中写入。我假设您已经登录并以 karthik 身份运行 intellij。你有这些文件归 root 拥有的原因吗?我建议将 Play2.4 文件夹的所有权更改为您的用户名。例如sudo chown -R karthik:karthik /home/karthik/Play2.4。我不建议以 root 身份运行 Intellij。【参考方案2】:

我也遇到了同样的问题,正如 Manos Nikolaidis 所说,问题出在文件权限上。 为了快速解决这个问题,我尝试以root用户权限运行idea,并能够正常导入项目。

我用来做的命令在这里(来自idea root/bin目录):

sudo ./idea.sh

【讨论】:

以上是关于Intellij 无法导入 SBT 项目的主要内容,如果未能解决你的问题,请参考以下文章

IntelliJ 无法解析 Activator-Play build.sbt libraryDependencies

如何使用 IntelliJ Idea 创建 SBT 项目?

SBT 项目刷新失败 [IntelliJ、Scala、SBT]

IntelliJ Idea 找不到 sbt-idea-compiler-indices

IntelliJ 中 SBT 项目的未解析依赖路径

IntelliJ 在创建 Scala 项目后在 build.sbt 中给出“无法解析符号”的错误