sparklemotion / mechanize

Mechanize is a ruby library that makes automated web interaction easy.
https://www.rubydoc.info/gems/mechanize/
MIT License
4.39k stars 473 forks source link

already initialized constant Set::InspectKey #590

Closed kshnyakin closed 2 years ago

kshnyakin commented 2 years ago

Hello guys! Thanks for you work with mechanize! I'm just starting work with it. A have installed gem on pure (rails by $ rails new) and when I try to launch ( $ rails c / s ) meet next problem:

/Users/user/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/user/.rvm/gems/ruby-3.0.0/gems/set-1.0.2/lib/set.rb:815: warning: previous definition of InspectKey was here
/Users/user/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/set.rb:648: warning: already initialized constant Set::InspectKey
/Users/user/.rvm/gems/ruby-3.0.0/gems/set-1.0.2/lib/set.rb:815: warning: previous definition of InspectKey was here
/Users/user/projects/temp/mechanize/config/application.rb:9:in `<top (required)>': Mechanize is not a module
/Users/user/.rvm/gems/ruby-3.0.0/gems/mechanize-2.8.4/lib/mechanize/version.rb:2: previous definition of Mechanize was here (TypeError)

using next gems:

ruby '3.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false

# parser for web-pages
gem 'mechanize'

Maybe someone have met this problem and I make something wrong, or it's really bug, those needed to be fixed.

flavorjones commented 2 years ago

Hi! I'll try to help.

I see this line in your output:

/Users/user/projects/temp/mechanize/config/application.rb:9:in `<top (required)>': Mechanize is not a module

This looks like an error message from code that is doing something like:

module Mechanize
end

because Mechanize is a Class not a Module. If you want to re-open Mechanize in the file temp/mechanize/config/application.rb then you should do it like this:

class Mechanize
end

Does that make sense? The "already initialized constant" messages are just warnings, not errors.