Can't run Composer -- directories and files owned by "web"

I’ve got a trial Professional account. In an SSH session, I want to add a module to a Drupal site using Composer:

 composer require drupal/admin_toolbar

But in the /app directory, the host shows directories and files are owned by “web” so composer.json isn’t writable (and caches can’t be created).

Before I chown everything in /web, is there a Platform.sh way to handle this?

Hi @linkletter - would you mind pasting in a copy of your .platform.app.yaml file?

web@app.0:~$ echo $PLATFORM_APPLICATION | base64 --decode | jq
{
  "resources": null,
  "size": "AUTO",
  "disk": 2048,
  "access": {
    "ssh": "contributor"
  },
  "relationships": {
    "redis": "cache:redis",
    "database": "db:mysql"
  },
  "mounts": {
    "/.console": {
      "source": "local",
      "source_path": "console"
    },
    "/web/sites/default/files": {
      "source": "local",
      "source_path": "files"
    },
    "/tmp": {
      "source": "local",
      "source_path": "tmp"
    },
    "/.drush": {
      "source": "local",
      "source_path": "drush"
    },
    "/drush-backups": {
      "source": "local",
      "source_path": "drush-backups"
    },
    "/private": {
      "source": "local",
      "source_path": "private"
    }
  },
  "timezone": null,
  "variables": {},
  "firewall": null,
  "name": "app",
  "type": "php:7.4",
  "runtime": {
    "extensions": [
      "redis"
    ]
  },
  "preflight": {
    "enabled": true,
    "ignored_rules": []
  },
  "tree_id": "f34a31e6c09107e864075fbc0b9e265977a817f6",
  "slug_id": "q7j4sfsggneps-app-f34a31e6c09107e864075fbc0b9e265977a817f6-64199f2573898b19a4ac5e7bff8e7c72fa1daab5",
  "app_dir": "/app",
  "web": {
    "locations": {
      "/": {
        "root": "web",
        "expires": "5m",
        "passthru": "/index.php",
        "scripts": true,
        "allow": false,
        "headers": {},
        "rules": {
          "\\.(jpe?g|png|gif|svgz?|css|js|map|ico|bmp|eot|woff2?|otf|ttf)$": {
            "allow": true
          },
          "^/robots\\.txt$": {
            "allow": true
          },
          "^/sites/sites\\.php$": {
            "scripts": false
          },
          "^/sitemap\\.xml$": {
            "allow": true
          },
          "^/sites/[^/]+/settings.*?\\.php$": {
            "scripts": false
          }
        }
      },
      "/sites/default/files": {
        "root": "web/sites/default/files",
        "expires": "5m",
        "passthru": "/index.php",
        "scripts": false,
        "allow": true,
        "headers": {},
        "rules": {
          "^/sites/default/files/(css|js)": {
            "expires": "2w"
          }
        }
      }
    },
    "move_to_root": false
  },
  "hooks": {
    "build": "set -e\n",
    "deploy": "set -e\nphp ./drush/platformsh_generate_drush_yml.php\ncd web\ndrush -y cache-rebuild\ndrush -y updatedb\ndrush -y config-import\n",
    "post_deploy": null
  },
  "crons": {
    "drupal": {
      "spec": "*/19 * * * *",
      "commands": {
        "start": "cd web ; drush core-cron",
        "stop": null
      },
      "shutdown_timeout": null
    }
  }
}

Hey @linkletter - I don’t see anything in your build hook, which is the only time the file system is writable.

I’d try either running composer require drupal/admin_toolbar first locally and pushing the updated composer.lock file, or placing that line in your build hook.