asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
439 stars 107 forks source link

Ruby 3.3 warns about base64 being missing from gemspec #464

Closed craigscott-crascit closed 3 months ago

craigscott-crascit commented 3 months ago

After updating to Ruby 3.3.0, I started seeing the following warning:

warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec. Also contact author of asciidoctor-diagram-2.3.0 to add base64 into its gemspec.

The end of that warning seems fairly self-explanatory. Looks like base64 needs to be added to the gemspec here.

mojavelinux commented 3 months ago

The correct fix is to remove the use of base64 entirely and use the lower-level [bindata].pack 'm0' call instead (which does exactly the same thing). Ruby introduced a unnecessary incompatibility in a minor release when they removed base64 from stdlib. It cannot simply be fixed by adding the base64 dependency since that it creates a packaging conflict for Ruby < 3.3.

See https://github.com/asciidoctor/asciidoctor/pull/4562 for reference.

pepijnve commented 3 months ago

I ended up using https://github.com/subvisual/ruby-radix-encoding. The encoding for PlantUML is actually not RFC 4648 base64. The author used a different alphabet.

pepijnve commented 3 months ago

I was just reviewing the dependencies of that gem... I'm going to have to inline it most likely because it pulls in way too much other stuff. Don't want an activesupport dependency...

pepijnve commented 3 months ago

pack('m0') followed by a tr to swizzle the alphabet did the trick