Grav on Heroku || Permission denied

Hello! I am trying to deploy Grav as a Heroku app but I get this error:

sh: 1: bin/grav: Permission denied

Script bin/grav install handling the compile event returned with error code 126

! Push rejected, failed to compile PHP app.

! Push failed

The full build log is:
`-----> PHP app detected

-----> Bootstrapping…

-----> Installing platform packages…

   NOTICE: No runtime required in composer.json; requirements

   from dependencies in composer.lock will be used for selection

   - php (7.1.8)

   - ext-mbstring (bundled with php)

   - apache (2.4.20)

   - nginx (1.8.1)

! WARNING: Your ‘composer.lock’ is not up to date with the latest

   changes in 'composer.json'. To ensure you are not getting stale

   dependencies, run 'composer update' on your machine and commit

   any changes to Git before pushing again.

-----> Installing dependencies…

   Composer version 1.4.2 2017-05-17 08:17:52

   Loading composer repositories with package information

   Installing dependencies from lock file

   Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

   Package operations: 12 installs, 0 updates, 0 removals

     - Installing psr/log (1.0.2): Loading from cache

     - Installing monolog/monolog (1.22.1): Loading from cache

     - Installing symfony/routing (v3.2.7): Loading from cache

     - Installing symfony/polyfill-mbstring (v1.3.0): Loading from cache

     - Installing symfony/http-foundation (v3.2.7): Loading from cache

     - Installing symfony/event-dispatcher (v3.2.7): Loading from cache

     - Installing symfony/debug (v3.2.7): Loading from cache

     - Installing symfony/http-kernel (v3.2.7): Loading from cache

     - Installing pimple/pimple (v3.0.2): Loading from cache

     - Installing silex/silex (v2.0.4): Loading from cache

     - Installing twig/twig (v2.3.0): Loading from cache

     - Installing symfony/twig-bridge (v3.2.7): Loading from cache

   Generating optimized autoload files

-----> Running ‘composer compile’…

   > bin/grav install

   sh: 1: bin/grav: Permission denied

   Script bin/grav install handling the compile event returned with error code 126

! Push rejected, failed to compile PHP app.

! Push failed`

Any help!

Thanks

Hi!
It seems that you don’t have permission to run it. What user owns the files?
You can check it by running ls -l in the folder.

Did you follow this Heroku guide? https://learn.getgrav.org/webservers-hosting/paas/heroku

1 Like

MakaryGo

rhuk

Thank you for the answers!!

Yes I follow the Heroku guide, and I think I made a mistake - I added all Grav files in the ‘web’ folder instead to delete it…

I am sorry… :slight_smile:

Will try again!

Regards

Same result - I tried to deploy Grav again following the guide step by step but I get the same errors:

   sh: 1: bin/grav: Permission denied

   Script bin/grav install handling the compile event returned with error code 126

This is the second build log:

-----> PHP app detected

-----> Bootstrapping…

-----> Installing platform packages…

   - php (7.1.8)

   - ext-gd (bundled with php)

   - ext-mbstring (bundled with php)

   - apache (2.4.20)

   - nginx (1.8.1)

-----> Installing dependencies…

   Composer version 1.4.2 2017-05-17 08:17:52

   Loading composer repositories with package information

   Installing dependencies from lock file

   Package operations: 27 installs, 0 updates, 0 removals

     - Installing antoligy/dom-string-iterators (v1.0.0): Downloading (100%)

     - Installing doctrine/cache (v1.6.1): Downloading (100%)

     - Installing doctrine/collections (v1.3.0): Downloading (100%)

     - Installing donatj/phpuseragentparser (v0.7.0): Downloading (100%)

     - Installing erusev/parsedown (1.6.2): Downloading (100%)

     - Installing erusev/parsedown-extra (0.7.1): Downloading (100%)

     - Installing psr/log (1.0.2): Loading from cache

     - Installing filp/whoops (2.1.9): Downloading (100%)

     - Installing gregwar/cache (v1.0.12): Downloading (100%)

     - Installing gregwar/image (v2.0.21): Downloading (100%)

     - Installing seld/cli-prompt (1.0.3): Downloading (100%)

     - Installing league/climate (3.2.1): Downloading (100%)

     - Installing matthiasmullie/path-converter (1.1.0): Downloading (100%)

     - Installing matthiasmullie/minify (1.3.45): Downloading (100%)

     - Installing symfony/polyfill-mbstring (v1.4.0): Downloading (100%)

     - Installing symfony/var-dumper (v2.8.22): Downloading (100%)

     - Installing maximebf/debugbar (1.13.1): Downloading (100%)

     - Installing miljar/php-exif (v0.6.3): Downloading (100%)

     - Installing monolog/monolog (1.23.0): Downloading (100%)

     - Installing symfony/yaml (v2.8.22): Downloading (100%)

     - Installing symfony/event-dispatcher (v2.8.22): Downloading (100%)

     - Installing pimple/pimple (v3.0.2): Loading from cache

     - Installing rockettheme/toolbox (1.3.5): Downloading (100%)

     - Installing symfony/debug (v3.0.9): Downloading (100%)

     - Installing symfony/console (v2.8.22): Downloading (100%)

     - Installing symfony/polyfill-iconv (v1.4.0): Downloading (100%)

     - Installing twig/twig (v1.34.3): Downloading (100%)

   Generating optimized autoload files

-----> Running ‘composer compile’…

   > bin/grav install

   sh: 1: bin/grav: Permission denied

   Script bin/grav install handling the compile event returned with error code 126

