Skip to content

Instantly share code, notes, and snippets.

@demeritcowboy
Last active November 13, 2019 02:56
Show Gist options
  • Save demeritcowboy/e1a0b6dbe8149e4f3e04510cf4c3ae80 to your computer and use it in GitHub Desktop.
Save demeritcowboy/e1a0b6dbe8149e4f3e04510cf4c3ae80 to your computer and use it in GitHub Desktop.
Install civicrm on drupal 8 using roundearth on windows - Sept 2019 version

OBSOLETE

Variation of patch below has been merged into the roundearth plugin as of 2019-11-12, so shouldn't need this anymore.


Intro

There's a problem that seems to have been around since about June 2019 where archive_tar is no longer able to extract the civicrm download .tar.gz file on windows so the install fails. These steps will get it installed.

Steps

  • composer create-project roundearth/drupal-civicrm-project:8.x-dev some-dir
    • It will fail with an error about unable to extract.
  • Apply hack patch to vendor/roundearth/civicrm-composer-plugin/src/Handler.php
--- Handler.php
+++ Handler.php.new
@@ -195,8 +195,10 @@
       $this->filesystem->dumpFile($civicrm_archive_file, fopen($civicrm_archive
_url, 'r'));

       $this->output("<info>Extracting CiviCRM {$civicrm_version} release...</in
fo>");
-      $extract_successful = (new \Archive_Tar($civicrm_archive_file, "gz"))->ex
tract($civicrm_extract_path);
-      if (!$extract_successful) {
+      try {
+        $phar = new \PharData($civicrm_archive_file);
+        $phar->extractTo($civicrm_extract_path);
+      } catch (Exception $e) {
         throw new \RuntimeException("Unable to extract: $civicrm_archive_file")
;
       }
  • Delete vendor/civicrm/civicrm-core.
    • This is important because otherwise it won't trigger the plugin to do its thing in the next step.
  • From the root folder where you installed the project, type:
    • composer require civicrm/civicrm-drupal-8
  • Install drupal normally, e.g. visiting http://site/install.php.
  • If logged in to website, logout.
  • From the root folder where you installed the project, type:
    • vendor\drush\drush\drush.bat en -y -l host.name.org civicrm
      • Replace host.name.org with the correct domain name, e.g. example.org. Without the -l parameter you'll probably end up with http://DEFAULT as civi's BASEURL.
  • Log back in
  • The civi menus will look messed up. So as it says in the roundearth readme, update the resource url by going to /civicrm/admin/setting/url?reset=1 and setting the value to [cms.root]/libraries/civicrm.
@demeritcowboy
Copy link
Author

Note to self: The built-in PharData class in php seems able to handle tar and gz natively. Should be able to replace archive_tar completely. This seems to run fine:

try {
  $phar = new PharData('civicrm.tar.gz');
  $phar->extractTo('.');
} catch (Exception $e) {
  echo $e->getMessage();
}

So if can get that into the original plugin shouldn't need the above workaround.

@Sprbb
Copy link

Sprbb commented Sep 19, 2019

after I ran composer require civicrm/civicrm-drupal-8

- Can only install one of: psr/log[1.1.0, 1.0.2].
- Can only install one of: psr/log[1.1.x-dev, 1.0.2].
- Installation request for psr/log (locked at 1.0.2) -> satisfiable by psr/log[1.0.2].

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

@demeritcowboy
Copy link
Author

@basneve
(a) Is this a fresh install from scratch created by the create-project command above? and (b) where are you running it from? It should be the top-level folder of the project.

@demeritcowboy
Copy link
Author

Updated gist with alternate PharData patch. Also see https://gitlab.com/roundearth/civicrm-composer-plugin/merge_requests/8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment