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

NameError (undefined local variable or method `env' when calling ld_client.variation #160

Closed
everly-blake opened this issue Jun 8, 2020 · 0 comments

Comments

@everly-blake
Copy link

everly-blake commented Jun 8, 2020

Is this a support request?
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here and clicking "submit a request", or by emailing support@launchdarkly.com.

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug
On rails 5.1.6, I am initializing ld_client per the docs on_worker_boot in my puma config. However, whenever I run code that checks ld_client.variation my application throws the above exception, presumably something in the middleware. From my testing, this only happens if ld_client isn't properly instantiated. However, I cannot get ld_client to properly initialize during startup now. This used to only happen occasionally, but now I can't get it to start at all.

To reproduce
Rails 5.1.6 using puma

on_worker_boot do ActiveRecord::Base.establish_connection Rails.configuration.ld_client = LaunchDarkly::LDClient.new(ENV['LAUNCH_DARKLY_SDK_KEY']) end

Simple check somewhere in controller: Rails.configuration.ld_client.variation('synchronous_checkout', current_user, false)

And I get the error every time now.

Expected behavior
true or false returned for that toggle, based on environment/project specific launch darkly settings.

Logs
If applicable, add any log output related to your problem.

SDK version
The version of this SDK that you are using.

Language version, developer tools
ruby 2.5.7
rails 5.1.6
launchdarkly-server-sdk (5.8.0)

OS/platform
OSX Mojave 10.14.1

Additional context
Within a console, if I manually run the initialization code it works, so I don't know if this is something puma specific or what.

LaunchDarklyReleaseBot pushed a commit that referenced this issue Oct 12, 2021
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

1 participant