civicrm / cv

CiviCRM CLI Utility
26 stars 29 forks source link

cmsBaseUrl is unavailable or malformed #65

Open herbdool opened 4 years ago

herbdool commented 4 years ago

I'm attempting to install while using Drupal 7 on Lando. This might also be relevant for attempting to install in other containers. I get an error and it fails:

$ lando ssh
www-data@045f79017765:/app$ ./cv core:install
Found code for civicrm-core in /app/sites/all/modules/civicrm
Found code for civicrm-setup in /app/sites/all/modules/civicrm/vendor/civicrm/civicrm-setup
WARNING: (system) CiviCRM memory check: You have -1 allocated (minimum 32Mb, recommended 64Mb)
ERROR: (system) cmsBaseUrl: The "cmsBaseUrl" (http://localhost/././) is unavailable or malformed. Consider setting it explicitly.

I'm guessing it doesn't like the environment variable that Lando is setting. I may attempt to manually set it (though it would be better if we didn't have to). It doesn't say where to set it. Perhaps it requires setting $base_url in settings.php? (Though Lando actually provides 2 options for URLs for the sites).

By the way, I'm sshing to the Lando container so that I can run cv and have it recognize the database.

herbdool commented 4 years ago

Apparently setting $base_url does something but doesn't actually fix the problem:

The "cmsBaseUrl" (https://d-7-civi.lndo.site/) is unavailable or malformed.

justinmosier commented 1 year ago

I ran into a similar issue recently while installing CiviCRM using cv on Drupal 10 via Lando.

I fixed it by moving the cv file to a subfolder within the Lando project, such as "cv-cli/cv" and then calling it this way: lando php cv-cli/cv core:install --cms-base-url=https://example.org

The issue seems to be in: civicrm-core/setup/plugins/checkRequirements/CheckBaseUrl.civi-setup.php

There are two error checks in that file which output the same error message that the cmsBaseURL "is unavailable or malformed."

The second check (below) is the issue when you invoke cv core:install via Lando and the cv file is located in the lando project root...

$selfDir = dirname($_SERVER['PHP_SELF']);
if (PHP_SAPI === 'cli' && $selfDir !== '/' && strpos($model->cmsBaseUrl, $selfDir) !== FALSE) {
  $e->addError('system', 'cmsBaseUrl', "The \"cmsBaseUrl\" ($model->cmsBaseUrl) is unavailable or malformed. Consider setting it explicitly.");
  return;
}

...because $_SERVER['PHP_SELF'] resolves to "./cv" and $selfDir becomes "."

This then throws the error because the code above finds "." in any validly-formed cmsBaseURL passed into it, such as "https://example.org"

Hope that helps.