Cosmos.Executable.Lua 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cosmos.Executable.Lua --version 1.0.0
                    
NuGet\Install-Package Cosmos.Executable.Lua -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cosmos.Executable.Lua" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cosmos.Executable.Lua" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cosmos.Executable.Lua" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cosmos.Executable.Lua --version 1.0.0
                    
#r "nuget: Cosmos.Executable.Lua, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cosmos.Executable.Lua@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cosmos.Executable.Lua&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cosmos.Executable.Lua&version=1.0.0
                    
Install as a Cake Tool

<h1 align="center">Cosmos Lua Interpreter 🚀</h1> <p> <a href="https://www.nuget.org/packages/Cosmos.Executable.Lua/" target="_blank"> <img alt="Version" src="https://img.shields.io/nuget/v/Cosmos.Executable.Lua.svg" /> </a> <a href="https://github.com/CosmosOS/Cosmos.Executable.Lua/blob/main/LICENSE.txt" target="_blank"> <img alt="License: BSD Clause 3 License" src="https://img.shields.io/badge/license-BSD License-yellow.svg" /> </a> </p>

Cosmos.Executable.Lua is a Lua 5.2 interpreter, based on UniLua, made in C# for the Cosmos operating system construction kit.

Usage

Add the package to your kernel .csproj:

<ItemGroup>
    <PackageReference Include="Cosmos.Executable.Lua" Version="1.0.0" />
</ItemGroup>
using System;
using Cosmos.Executable.Lua;

LuaInterpreter lua = new()
{
    WorkingDirectory = "/mnt", // where dofile, require and io.open start relative paths from
};

try
{
    lua.DoString("print('Hello from ' .. _VERSION)");
    lua.DoFile("script.lua", "first argument"); // as `lua script.lua first argument`
    lua.RunPrompt(); // the interactive prompt, until os.exit()
}
catch (LuaException e)
{
    // A syntax error, or a runtime error no pcall caught
    Console.WriteLine(e.Message);
    Console.WriteLine(e.LuaStackTrace);
}
catch (LuaExitException e)
{
    // The script called os.exit(e.ExitCode)
}

A C# function raises a Lua error with state.L_Error(...), or by throwing: a .NET exception becomes a Lua error that pcall catches.

Limitations

The standard libraries are those of Lua 5.2, except io.popen. Lua strings are .NET strings: a character is a UTF-16 code unit, files opened in text mode are UTF-8, and files opened in binary mode ("rb", "wb") map each byte to one character. There is no __gc and no weak tables, so close the files you open. On a Cosmos kernel the local time is UTC and os.getenv returns nil.

Authors

👤 @xebecnan

👤 @valentinbreiz

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

📝 License

Copyright © 2026 CosmosOS.

This project is BSD Clause 3 licensed. It includes UniLua, Copyright © 2013 Sheng Lunan, under the MIT license: see THIRD-PARTY-NOTICES.txt.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1 46 10/2/2026
4.0.0 43 10/2/2026
2.0.0 44 10/1/2026
1.0.0 51 10/1/2026