rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
260 stars 11 forks source link

mist failing to compile when using it as a dependency for the lustre_dev_tools project #52

Closed JGood9001 closed 1 month ago

JGood9001 commented 1 month ago

Hello, I'm new to Gleam.

I'm attempting to use Lustre and the lustre_dev_tools project relies on this project as a dependency.

However, the mist package when ends up in my packages folder doesn't compile due to the following code in ./src/mist/internal/websocket.gleam:

fn unmask_data(
  data: BitArray,
  masks: List(BitArray),
  index: Int,
  resp: BitArray,
) -> BitArray {
  case data {
    <<masked:bits-size(8), rest:bits>> -> {
      let assert Ok(mask_value) = list.at(masks, index % 4)
      let unmasked = crypto_exor(mask_value, masked)
      unmask_data(rest, masks, index + 1, <<resp:bits, unmasked:bits>>)
    }
    _ -> resp
  }
}

The compilation error message is:

/gleam_dev/lustre_play_gleam/build/packages/mist/src/mist/internal/websocket.gleam:44:39
   │
44 │       let assert Ok(mask_value) = list.at(masks, index % 4)
   │                                       ^^^ Did you mean `last`?

The module `gleam/list` does not have a `at` value.

The lustre_dev_tools project lists mist as a dependency in the gleam.toml file as such:

mist = "~> 1.0"

I tried to the version of websocket.gleam on my local computer to what you have in this github repo, and it seems that you've refactored it recently as the unmask_data function is not present in that file now.

Is it possible that whatever solution was implemented for package management has "cached" the previous 1.0.0 version of mist and that the old version is still being pulled down because you haven't bumped the version?

rawhat commented 1 month ago

https://github.com/rawhat/mist/issues/51 see here

JGood9001 commented 1 month ago

Thank you, that worked for me.

u007 commented 1 month ago

is there a command to upgrade packages like ncu with npm?