【问题标题】:ceylon run: Module default/unversioned not found锡兰运行:未找到模块默认/未版本化
【发布时间】:2017-02-05 05:53:41
【问题描述】:

今天我在我的 macbook 上安装了 intelliJ ceylon IDE。编译我的项目时,我收到以下消息

/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java "-Dceylon.system.repo=/Users/Laust/Library/ApplicationSupport/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/repo" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Users/Laust/Library/Application Support/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/lib/ceylon-bootstrap.jar:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain com.redhat.ceylon.launcher.Bootstrap run --run main default/unversioned
ceylon run: Module default/unversioned not found in the following repositories:
 /Users/Laust/Library/Application Support/IdeaIC2016.
3/CeylonIDEA/classes/embeddedDist/repo
 /Users/Laust/.ceylon/cache
 https://modules.ceylon-lang.org/repo/1
 [Maven] Aether
 [NPM] npm

Process finished with exit code 1

代码在我的另一台计算机(Windows 7)上执行良好。

“模块”文件夹包含以下内容:

default
    default.car
    default.car.sha1
    default.src
    default.src.sha1

还有我的构建配置looks as follows

这是我的代码(在文件 source/main.ceylon 中)

shared void main() {
    print("Generating pretty sweet g-code:");

    {Gcommand+} myGcommands = {
        G00( Vector3(0.0, 0.0, 0.0) ),
        G00( Vector3(9.0, 0.0, 0.0) ),
        G00( Vector3(9.0, 9.0, 0.0) ),
        G00( Vector3(0.0, 9.0, 0.0) ),
        G00( Vector3(0.0, 0.0, 0.0) )
    };

    GcodeProgram myGcodeProgram = GcodeProgram( *myGcommands );

    print(myGcodeProgram.toString());
}

"A carthesian coordinate class"
alias X => Float;
alias Y => Float;
alias Z => Float;
class Vector3(shared X x, shared Y y, shared Z z) {
}

"An abstract spec class for all G-code command classes"
abstract class Gcommand() {
    shared formal String toString();
}

"G-code command for moving in a straight line at rapid speed"
class G00( Vector3 endPoint ) extends Gcommand() {
    toString() => "G0 " + "X" + endPoint.x.string
                        + "Y" + endPoint.y.string
                        + "Z" + endPoint.z.string + "\n";
}

class GcodeProgram( Gcommand+ gcommands ) {

    variable String stringifiedGcodeProgram = "";

    shared String toString() {
        for (gcommand in gcommands) {
            stringifiedGcodeProgram = stringifiedGcodeProgram + gcommand.toString();
        }
    return stringifiedGcodeProgram;
    }
}

【问题讨论】:

    标签: ceylon


    【解决方案1】:

    您提供的屏幕截图显示运行配置不基于任何 IntelliJ 模块(Use classpath of module 设置为 [none])。这意味着配置将不会modules 目录所在的项目文件夹中运行。该目录包含编译后的代码,当您要求ceylon run 运行default 模块时,它会查找该目录。

    一般来说,您应该避免手动创建运行配置。通过单击可运行函数名称旁边的绿色箭头,Ceylon IDE 将自动创建并配置正确的运行配置。

    要修复您现有的运行配置,只需在标记为 Use classpath of module 的字段中选择包含您的代码的 IntelliJ 模块。

    另请参阅getting started guide,了解有关如何开始使用 Ceylon IDE for IntelliJ 的更多信息。

    【讨论】:

    • 如果您选择自动为您构建一个新的、正确的运行配置,请记住在之后(或者之前删除旧的、错误的运行配置,以免混淆它们) .在“运行”->“编辑配置”中执行此操作。
    【解决方案2】:

    这可能是 IntelliJ 插件无法正确处理“默认”模块的错误。我们倾向于不经常使用默认模块,因为它们比常规模块更受限制。

    尝试创建一个模块并将您的代码移至其中。这很可能会解决问题。如果是这样,您可以在此处打开一个问题以修复此错误:https://github.com/ceylon/ceylon-ide-intellij/issues/new

    【讨论】:

    • 这个解释对我来说似乎很投机。看起来更有可能是项目配置的问题。
    【解决方案3】:

    这里的项目设置似乎有问题。请注意正在搜索的 repos 列表:

    Module default/unversioned not found in the following repositories:
     /Users/Laust/Library/Application Support/IdeaIC2016.3/CeylonIDEA/classes/embeddedDist/repo
     /Users/Laust/.ceylon/cache
     https://modules.ceylon-lang.org/repo/1
     [Maven] Aether
     [NPM] npm
    

    我希望看到your-project-dir/modules 形式的回购作为该列表中的第二个条目,但它不存在。

    也就是说,ceylon run 并没有在编译的.car 所在的modules 目录中查找。所以问题是为什么列表中缺少该 repo。

    您在项目结构 > 模块 > Ceylon > 存储库中看到了什么?

    【讨论】:

      【解决方案4】:

      this question 中,第一个(也是唯一一个)答案说明了如何创建新模块。

      我有几个答案:

      • 开始新项目时,您可能不需要为您的模块使用复杂的嵌套命名层次结构。如果您在模块名称中使用句点(例如my.ceylon.example),您会明白这一点,所以我建议您坚持使用简单的名称,例如main
      • 在创建新模块时,将要求您(除其他事项外)指定“可运行单元名称”。该字段的目的是告诉 IntelliJ 在启动程序时应该执行哪些模块类。换句话说,这将成为您程序的入口点。一个合适的名称可能(也)是main
      • Ceylon项目分为模块,模块分为包,包分为类和顶层函数。创建模块时,会在该模块下自动创建一个包。此模块下的代码文件的路径将是“source/moduleName/packageName”。创建新模块时,您无需指定模块中第一个包的名称。相反,包的名称与您的模块名称相同。因此,名为“main”的模块将具有以下路径:source/main/main 作为其代码文件的路径。
      • 在您的新模块文件夹(例如source/main/main)中将创建三个新文件。找到以您之前选择的“可运行单元名称”命名的文件。 你的代码应该进入这个文件。此外,您的代码应该有一个与您选择作为“可运行单元名称”的名称完全相同的类
      • 答案使用了“可运行单元”这个花哨的术语,他只是指包含 Ceylon 代码的文件。
      • 记得在尝试运行新模块之前删除包含旧“默认”模块的文件。
      • 模块名称不能以大写字母开头。
      • modules/ 是编译代码所在的输出目录。它会在项目构建时自动从source/ 中的代码重新创建。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多