Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: wrong constant name CDN v2 (NameError) #43

Open
vyankateshmadgundi-ayla opened this issue Sep 7, 2023 · 1 comment
Open

Error: wrong constant name CDN v2 (NameError) #43

vyankateshmadgundi-ayla opened this issue Sep 7, 2023 · 1 comment

Comments

@vyankateshmadgundi-ayla
Copy link

lib/fog/rackspace.rb
service has a wrong model name

service(:cdn_v2, 'CDN v2') service(:compute_v2, 'Compute v2')

Should replace with

service(:cdn_v2, 'CDNV2') service(:compute_v2, 'ComputeV2')

Throwing an error:
/usr/local/bundle/ruby/2.6.0/gems/fog-core-2.3.0/lib/fog/core/provider.rb:49:in `const_defined?': wrong constant name CDN v2 (NameError)

@shoutsid
Copy link

We have also experienced this, to work around this issue, the following is what we have implemented for now.

# file: lib/patches/fog/provider.rb
# frozen_string_literal: true

# This is a monkeypatch to workaround this bug in the Fog-Rackspace gem:
# https://github.com/fog/fog-rackspace/issues/43

module Fog
  module Provider
    # Intercepts constant definition check to correct broken name in Fog gem
    def const_defined?(name, inherit = true)
      Object.const_defined? fixed_constant_name(name), inherit
    end

    # Intercepts constant get to correct broken name in Fog gem
    def const_get(name, inherit = true)
      Object.const_get fixed_constant_name(name), inherit
    end

    private

    # @param [String] name The requested constant name
    # @return [String] The corrected constant name
    def fixed_constant_name(name)
      return 'Fog::Rackspace::CDNV2' if name == 'Fog::Rackspace::CDN v2'
      return 'Fog::Rackspace::ComputeV2' if name == 'Fog::Rackspace::Compute v2'

      name
    end
  end
end
# file: config/application.rb

# Monkeypatch for a bug in the Fog-Rackspace gem
require_relative '../lib/patches/fog/provider'

# Rest of file here....

Looking forward to a fix! 🥳

mshibuya added a commit to carrierwaveuploader/carrierwave that referenced this issue Apr 14, 2024
jongmyung added a commit to StayNTouch/fog-rackspace that referenced this issue Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants