当前位置: 首页 > 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.xdnf.cn/news/1215379.html

相关文章:

  • Android调用python库和方法的实现
  • 三十四、【Linux常用工具】rsync+inotify实时同步演示
  • GitHub使用小记——本地推送、外部拉取和分支重命名
  • Camera相机人脸识别系列专题分析之十九:MTK ISP6S平台FDNode传递三方FFD到APP流程解析
  • git本地仓库,工作区和暂存区的知识
  • llama factory本地部署常见问题
  • 用Python+MySQL实战解锁企业财务数据分析
  • 会吸的簸箕专利拆解:迷你真空组件的吸力控制与吸入口设计原理
  • Redis学习------缓存穿透
  • 数据建模怎么落地?从概念、逻辑到物理模型,一文讲请!
  • Prometheus-2--什么是Exporter是什么?
  • Spring boot 打包成docker image 镜像
  • 数据结构第3问:什么是线性表?
  • (RedmiBook)上禁用触摸板或自带键盘
  • 4.方法的使用
  • OmniParser:提升工作效率的视觉界面解析工具
  • 【深度学习新浪潮】3D城市建筑多样化生产的研发进展调研
  • Kafka 单机多 Broker 实例集群搭建 | 详情
  • 【机器学习】机器学习新手入门概述
  • 如何将DICOM文件制作成在线云胶片
  • React 服务端渲染(SSR)详解
  • Java注解与反射:从自定义注解到框架设计原理
  • 构建智能体(Agent)时如何有效管理其上下文
  • Python奇幻之旅:从零开始的编程冒险
  • 光谱相机自动调焦曝光控制
  • 关于MyBatis 的懒加载(Lazy Loading)机制
  • 基于 Hadoop 生态圈的数据仓库实践 —— OLAP 与数据可视化(六)
  • STM32F1 Flash的操作
  • 如何将word里面的英文引号改为中文引号?如何将Times New Roman字体的符号改为宋体?
  • 1.5.Vue v-for 和 指令修饰符