当前位置: 首页 > news >正文

在Trae中使用MoonBit月兔

在MoonBit月兔手册中MoonBit:新手之旅 — MoonBit 月兔 v0.6.22 文档,讲到在VSCode中安装MoonBit月兔插件。于是想到Trae也是VSCode内核,那么在Trae中应该也可以使用MoonBit月兔。

首先启动Trae,发现7.25日升级到2.0.4版本,主要是增加了新模型 Kimi-K2 和 Qwen3-Coder,真是太棒了!但是发现

首先在Trae的插件市场搜索MoonBit,看到有MoonBit 和MoonBit nightly ,先安装普通版吧

安装之后,并没有像roo 、cline等插件那样出现一个插件图标。

让Trae写个demo试试:请帮我用moonbit写一个hello world、

它创建了一个目录,然后提示到目录里执行moon run。可以看到moonbit的代码有高亮提示,证明插件安装成功。

moon run的时候提示需要安装工具链。

安装工具链

在MoonBit中安装工具链moonbit toolchain

在VSCode或Trae中安装:

在搜索栏里,输入>moonbit:

选择:Install moonbit toolchain

感觉这里很不稳定,有时候能出来Install moonbit toolchain ,有时候不出来。

出来Install moonbit toolchain之后,点击,有时候能出来moonbit的配置选项,有时候不出来....

大约是Trae的问题。

在VSCode里面,选择Install moonbit toolchain之后,出现moonbit toolchain的安装提示,经确认后会自动安装。原来这里调用了这句命令:

shell,irm https://cli.moonbitlang.cn/install/powershell.ps1 | iex,

安装的东西挺多,还需要编译,需要一段时间

耗时相当长,反正比安装VSCode或者Clang等时间要长。

安装完毕,重启VSCode,就可以使用moon命令啦!

moon
The build system and package manager for MoonBit.Usage: moon [OPTIONS] <COMMAND>Commands:new                    Create a new MoonBit modulebuild                  Build the current packagecheck                  Check the current package, but don't build object filesrun                    Run a main packagetest                   Test the current packageclean                  Remove the target directoryfmt                    Format source codedoc                    Generate documentationinfo                   Generate public interface (`.mbti`) files for all packages in the modulebench                  Run benchmarks in the current packageadd                    Add a dependencyremove                 Remove a dependencyinstall                Install dependenciestree                   Display the dependency treelogin                  Log in to your accountregister               Register an account at mooncakes.iopublish                Publish the current module

在powershell中用命令安装

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex

我没明白为什么还要再装一下,那moonbit插件是做什么用的?哦,明白了,如果没有自动安装,就用这条命令手动安装,比如Trae里面。

执行demo例子

让Trae生成了一个moonbit的demo,

感觉moonbit真的太复杂了,一个hello world包换了老多文件

主程序main.mbt很简单:

fn main {println("Hello, MoonBit!")
}

但是需要其它文件配合:

E:\moonbit_test>dir驱动器 E 中的卷是 新加卷卷的序列号是 CA89-671DE:\moonbit_test 的目录2025/07/30  23:28    <DIR>          .
2025/07/30  23:28    <DIR>          ..
2025/07/30  23:28    <DIR>          .mooncakes
2025/07/30  23:28                40 main.mbt
2025/07/30  23:28               188 moon.mod.json
2025/07/30  23:28               104 moon.pkg.json
2025/07/30  23:28    <DIR>          target3 个文件            332 字节4 个目录 14,125,985,792 可用字节E:\moonbit_test>tree
卷 新加卷 的文件夹 PATH 列表
卷序列号为 CA89-671D
E:.
├─.mooncakes
└─target└─wasm-gc└─release└─build

执行结果:

moon run main.mbt
Hello, MoonBit!

搞定,收工!

 

调试

 moon run报错Check the spelling of the name

 moon run 
moon: The term 'moon' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

用moon run main.mbt

moon run main.mbt报错error: `` is not a main package

moon run main.mbt
error: `` is not a main package

不知道咋回事,给Trae,让它去修改了。

