Issue #14716 has been updated by fa11enangel (Konstantin Filtschew).


I have the same issue running ruby 2.6.3 on MacOS 10.14.6 while using guard on a rails project:

``` ruby
13:43:07 - INFO - Running: spec/features/foo_spec.rb
Running via Spring preloader in process 17829

Randomized with seed 57737
Capybara starting Puma...
* Version 3.12.1 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:52057
...2019-08-22 11:43:24 +0000: Rack app error handling request { GET /foo/bar }
#<RuntimeError: failed to get urandom>
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/securerandom.rb:104:in `urandom'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/securerandom.rb:104:in `gen_random_urandom'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/securerandom.rb:136:in `random_bytes'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/2.6.0/securerandom.rb:234:in `uuid'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:40:in `internal_request_id'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:35:in `make_request_id'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:26:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/runtime.rb:22:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb:127:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-heartbeat-1.1.0/lib/rack/heartbeat.rb:45:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/urlmap.rb:68:in `block in call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `each'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/urlmap.rb:53:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/capybara-3.26.0/lib/capybara/server/middleware.rb:48:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:227:in `call'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:660:in `handle_request'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:474:in `process_client'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
/Users/me/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
```

Restarting guard helps to fix it temporarily.


----------------------------------------
Bug #14716: SecureRandom throwing an error in Ruby 2.5.1
https://bugs.ruby-lang.org/issues/14716#change-80914

* Author: snehavas (sneha vasanth)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.6.3
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED
----------------------------------------
Hi,

We recently upgraded from ruby 2.3.6 to 2.5.1.
We use SecureRandom.uuid to generate a random number for our session.
Post the upgrade we have been getting the following error intermittently

```
app error: failed to get urandom (RuntimeError)
E, [2018-04-27T04:55:08.741859 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:99:in `urandom'
E, [2018-04-27T04:55:08.741898 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:99:in `gen_random_urandom'
E, [2018-04-27T04:55:08.741932 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:129:in `random_bytes'
E, [2018-04-27T04:55:08.741965 #16550] ERROR -- : /usr/lib/ruby/2.5.0/securerandom.rb:219:in `uuid'
E, [2018-04-27T04:55:08.741997 #16550] ERROR -- : /usr/share/nginx/frontend/app/utilities/log.rb:74:in `create_session_info'
E, [2018-04-27T04:55:08.742036 #16550] ERROR -- : /usr/share/nginx/frontend/app/utilities/log.rb:11:in `context'
```

We understand that there was a change in ruby 2.5.1 where we now look at OS sources as the first point of contact to generate random numbers as opposed to OpenSSL.
Any idea why this could be happening?







-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>