cgi icon indicating copy to clipboard operation
cgi copied to clipboard

Does cgi no longer work?

Open rubyFeedback opened this issue 2 months ago • 0 comments

I have this code in a .cgi file:

#!/usr/bin/ruby -w
# Encoding: UTF-8
# frozen_string_literal: true
# ============================================================================ #
require "cgi"
cgi = CGI.new
value = cgi['field_name'] # => "123"
cgi['flowerpot'] # => ""
fields = cgi.keys # => [ "field_name" ]

cgi.has_key?('field_name') # => true
cgi.include?('field_name') # => true
cgi.include?('flowerpot') # => false

However had this fails via:

/home/x/data/programming/ruby/src/web/lib/web/examples/cgi/006_testing_simple_cgi_params.cgi:9:
warning: assigned but unused variable - value
/home/x/data/programming/ruby/src/web/lib/web/examples/cgi/006_testing_simple_cgi_params.cgi:11:
warning: assigned but unused variable - fields

/home/x/data/programming/ruby/src/web/lib/web/examples/cgi/006_testing_simple_cgi_params.cgi:7:
warning: CGI library is removed from Ruby 3.5. Please use cgi/escape instead for CGI.escape and CGI.unescape features.

  If you need to use the full features of CGI library, Please install cgi gem.
        /home/x/data/programming/ruby/src/web/lib/web/examples/cgi/006_testing_simple_cgi_params.cgi:9:in     '<main>': undefined method '[]' for an instance of CGI (NoMethodError)

  value = cgi['field_name'] # => "123"
             ^^^^^^^^^^^^^^

The cgi code I got from the main README. I swear this used to work in the past, but suddenly it seems I no longer have access to cgi even after installing the gem. Could you guys perhaps add a standalone .cgi file, one that works? For some reason lately I am increasingly getting so many problems with ruby that I did not have in the past. Also with ruby-gtk3 for instance. Are things breaking down suddenly? Or am I the only one with that observation? It does not happen with every gem though, so it seems to be a problem with a few gems more than with all projects. Finding up to date documentation is also becoming harder, many of those externalized gems seem to quickly end up into a non-functional, unmaintained state.

rubyFeedback avatar Oct 04 '25 23:10 rubyFeedback