drush en simplesamlphp_auth

results in

include_once(/lib/_autoload.php): failed to open stream: No such file[warning]
or directory simplesamlphp_auth.install:83
include_once(): Failed opening '/lib/_autoload.php' for inclusion    [warning]
(include_path='.:/usr/local/lib/php') simplesamlphp_auth.install:83
Module simplesamlphp_auth doesn't meet the requirements to be        [error]
enabled.
SimpleSAMLphp module requires the simplesamlphp library. See README  [error]
file for installation instructions.

Comments

alberto56 created an issue. See original summary.

alberto56’s picture

Title: include_once(/lib/_autoload.php): failed to open stream » Allow the module to be installed even if SimpleSAMLphp is not available
Category: Bug report » Feature request

Here is the code which fails:


use Drupal\Core\Site\Settings;

...

/**
 * Check if the SimpleSAMLphp library can be found.
 *
 * Fallback for when the library was not found via Composer.
 */
function simplesamlphp_auth_check_library() {
  if (!class_exists('SimpleSAML_Configuration')) {
    $dir = Settings::get('simplesamlphp_dir');
    include_once $dir . '/lib/_autoload.php';
  }
}

alberto56’s picture

I got this to work by adding a line to my settings.php file:


$settings['simplesamlphp_dir'] = '/full/path/to/simplesamlphp-1.15.4';

Only then can I enable the module.

Instead of failing with

include_once(/lib/_autoload.php): failed to open stream

if this has not been done, we might have a message such as:

Cannot find the simplesamlphp library. Either install it with composer or add the following line to your settings.php file:
$settings['simplesamlphp_dir'] = '/full/path/to/simplesamlphp-1.15.4';
Then you will be able to enable the module.
dakku’s picture

@alberto56 it makes sense to fail a little more gracefully and provide a logical message instead of a fatal error. I have personally been caught out by that as well.

I think the solution however needs some thought as we want all dependent functionality to fail instead of just SAML installation.

oknate’s picture

See #2915568: Installing the module causes exception and Drupal whitescreen

I have a patch that adds warnings (for users with access) and prevents WSOD:

      catch (CriticalConfigurationError $e) {
        if (\Drupal::currentUser()->hasPermission('administer simplesamlphp authentication')
          && \Drupal::routeMatch()->getRouteObject()->getOption('_admin_route')) {
          drupal_set_message($this->t('There is a Simplesamlphp configuration problem. ' . $e->getMessage()), 'error');
        }
      }

See https://www.drupal.org/files/issues/2019-02-13/simplesamlphp_auth-fatal-... on comment #31

oknate’s picture

Status: Active » Needs review

If you could please review https://www.drupal.org/files/issues/2019-02-13/simplesamlphp_auth-fatal-...

It takes care of this issue.

oknate’s picture

berdir’s picture

Status: Needs review » Closed (duplicate)

Closing as a duplicate of that other issue, although worth mentioning that it is IMHO a bug in drush that it doesn't check hook_requirements() which should prevent installation if you e.g. to install from the UI.