Problem
A Burrito-wrapped binary does not populate System.argv/0. Arguments arrive
through Burrito.Util.Args.argv/0 instead, and Burrito.Util.running_standalone?/0
is what tells you which mode you are in. Every Cheer app that ships via Burrito
therefore writes the same shim:
defp argv do
if Code.ensure_loaded?(Burrito.Util) and Burrito.Util.running_standalone?() do
Burrito.Util.Args.argv()
else
System.argv()
end
end
tinfoil_demo hand-writes it. hexpm-mcp is about to write the same thing
(joshrotenberg/hexpm-mcp#68). Anyone using the burrito + tinfoil + cheer stack
hits it.
The failure mode when you get it wrong is silent rather than loud: System.argv/0
returns [], every option falls through to its default, and the binary does
something plausible but wrong. In hexpm-mcp's case --transport stdio would
have fallen through to the :http default and started a web server while the
MCP client waited forever for a stdio handshake.
Proposal
@spec argv() :: [String.t()]
def argv()
Returns Burrito.Util.Args.argv/0 when running as a standalone Burrito binary,
System.argv/0 otherwise.
Cheer keeps its zero-runtime-dependency property by resolving Burrito through
Code.ensure_loaded?/1 rather than taking a dep.
Notes
Cheer.main/3 should probably default to this rather than requiring the caller
to pass argv in, though the explicit-argv form has to keep working for tests.
Problem
A Burrito-wrapped binary does not populate
System.argv/0. Arguments arrivethrough
Burrito.Util.Args.argv/0instead, andBurrito.Util.running_standalone?/0is what tells you which mode you are in. Every Cheer app that ships via Burrito
therefore writes the same shim:
tinfoil_demohand-writes it.hexpm-mcpis about to write the same thing(joshrotenberg/hexpm-mcp#68). Anyone using the burrito + tinfoil + cheer stack
hits it.
The failure mode when you get it wrong is silent rather than loud:
System.argv/0returns
[], every option falls through to its default, and the binary doessomething plausible but wrong. In hexpm-mcp's case
--transport stdiowouldhave fallen through to the
:httpdefault and started a web server while theMCP client waited forever for a stdio handshake.
Proposal
Returns
Burrito.Util.Args.argv/0when running as a standalone Burrito binary,System.argv/0otherwise.Cheer keeps its zero-runtime-dependency property by resolving Burrito through
Code.ensure_loaded?/1rather than taking a dep.Notes
Cheer.main/3should probably default to this rather than requiring the callerto pass argv in, though the explicit-argv form has to keep working for tests.