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

cmsBaseUrl is unavailable or malformed #65

Open
herbdool opened this issue Mar 20, 2020 · 2 comments
Open

cmsBaseUrl is unavailable or malformed #65

herbdool opened this issue Mar 20, 2020 · 2 comments

Comments

@herbdool
Copy link

herbdool commented Mar 20, 2020

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
Copy link
Author

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
Copy link

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.

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

2 participants