haskell-game/tiny-games-hs

Trouble running matchmaking

toonn opened this issue · 12 comments

toonn commented

Hi, I'm having some trouble getting "matchmaking" to run.

$ ./play matchmaking

prelude/matchmaking/matchmaking.hs:1:2: error:
    parse error on input ‘#!/’
  |
1 | #!/usr/bin/env -S runghc -cpp -DD=a=replicate;b=putStrLn;c=length;p=map;u=max(2)
  |  ^^^

Same error if I run the file directly. (I thought maybe the shebang shenanigans were tripping up the play script.)

$ prelude/matchmaking/matchmaking.hs 

prelude/matchmaking/matchmaking.hs:1:2: error:
    parse error on input ‘#!/’
  |
1 | #!/usr/bin/env -S runghc -cpp -DD=a=replicate;b=putStrLn;c=length;p=map;u=max(2)
  |  ^^^

I'm running this in shell set up with the Nix flake.

Works fine for me on Ubuntu...

~> chmod +x /tmp/matchmaking.hs 
~> /tmp/matchmaking.hs
      H K L M N P R S 
      a l u a o e o a 
      n a j j r t z r 
      n r z a a r a a 
      a a a     a     
Adam  . . . . . . O O   
Bela  O O O O . O O .   
Csaba . O . O . O O .   
David . . . . . O . O   
Erik  . O O O . . O .   
Feri  . . . . O O O .   
Geza  O . O . . O O .   
Imre  . . . O . . . .   
Jeno  O O . . . O . O   

As a workaround, you may succeed with invoking the shebang line directly, optionally bypassing the call to env:

runghc -cpp '-DD=a=replicate;b=putStrLn;c=length;p=map;u=max(2)' prelude/matchmaking/matchmaking.hs

toonn commented

Still the same result when I run the shebang without env from the shell.

$ runghc -cpp '-DD=a=replicate;b=putStrLn;c=length;p=map;u=max(2)' prelude/matchmaking/matchmaking.hs

prelude/matchmaking/matchmaking.hs:1:2: error:
    parse error on input ‘#!/’
  |
1 | #!/usr/bin/env -S runghc -cpp -DD=a=replicate;b=putStrLn;c=length;p=map;u=max(2)
  |  ^^^

Hey, I don't really know what to say here, shebang combination '#!/...' is pretty normal and shouldn't cause errors. Do other entries run normally?

toonn commented

@migmit, yes, I've been able to successfully run all the other medalist entries.

What about brickbreaker?
The only thing I can think about is that your system doesn't like env -S, but brickbreaker also uses it.

toonn commented

I will try when I get access to the machine again but that will take a couple of weeks. I will get back to you : )

I will get back to you : )

Famous last words :)

toonn commented

Thanks for the ping. This fell off the radar.

I remember trying brickbreaker before. It works just fine. I get a white plane with a red circle and a breakout game inside of that. When I break all the bricks the circle turns green.

@toonn the issue here is Nix-specific AFAICS.

Nix does a number of shebang shenanigans: https://nixos.wiki/wiki/Nix-shell_shebang

In particular, I think the Nix's requirement to use #!/usr/bin/env nix-shell simply conflicts with this specific matchmaking game which also uses shebang to pass CPP options.

I'm not a Nix user... but it seems that a sibling file shell.nix may help, via pkgs.mkShell doing the same customization runghc -cpp '-DD=a=replicate;b=putStrLn;c=length;p=map;u=max(2)'

migmit commented

Ahhh... If it's indeed Nix-specific, there is no wonder I couldn't replicate it.

toonn commented

matchmaking.hs doesn't have a nix-shell shebang so I don't see how that relates? I'm also not on NixOS but on macOS using Nix. Nix just provides GHC and cabal-install in this case, the environment is still fairly plain macOS.