Skip to content
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

Reinstate spago script #1000

Open
f-f opened this issue Sep 18, 2023 · 11 comments
Open

Reinstate spago script #1000

f-f opened this issue Sep 18, 2023 · 11 comments

Comments

@f-f
Copy link
Member

f-f commented Sep 18, 2023

Still needs to be ported from the Haskell implementation, see here

@JordanMartinez
Copy link
Contributor

This may require changes in node-execa first as I don't think it'll handle multi-line shebangs properly right now (or this might only be the case on Windows). See https://github.com/JordanMartinez/purescript-node-execa/blob/master/src/Node/Library/Execa/CrossSpawn.purs#L181-L188

@f-f f-f changed the title Implement spago script Reinstate spago script Sep 29, 2023
@f-f
Copy link
Member Author

f-f commented Jan 14, 2024

This should now be unblocked?

@JordanMartinez
Copy link
Contributor

Yes and no. For Linux/Mac, this is unblocked. For Windows, this is unblocked but may not work correctly in all cases. In node-execa (as noted above), we only read the first 150 bytes of a file. If there are multi-line shebangs that make up the entire command, we'll drop some of that on Windows.

@f-f
Copy link
Member Author

f-f commented Jan 15, 2024

Do we know why that 150? Is that just a number that is deemed "good enough" to read all the shebang lines?

@JordanMartinez
Copy link
Contributor

Is that just a number that is deemed "good enough" to read all the shebang lines?

AFAICT, yes. That's what was in the original code. I can't recall whether there was a comment explaining why.

@f-f
Copy link
Member Author

f-f commented Jan 15, 2024

150 chars should be quite enough for the majority of cases, we can try shipping this and come back to bump it if we ever figure out it's not enough

@JordanMartinez
Copy link
Contributor

It's your call.

@f-f
Copy link
Member Author

f-f commented Jan 16, 2024

Let's

@f-f f-f removed this from the spago-next beta bugs milestone Jul 31, 2024
@fsoikin
Copy link
Collaborator

fsoikin commented Sep 21, 2024

A question/proposal: instead of (or in addition to) specifying package set and dependencies on the command line, how about supporting them via pragmas in the file itself? Haskell Stack does that to an extent, but I don't like the command-line syntax, I think F# does it much better.

And speaking of F#: it has another pragma #load that allows to have multi-module scripts, and could be trivially implemented in Spago - just copy all those #loaded files to the same temp dir.

@f-f
Copy link
Member Author

f-f commented Sep 21, 2024

I don't have a strong opinion on this, except for the fact that whatever we add in .purs files needs to be supported by the parser. E.g. when we introduced spago script for the Haskell implementation we had to patch the parser

@fsoikin
Copy link
Collaborator

fsoikin commented Sep 22, 2024

Yes, of course, the pragmas would look like comments to the compiler.

The Haskell patch was for shebang lines, not the pragmas. Pragmas in Haskell files are also just comments, no patch would be needed for them.

And while I wasn't actually proposing to support shebangs as well, it can also be easily done: as long as we're copying the files to a different location anyway, we can just cut off the shebang lines along the way.

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

No branches or pull requests

3 participants