Skip to content

lune: require(script.Parent.) fails because script is nil #21

Description

@westurner

Trying to run jest-lua in lune (with wally and rojo)

  • Wally installs packages into ./DevPackages/_Index/... and ./Packages/_Index/..., and creates aliases to require instead:
    For example:
    -- ./DevPackages/Jest.lua
    return require(script.Parent._Index["jsdotlua_jest@3.10.0"]["jest"])

But require(script.Parent) fails with:

[string "game/DevPackages/Jest.lua"]:1: attempt to index nil with 'Parent'

Could or should lune set script so that script.Parent works?

Activity

  1. westurner commented on Jun 14, 2025

    @westurner
    Author

    I'm probably doing this wrong, and it's not even supposed to work; but run-in-roblox fails on linux (due to the roblox-install crate not yet supporting vinegar or vinegar flatpak) so I thought I'd try running jest in lune.

    (Copilot) hacked at this for a minute, so it has the pcall and the comment about Packages.Project (which is necessary due to Rojo/wally iiuc?)

    local ReplicatedStorage = nil
    local runCLI = nil
    
    local isLune = (_VERSION:gmatch("Lune")() == "Lune")
    if isLune then 
    	-- local roblox = nil
    	-- local ok, mod = pcall(require, "@lune/roblox")
    	-- if ok then
    	-- 	roblox = mod
    	-- else
    	-- 	print("ERROR: require('@lune/roblox') failed")
    	-- end
    	local roblox = require("@lune/roblox")
    	local Instance = roblox.Instance
    
    	local game = Instance.new("DataModel")
    	local _workspace = game:GetService("Workspace")
    
    	print("DEBUG: @lune/roblox: game=Instance.new('DataModel') => " .. tostring(game) .. " type=" .. typeof(game))
    	assert(game ~= nil)
    
    
    
    	-- Create ReplicatedStorage, DevPackages, and Packages folders
    	-- ReplicatedStorage = Instance.new("Folder")
    	-- ReplicatedStorage.Name = "ReplicatedStorage"
    
    	ReplicatedStorage = Instance.new("ReplicatedStorage")
    	--game.ReplicatedStorage = ReplicatedStorage
    
    	local DevPackages = Instance.new("Folder")
    	DevPackages.Name = "DevPackages"
    	DevPackages.Parent = ReplicatedStorage
    
    	local Packages = Instance.new("Folder")
    	Packages.Name = "Packages"
    	Packages.Parent = ReplicatedStorage
    
    	-- Insert Jest as a ModuleScript-like table
    	--local jestModule = require("./stemgame/DevPackages/_Index/jsdotlua_jest@3.10.0/jest/src/init.lua")
    	local jestModule = require("./DevPackages/Jest")
    	DevPackages.Jest = jestModule -- TODO: this is going to fail
    
    	-- Is there a way to rojo_require("./default.project.json") here
    	-- Or is it better or only possible to create the .rblxm with rojo and then deserializePlace(place.rblx)
    
    
    
    	-- You may need to insert your Project module into Packages.Project here if your tests require it
    	-- Example: Packages.Project = require("path/to/your/project/init.lua")
    
    	runCLI = DevPackages.Jest.runCLI
    else
    	ReplicatedStorage = game:GetService("ReplicatedStorage")
    	runCLI = require(ReplicatedStorage.DevPackages.Jest).runCLI
    end
    
    local processServiceExists, ProcessService = pcall(function()
    	return game:GetService("ProcessService")
    end)
    
    local status, result = runCLI(ReplicatedStorage.Packages.Project, {
    	verbose = true,
    	ci = false
    }, { ReplicatedStorage.Packages.Project }):awaitStatus()
    
    if status == "Rejected" then
    	print(result)
    end
    
    if status == "Resolved" and result.results.numFailedTestSuites == 0 and result.results.numFailedTests == 0 then
    	if processServiceExists then
    		ProcessService:ExitAsync(0)
    	end
    end
    
    if processServiceExists then
    	ProcessService:ExitAsync(1)
    end
    
    return nil

    (Perhaps pesde would be easier for this. Though FWIU pesde supports installing wally packages (and git repos) but not rojo sync?)

  2. westurner commented on Jul 4, 2025

    @westurner
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions