╰──➤ $ shards build
Dependencies are satisfied
Building: procodile
In src/procodile/cli.cr:99:29
99 | process = ::Process.fork do
^---
Warning: Deprecated Process.fork. Fork is no longer supported.
A total of 1 warnings were found.
I want add --error-on-warnings when build my app on CI, but I want ignore only above Process.fork warning, since as far as I know, there is no replacement for it, how to do that?
I saw --exclude-warnings option, it’s seem like work like this:
Currently there is no mechanism to silence specific deprecation warnings. You can only ignore them on a per-file basis.
With that in mind you could put a method which delegates to the deprecated method in a separate file and then ignore that.
shards build doesn’t have an understanding of the CLI options passed forward to the compiler, so it doesn’t realize the path is a value to the option --exclude-warnings.
You should be able to work around that with the assignment syntax: --exclude-warnings=src/procodile/cli.cr
With that in mind you could put a method which delegates to the deprecated method in a separate file and then ignore that.
Hello, this way work, but, have to add a --exclude-warnings=src/procodile/cli.cr for only suppress this warn is not good for any user which try build my app manually.
Is there a programming(change code) way to solve this? Or add it as a new feature?
If i remember correct, Ruby use a global variable $VERBOSE to control this, it really useful when update to Ruby 3, because there are so many warning info pollute the screen, so, if Crystal can support same way to do this, e.g. add a CRYSTAL_VERBOSE_LEVEL env, then I can define myself version fork instead of monkey patch(replace) core library directly, like following:
class Process
def self.fork(&block) : Process
# new Crystal::System::Process.fork { yield }
old_env = ENV["CRYSTAL_VERBOSE_LEVEL"]
ENV["CRYSTAL_VERBOSE_LEVEL"] = "silent"
previous_def
ENV["CRYSTAL_VERBOSE_LEVEL"] = old_env
end
end