Issue #10047 has been updated by Yukihiro Matsumoto.

Status changed from Open to Feedback

If `require` failed, you don't have the features (classes and modules) from the library, so that your program would not work. So I think plain `require_failsafe` is useless.

Matz.


----------------------------------------
Feature #10047: Proposal for failesafe requires
https://bugs.ruby-lang.org/issues/10047#change-47842

* Author: Robert A. Heiler
* Status: Feedback
* Priority: Low
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
Hi guys,

I know this is unlikely to make it in, so it can be closed soon I suppose,
but a short discussion might be useful still?

I am doing something like this here quite often:

begin
  require 'foo_bar'
rescue LoadError; end

One project I use has about 100 of these requires. These projects
are mostly tiny, often consisting of just one file, and it also
is often not important if these are available or not, hence why
there is a silent rescue, so that loading of the main project
can continue unhampered.

But I wondered why I couldn't just use a special call of
require instead.

We have require_relative, so why not something like this:

require_failsafe 'foo_bar'

?

You could even report a string to the user like:

require_failsafe 'foo_bar','please install foo_bar'

yet continue loading.



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