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

[MultipleFixes] Fixed init-drupal for composer's memory-limit-errors and init-lando for FileNotFoundError #4

Closed
wants to merge 4 commits into from

Conversation

shinde-rahul
Copy link
Contributor

@shinde-rahul shinde-rahul commented May 24, 2020

The PR changes fix for,

  • composer install -o error
% init-drupal --directory=d8-dev --core=core drupal
Initialized empty Git repository in /private/var/www/contrib/d8-dev/.git/
[master (root-commit) 8dc7a87] Initial commit
Deprecation warning: Your package name drupal is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$". Make sure you fix this as Composer 2.0 will error.
   ........
    Finished: success: 37, skipped: 0, failure: 0, total: 37
Loading composer repositories with package information
Updating dependencies (including require-dev)
PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
% 
  • Error generating lando development override configuration file
% init-drupal --directory=d8-dev --lando --no-install drupal
Initialized empty Git repository in /private/var/www/contrib/d8-dev/d8-dev/.git/
[master (root-commit) 248dd89] Initial commit
Adding Lando support...
Traceback (most recent call last):
  File "/usr/local/bin/init-drupal", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/axltempl/drupal.py", line 46, in main
    lando.generateLandoFiles(name, args.docroot, args.cache)
  File "/usr/local/lib/python3.7/site-packages/axltempl/lando.py", line 64, in generateLandoFiles
    util.writeFile(docroot + "/sites/default/settings.lando.php", landoSettings)
  File "/usr/local/lib/python3.7/site-packages/axltempl/util.py", line 17, in writeFile
    with open(file, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'web/sites/default/settings.lando.php'
%
  • composer init-lando error
% init-lando
Traceback (most recent call last):
  File "/usr/local/bin/init-lando", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/axltempl/lando.py", line 30, in main
    generateLandoFiles(name, docroot, cache)
  File "/usr/local/lib/python3.7/site-packages/axltempl/lando.py", line 64, in generateLandoFiles
    util.writeFile(docroot + "/sites/default/settings.lando.php", landoSettings)
  File "/usr/local/lib/python3.7/site-packages/axltempl/util.py", line 17, in writeFile
    with open(file, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'web/sites/default/settings.lando.php'
%

@shinde-rahul shinde-rahul changed the title Composer mem err Fix for init-drupal errors May 24, 2020
@shinde-rahul shinde-rahul changed the title Fix for init-drupal errors [MultipleFixes] Fixed init-drupal for composer's memory-limit-errors and init-lando for FileNotFoundError May 24, 2020
@@ -88,7 +88,9 @@ def main(

if not no_install:
if shutil.which("composer") is not None:
os.system("composer install -o")
status = os.system("composer install -o")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we can use

status = os.system("export COMPOSER_MEMORY_LIMIT=-1; composer install -o")

to set composer environment variable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shinde-rahul, I think it's better to run init-drupal with the variable set. For example, for bash

COMPOSER_MEMORY_LIMIT=-1 init-drupal --directory=d8 --core=core my/site

Copy link
Member

@hussainweb hussainweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be easier to review and merge multiple PRs here rather than just one. Do you mind looking at feedback here and creating them in separate PRs?

@@ -88,7 +88,9 @@ def main(

if not no_install:
if shutil.which("composer") is not None:
os.system("composer install -o")
status = os.system("composer install -o")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shinde-rahul, I think it's better to run init-drupal with the variable set. For example, for bash

COMPOSER_MEMORY_LIMIT=-1 init-drupal --directory=d8 --core=core my/site

@@ -98,7 +100,7 @@ def main(
name = name.split("/")
name = name[1] if len(name) == 2 else name[0]
util.writeInfo("Adding Lando support...")
lando.generateLandoFiles(name, docroot, cache)
lando.generateLandoFile(name, docroot, cache)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shinde-rahul, I'll still keep it plural as there are multiple files to be generated here, not just one.

@@ -56,6 +56,20 @@ def generateLandoFiles(name, docroot, cache):
os.mkdir(".lando")
util.copyPackageFile("files/lando/php.ini", ".lando/php.ini")

# Generate lando development override configuration.
generateLandoDevelopmentSettingsFiles(docroot, cache)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shinde-rahul, any value in this new function? I mean, is there a scenario where we would just call this function and not generateLandoFiles?

Copy link
Contributor Author

@shinde-rahul shinde-rahul May 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging both the functions. This function was called from drupal.py, which is not the case now and do see any call for this.

@shinde-rahul
Copy link
Contributor Author

Closing this PR and the created following two PR's to review,

hussainweb added a commit that referenced this pull request Aug 5, 2020
Fixes #4: Set the default directory based on the package name
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

Successfully merging this pull request may close these issues.

2 participants