moon run main.mbt报错Error: Sys_error("E:\\work\\\231\128\155\239\184\191\231\175\132360\\hello_moonbit\\main.mbt: No such file or directory")

moon run main.mbt
failed: moonc build-package -error-format json E:\work\学习360\hello_moonbit\main.mbt -o E:\work\学习360\hello_moonbit\target\wasm-gc\release\build\hello_moonbit.core -pkg hello_moonbit -is-main -std-path C:\Users\Admin\.moon\lib\core\target\wasm-gc\release\bundle -pkg-sources hello_moonbit:E:\work\学习360\hello_moonbit -target wasm-gc

         --  --
       /  //  / __--------_
      /  //  /_/            \
   ---      -                \ __
  / X        /        ____   /   )
  *_________/__/_____/______/ `--

Oops, the compiler has encountered an unexpected situation.
This is a bug in the compiler.

A bug report containing the error description and relevant code would be
greatly appreciated. You can submit the bug report here:

  https://github.com/moonbitlang/moonbit-docs/issues/new?template=ice.md

Error: Sys_error("E:\\work\\\231\128\155\239\184\191\231\175\132360\\hello_moonbit\\main.mbt: No such file or directory")

Compiler args: moonc build-package -error-format json "E:\\work\\瀛︿範360\\hello_moonbit\\main.mbt" -o "E:\\work\\瀛︿ 範360\\hello_moonbit\\target\\wasm-gc\\release\\build\\hello_moonbit.core" -pkg hello_moonbit -is-main -std-path "C:\\Users\\Admin\\.moon\\lib\\core\\target\\wasm-gc\\release\\bundle" -pkg-sources "hello_moonbit:E:\\work\\瀛︿範360\\hello_moonbit" -target wasm-gc

moonc version: v0.6.22
error: failed when building

不能用中文目录

http://www.dtcms.com/a/305513.html

相关文章:

  • 《Computational principles and challenges in single-cell data integration》
  • Map 集合
  • vue 使用postcss-pxtorem 实现适老化
  • Elasticsearch 基础速成 5 步跑通索引、文档、映射与查询
  • 【php 安装 xdebug】
  • 数学建模——最大最小化模型
  • 关于mysql时间类型和java model的日期类型映射
  • anaconda和Miniconda安装包32位64位皆可,anaconda和Miniconda有什么区别?
  • 【33】C# WinForm入门到精通 ——表格布局器TableLayoutPanel【属性、方法、事件、实例、源码】
  • JetBrains Annotations:从入门到落地,彻底告别 NullPointerException
  • Vue路由钩子完全指南
  • Linux ARM 平台 C 语言操作 Excel 文件的常用库与工具汇总(支持 xls 和 xlsx)
  • 【 建模分析回顾】[MultiOutputClassifier]MAP - Charting Student Math Misunderstandings
  • 【硬件-笔试面试题】硬件/电子工程师,笔试面试题-51,(知识点:stm32,GPIO基础知识)
  • Java stream 并发问题
  • 2025年6月电子学会青少年软件编程(C语言)等级考试试卷(二级)
  • 潇洒郎: Kafka Ubuntu 安装部署,命令行或者python生产数据与消费数据(kafka-python)
  • makefile中include *.d文件的作用
  • 安全和AI方向的学习路线
  • aws(学习笔记第五十课) ECS集中练习(2)
  • 项目目标如何拆解,才能提高执行效率和效果
  • 获取TensorRT引擎文件(.engine)版本号的几种方法
  • GitPython02-Git使用方式
  • 【Datawhale AI夏令营】科大讯飞AI大赛(大模型技术)/夏令营:让AI理解列车排期表(Task3)
  • Elasticsearch 全文检索与过滤
  • MyBatis Plus Wrapper 详细分析与原理
  • 设计模式十四:适配器模式(Adapter Pattern)
  • MCP提示词工程:上下文注入的艺术与科学
  • 【计算机视觉与代码大模型全景解析:从理论基础到学习路线】
  • VSCode高效集成开发全流程优化