! Push rejected, failed to compile PHP app.

! Push failed

Hello again!

So I tried and this: I made a setup.php with:

#!/bin/sh
chown -R joeblow:staff .    
find . -type f | xargs chmod 664
find ./bin -type f | xargs chmod 775    
find . -type d | xargs chmod 775
find . -type d | xargs chmod +s    
umask 0002

But the result is still the same…

Could you please give us output of this command?

MakaryGo
rhuk

Please accept my apologies - all problems above were because I did everything wrong - I tried to run Grav directly from GitHub (I don’t have it running locally on my pc…) following the wrong part of the Grav documentation. Today I just cloned the Grav GitHub repository and added in composer.json

"scripts": {
  "compile": [
    "bin/grav install",
    "bin/gpm install admin -y",
    "bin/gpm install antimatter -y"
  ]

}

and I was able to deploy Grav on Heroku.

Regards

Kiril

Hi Guys,

I’ve read the https://learn.getgrav.org/webservers-hosting/paas/heroku, but I’m running into similar problems, trying to deploy to heroku.

composer.json

{
    "name": "getgrav/grav",
    "type": "project",
    "description": "Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS",
    "keywords": ["cms","flat-file cms","flat cms","flatfile cms","php"],
    "homepage": "http://getgrav.org",
    "license": "MIT",
    "require": {
        "php": ">=5.5.9",
        "twig/twig": "~1.24",
        "erusev/parsedown": "~1.6",
        "erusev/parsedown-extra": "~0.7",
        "symfony/yaml": "~2.8",
        "symfony/console": "~2.8",
        "symfony/event-dispatcher": "~2.8",
        "symfony/var-dumper": "~2.8",
        "symfony/polyfill-iconv": "~1.0",
        "doctrine/cache": "1.6.*",
        "doctrine/collections": "1.3",
        "filp/whoops": "~2.0",
        "matthiasmullie/minify": "^1.3",
        "monolog/monolog": "~1.0",
        "gregwar/image": "2.*",
        "donatj/phpuseragentparser": "~0.3",
        "pimple/pimple": "~3.0",
        "rockettheme/toolbox": "~1.0",
        "maximebf/debugbar": "~1.10",
        "ext-mbstring": "*",
        "ext-openssl": "*",
        "ext-curl": "*",
        "ext-zip": "*",
        "league/climate": "^3.2",
        "antoligy/dom-string-iterators": "^1.0",
        "miljar/php-exif": "^0.6.3",
        "composer/ca-bundle": "^1.0"
    },
    "require-dev": {
        "codeception/codeception": "^2.1",
        "phpunit/php-code-coverage": "~2.0",
        "fzaninotto/faker": "^1.5",
        "victorjonsson/markdowndocs": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/trilbymedia/PHP-Markdown-Documentation-Generator"
        }
    ],
    "autoload": {
        "psr-4": {
            "Grav\\": "system/src/Grav"
        },
        "files": ["system/defines.php"]
    },
    "archive": {
        "exclude": ["VERSION"]
    },
    "scripts": {
        "post-create-project-cmd": "bin/grav install",
        "test": "vendor/bin/codecept run unit",
        "test-windows": "vendor\\bin\\codecept run unit",
        "compile": [
            "bin/grav install"
        ]
    },
    "extra": {
        "branch-alias": {
            "dev-develop": "1.x-dev"
        }
    }
}

Procfile

web: vendor/bin/heroku-php-apache2 ./

I’m using the above compile scripts in composer.json but it didn’t solve it, it still says permission denied.

Heroku deploy output:

remote: -----> Running 'composer compile'...
remote:        > bin/grav install
remote:        sh: 1: bin/grav: Permission denied
remote:        Script bin/grav install handling the compile event returned with error code 126
remote:  !     Push rejected, failed to compile PHP app.

Permissions ouput (locally)

$ ls -al
total 1796
drwxr-xr-x 1 ben 1049089       0 Sep 30 08:28 ./
drwxr-xr-x 1 ben 1049089       0 Oct  4 12:38 ../
-rwxr-xr-x 1 ben 1049089 1815925 Sep 30 08:28 composer.phar*
-rwxr-xr-x 1 ben 1049089    2171 Sep 30 08:28 gpm*
-rwxr-xr-x 1 ben 1049089    1408 Sep 30 08:28 grav*
-rwxr-xr-x 1 ben 1049089    4281 Sep 30 08:28 plugin*

What is going on here?
Any help would be much appreciated :slight_smile:

Cheers,
Ben

I’m having this same problem, hopefully someone can help.

OK I’m posting this if some other people also face this problem. I think there is something wrong in the tutorial found from here, or then in the GitHub Heroku php-getting-started repo it suggests to clone. I don’t know what it is but I tried to follow the tutorial several times and always got the permission denied problem. Perhaps someone could check the tutorial and see if there is something to fix.

Anyways, how I got it working was that I just cloned Grav repo to new folder, installed dependencies and ran heroku create. Then I created Procfile manually and entered web: vendor/bin/heroku-php-apache2 ./ there, added the compile scripts to composer.json then just committed changes and pushed to Heroku and it worked. Essentially did everything the tutorial tells you to do, except clone the Heroku php-getting-started repo and use it as a base for Grav installation.

1 Like

Thank you for this. Was struggling to get this to work.

I also added php to the compile commands which seem to resolve the permission errors:

"scripts": {
  "compile": [
    "php bin/grav install",
    "php bin/gpm install admin -y",
    "php bin/gpm install antimatter -y"
  ]
}
1 Like