GithubHelp home page GithubHelp logo

Comments (13)

pkulchenko avatar pkulchenko commented on June 6, 2024 1

Yes, we'll have to check on that in redbean; thank you for the update!

from fullmoon.

pkulchenko avatar pkulchenko commented on June 6, 2024

@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?

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

My build script file (powershell)

image

build.ps1

$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

from fullmoon.

pkulchenko avatar pkulchenko commented on June 6, 2024

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+).

from fullmoon.

pkulchenko avatar pkulchenko commented on June 6, 2024

@lost4git, can you re-test with the current redbean version: https://justine.lol/redbean/redbean-latest.com? I expect the issue to be resolved.

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

@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

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

redbean-build.zip

my build script output

from fullmoon.

imaitland avatar imaitland commented on June 6, 2024

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 [email protected]: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

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

@imaitland same problem in WSL 😂

image

from fullmoon.

pkulchenko avatar pkulchenko commented on June 6, 2024

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?

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

it works for me now 😂

image

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

Thanks to @pkulchenko for your patient answer

from fullmoon.

lost22git avatar lost22git commented on June 6, 2024

Maybe redbean needs to adjust the priority of the lua path

from fullmoon.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.