Is there a good way to validate a YAML locally ? I have several YAML issues in production env on deploy, like
https://gist.github.com/anonymous/78bed61832ff72ff3426
Not very informative, I would like to know the file this happens in. Is is possible to improve debugging yaml issues a bit more?
Also im not sure why this happens only in production and not in development.
I ended up writing a rake task to do this: save as /lib/yaml.rake for example ( .rake ! not .rb)
namespace :yaml do
desc "Test YAML files"
task :check => :environment do
require 'yaml'
d = Dir["./**/*.yml"]
d.each do |file|
begin
puts "checking : #{file}"
f = YAML.load_file(file)
rescue Exception
puts "failed to read #{file}: #{$!}"
end
end
end
end
Well, from my experience tracking down bugs in YAML is not easy. Online tools like yamllint usually give similar error messages like the ones Psych provides.
Only thing I could advise is: check diff from local/production YAML files and see what has changed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.