@app.root needs to be changed to %app.root% to install on Drupal10

Created on 28 January 2023, almost 2 years ago
Updated 16 August 2023, over 1 year ago

Problem/Motivation

Module can't be installed on Drupal 10.0.2. with error :

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The service "library_manager.library_discovery" has a dependency on a non-existent service "app.root". in Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass->processValue() (line 83 of /var/www/html/10_0_2/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php).

Steps to reproduce

I tired to install the module version 2.0.2 with composer and drupal web site. select library_manager and press install buton resulted in error.

Proposed resolution

I modified library_manager.service.yml file like below, it allowed me to install the module successfully.

services:
  library_manager.library_discovery:
    class: Drupal\library_manager\LibraryDiscovery
    arguments: ['@library.discovery.collector', '@module_handler', '@theme_h    andler', '%app.root%']

Because I do not have drupal developping skill, I do not know if this is proper solution or not. I guess no. So I wanted to report this.

thank you very much.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jajamaru09
  • It seems installation was successfully done. I could define my custom libraries from library_manager's standard user interface.
    I could save the definition and some js and css files are properly generated in sites/default/files/libraries/.
    But my custom library files are not loaded when I open node pages.

    I guess this workaround only worked to complete installation process. It does not help this module to work on D10 in my case.

    After installation I tried to use @app.root instead of %app.root% in service.yml file, it resulted in "The website encountered an unexpected error. Please try again later."

  • I found that I made a mistake when I set up the condition of my custom_library definition.
    I should have selected theme properly. Default was claro.

    After I changed @app.root to %app.root% and installed this module without an error, the module function is working properly.

  • πŸ‡¨πŸ‡¦Canada smulvih2 Canada 🍁

    @jajamaru09 can you please create a patch for this and we can get it into the 2.0.x branch for testing? Thanks!

  • @smulvih2
    Since this is my first time to making a patch (acutually using git), if there is something wrong please let me know.

    I uploaeded a patch using a 2.0.x branch.

    What i did
    1. clone 2.0.x branch to local system
    2. modified two files
    2.1 library_manager.info.yml
    2.2 library_manager.services.yml
    3. created a patch with command git diff > 3337149-Drupal10-compatibility-fixes.patch
    4. Upload the patch file with this comment. Test with option: Do not test

    I hope this works. Thank you very much in advance.

  • πŸ‡ΊπŸ‡ΈUnited States hyperlogos

    I don't know if it's the correct way to do it or not, but I do know it worked here

  • Status changed to Needs work over 1 year ago
  • πŸ‡·πŸ‡ΊRussia Chi

    -core_version_requirement: ^8 || ^9 || ^10
    +core_version_requirement: ^9 || ^10

    We need to drop Drupal 8 support in composer.json file as well.

    • smulvih2 β†’ committed ec9f6a9a on 2.0.x
      Issue #3337149 by jajamaru09: @app.root  needs to be changed to %app....
  • Status changed to Fixed over 1 year ago
  • πŸ‡¨πŸ‡¦Canada smulvih2 Canada 🍁

    Committed and attributed! Will push a new 2.0.3 release now.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024