-
Notifications
You must be signed in to change notification settings - Fork 251
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
nixpack plan
generates an invalid toml file for python projects containing a .tool-versions
file.
#1241
Comments
…python projects containing a .tool-versions file. I assume that outputting those lines before the toml or json file is not intended. If it is then please ignore this commit. Another option might be to print these messages to stderr instead?
To me, it seems like the behavior of printing out the output as it does, is correct in normal cases. Rather, you are really saying that if the toml flag is present, the output should be only toml. So instead of removing the println, maybe it is better to output it only on specific output formats? That seems like an overly complex refactoring to make possible. So instead, either Coolify should fix this bug (since this is more a coolify bug) or, maybe a new flag is added that lets you output the plan to a file and have coolify parse that file (this is much easier logic to add in and I could see other use cases of this feature.) |
I don't think the format is important here. I thought the toml flag would cause the command to output just the toml file and the default json flag to output just the json file. I believe that a command line utility is more useful if it is easy to intergrate into other systems. When choosing between behaviour A "the command outputs a file in json/toml format" or behaviour B "the command outputs a file in json/toml format, but occasionally also outputs a few lines of english text", the first option seems more intuitive, easier to use and less error prone. With behaviour A a user can just
With behaviour B every user that tries to use the output of
Of course Coolify could implement something like this and as a Coolify user I am happy as long as my deploys work again, but I believe that making How would you feel about changing the When comparing this to the solution of adding a new flag to write the plan to a file, this might require changing more parts of the code and is in case any breaking change if any downstream application actually relies on parsing those messages. On the other hand being able to directly use the output
You could also consider to print something like "Build plan:" before outputting the json/toml. This would make it easier for downstream applications to find the start of the plan file, but this would surely break some downstream applications and is still more complicated than just capturing the output and passing it to a json/toml parser. |
I looked at some projects, that rely on nixpacks. Most don't use Also none of the tutorials and blogposts I found show anything but the json as output or mention that there might be some other output before it, which makes it very easy for other projects trying to use the command to produce the same bug. |
You are right. The python provider is very inconsistent here. Other providers don't seem to have this problem (technically, there are other providers that throw up warning but not errors into println. But more on that in a sec). In part, this is due to the python ecosystem. But regardless of that, you are right. The command should just output the raw valid parsable output. I would still love a way to get that info for debug reasons (since versions can be defined in so many different files ...) Making the debug info go to stderr isn't a great solution, since some other programs process any stderr as a failure of some type. Or at the very least, they complain about it. So that change makes sense for the other providers that have warnings but just provide default values. Regardless of that, I think you are right that the default behavior of that plan flag should just generate the parsable plan. The other stuff is just implementation details. |
Thanks for the insight regarding the other providers and the programs interpreting stdout as an error. Maybe a command line option ( |
I created a PR that cleans up more offenders. I ended up skipping the |
Is there an existing issue for this?
Describe the bug
When running
nixpack plan -f toml
in a directory containing a Poetry project and a .tool-versions file nixpacks outputs a line before it outputs the .toml-file:This breaks the deployment code in Coolify, because Coolify will read the output and try to parse it as toml.
I expect the same problem to occur with the json output format.
To reproduce
touch pyproject.toml poetry.lock
echo "poetry 1.8.5" > .tool-versions
nixpacks plan -f toml .
Expected behavior
I would expect nixpacks to output just the toml file of the build plan.
Environment
On the host:
In the container:
The text was updated successfully, but these errors were encountered: