Skip to content

Unable to run the given client example #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
thomas-huegel opened this issue Apr 21, 2025 · 2 comments
Open

Unable to run the given client example #249

thomas-huegel opened this issue Apr 21, 2025 · 2 comments

Comments

@thomas-huegel
Copy link

Describe the bug

.magic/envs/default/lib/mojo/lightbug_http.mojopkg:0:0: error: unknown attribute code: 36
src/main.mojo:2:6: error: failed to materialize top-level module
from lightbug_http.client import Client
     ^
src/main.mojo:2:20: error: 
from lightbug_http.client import Client
                   ^
mojo: error: failed to parse the provided Mojo source module

To Reproduce

from lightbug_http import *
from lightbug_http.client import Client

fn test_request(mut client: Client) raises -> None:
    var uri = URI.parse("google.com")
    var headers = Headers(Header("Host", "google.com"))
    var request = HTTPRequest(uri, headers)
    var response = client.do(request^)

    # print status code
    print("Response:", response.status_code)

    print(response.headers)

    print(
        "Is connection set to connection-close? ", response.connection_close()
    )

    # print body
    print(to_string(response.body_raw))


fn main() -> None:
    try:
        var client = Client()
        test_request(client)
    except e:
        print(e)

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Linux x64
  • mojo 25.2.0
  • lightbug_http 0.1.14
@saviorand
Copy link
Collaborator

@thomas-huegel I was able to reproduce this, seems to do with the small_time dependency. Currently working on including small_time directly, not over magic, hopefully this solves the issue. Will post here when done

@saviorand
Copy link
Collaborator

I shipped some changes in 0.1.19 , now this works on Mac, but I'm getting the following on Linux:

 magic run mojo test.mojo 
/workspaces/codespaces-blank/life/.magic/envs/default/lib/mojo/lightbug_http.mojopkg:0:0: error: unexpected trailing bytes after Attribute entry
/workspaces/codespaces-blank/life/test.mojo:2:6: error: failed to materialize top-level module
from lightbug_http.client import Client
     ^
/workspaces/codespaces-blank/life/test.mojo:2:20: error: 
from lightbug_http.client import Client
                   ^
/workspaces/codespaces-blank/life/.magic/envs/default/bin/mojo: error: failed to parse the provided Mojo source module

Will try to investigate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants