Closed lost22git closed 2 years ago
@lost4git, everything looks correct in your project setup, but for some reason redbean is not looking in any of the /zip/ folders. This is how the same message looks for me:
E2022-06-07T18:38:56+001281:tool/net/redbean.c:1043:cosmobin:13188] (lua) failed to run lua code: /.init.lua:1: module 'techbench' not found:
no field package.preload['techbench']
no file '/zip/.lua/techbench.lua'
no file '/zip/.lua/techbench/init.lua'
no file '/zip/.lua/techbench.so'
no file '/zip/.lua/loadall.so'
no file './techbench.so'
stack traceback:
[C]: in function 'require'
/.init.lua:1: in main chunk
Notice that in my case it checks /zip/.lua/techbench.lua
, which is where the file is in your case, but in your stacktrace these paths are not listed. Did you build your redbean copy yourself?
$ErrorActionPreference = "Stop"
$redbeanUri = "https://justine.lol/redbean/redbean-latest.com"
$redbeanPath = "./redbean.com"
$redbeanBuildPath = "./redbean-build.com"
$luaPath = "./.lua"
$initLuaPath = "./.init.lua"
if(Test-Path $redbeanBuildPath)
{
Remove-Item $redbeanBuildPath
}
"Checking redbean.com whether exists..."
if(-not $(Test-Path $redbeanPath))
{
"Downloading redbean.com from $redbeanUri to $redbeanPath"
Invoke-WebRequest -Uri $redbeanUri -OutFile $redbeanPath
}
"Creating ./.lua folder..."
if($(Test-Path $luaPath))
{
Remove-Item -Recurse $luaPath
}
mkdir $luaPath
"Copying fullmoon.lua to ./.lua folder..."
Copy-Item "./fullmoon.lua" "$luaPath/fullmoon.lua"
"Copying techbench.lua to ./.lua folder..."
Copy-Item "./examples/techbench.lua" "$luaPath/techbench.lua"
"Generating .init.lua..."
Set-Content -Value "require 'techbench'" -Path $initLuaPath
Write-Host "> Whether to package the resources to redbean.com and start readbean.com (Y/N): " -ForegroundColor Yellow -NoNewline
$toPackage = Read-Host
if(($toPackage -ne "Y") -and ($toPackage -ne "y"))
{
return
}
"Packaging to redbean.com..."
Copy-Item $redbeanPath $redbeanBuildPath
zip $redbeanBuildPath "$luaPath/fullmoon.lua" "$luaPath/techbench.lua"
zip $redbeanBuildPath $initLuaPath
"Starting redbean.com..."
. $redbeanBuildPath -vvmbag
I suspect it's the same issue as #2, as you appear to be using redbean 1.5. I'd expect this to be fixed when redbean 2.0 is out (or if you build redbean with any version 1.6+).
@lost4git, can you re-test with the current redbean version: https://justine.lol/redbean/redbean-latest.com? I expect the issue to be resolved.
@pkulchenko I found that it is already v2.0, but the problem still exists π
D2022-06-14T00:00:45.102047:tool/net/redbean.c:4922:redbean-build:1084] (lua) LuaRunAsset("/.init.lua")
E2022-06-14T00:00:45+000000:tool/net/redbean.c:1047:redbean-build:1084] (lua) failed to run lua code: /.init.lua:1: module 'techbench' not found:
no field package.preload['techbench']
no file '/E/scoop/global/apps/lua/current' // still try to load module from my local lua home?
no file '/E/scoop/global/apps/lua/current'
stack traceback:
[C]: in function 'require'
/.init.lua:1: in main chunk
my build script output
There may be an issue with your build script, try this, (note I use: bash -c './redbean.com -v'
, because I am using zsh.)
git clone git@github.com:pkulchenko/fullmoon.git \
&& cd fullmoon \
&& curl https://redbean.dev/redbean-latest.com >redbean.com \
&& chmod +x redbean.com \
&& mkdir .lua \
&& cp fullmoon.lua .lua \
&& cp examples/techbench.lua .lua \
&& echo 'require "techbench"' >.init.lua \
&& zip redbean.com .init.lua .lua/fullmoon.lua .lua/techbench.lua \
&& bash -c './redbean.com -v'
then to confirm working:
curl http://127.0.0.1:8080/json
@imaitland same problem in WSL π
I can't reproduce this and the script that @imaitland posted works for me.
I don't understand where /E/scoop/global/apps...
path is coming from and why there is no /zip/...
paths that should be added by default: https://github.com/jart/cosmopolitan/blob/master/tool/net/redbean.c#L5199.
In any case, it doesn't seem like it's a fullmoon issue, as your copy of redbean for some reason doesn't set proper lua paths, so the modules are not loaded. I'm a bit at a loss here. Can you run redbean with --ftrace option and check if LuaStart
and GetDefaultLuaPath
functions are on the list?
it works for me now π
Thanks to @pkulchenko for your patient answer
Maybe redbean needs to adjust the priority of the lua path
Yes, we'll have to check on that in redbean; thank you for the update!
Error message
zip -sf redbean-build.com
unzip -lc .\redbean-build.com .init.lua