Permission denied in Bitbucket pipeline - composer-php

I am having trouble getting a bitbucket pipeline to run correctly, it keeps throwing a permission denied error and I can't for the life of me see why?
This is my composer file:
{
"name": "pswebsolutionsltd/psadoptables",
"description": "Framework for Building Adoptable Sites",
"version": "0.0.1",
"type": "project",
"homepage": "https://www.pswebsolutions.co.uk/",
"authors": [
{
"name": "Paul Cook",
"email": "paul.cook#pswebsolutions.co.uk",
"homepage": "https://www.pswebsolutions.co.uk/"
}
],
"support": {
"issues": "https://bitbucket.org/pswebsolutionsltd/psadoptables/issues?status=new&status=open",
"wiki": "https://bitbucket.org/pswebsolutionsltd/psadoptables/wiki/",
"source": "https://bitbucket.org/pswebsolutionsltd/psadoptables/src"
},
"scripts": {
"test": [
"#clean",
"#load",
"#clearCache",
"#phpCS",
"#phpUnit",
"#phpDoc"
],
"clean": "composer clear-cache",
"load": "composer dump-autoload -o",
"clearCache": "rm -rf cache && mkdir cache",
"phpUnit": "phpunit --configuration phpunit.xml tests",
"phpDoc": "phpdoc",
"phpCS": "phpcs --config-set default_standard PSR2 phpcs src/ --extensions=php && phpcs tests/ --extensions=php",
"phpCBF": "phpcbf ./ --extensions=php"
},
"autoload": {
"psr-4": {
"AdoptableFramework\\": "src/",
"AdoptableFramework\\Tests\\": "tests/",
"AdoptableFramework\\Extend\\": "src/extend/"
}
},
"require": {
"matthiasmullie/minify": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "5.7",
"phpdocumentor/phpdocumentor": "2.*",
"squizlabs/php_codesniffer": "3.*"
}
}
This is my bitbucket pipeline config file:
P S Adoptable build configuration for PHP.
pipelines:
default:
- step:
name: php56-mysql57
image: php:5.6-apache
script:
# update apt
- apt-get update && apt-get install -y unzip
# install mysqli
- apt-get install -y mysql-client
- docker-php-ext-install mysqli
# install and configure composer
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install --no-interaction --no-progress --prefer-dist
- composer test
services:
- mysql57
definitions:
services:
mysql57:
image: mysql:5.7
environment:
MYSQL_DATABASE: psadoptables
MYSQL_ROOT_PASSWORD: root
The output is:
sh: 1: phpcs: Permission denied
Script phpcs --config-set default_standard PSR2 phpcs src/ --extensions=php && phpcs tests/ --extensions=php handling the phpCS event returned with error code 126
Is there some trick I am missing? Any help would be greatly appreciated!

I would suspect the permission of composer in /usr/local/bin or the directory itself. For debugging you could add a "ls -l /usr/local/bin/composer" in the pipeline config, right after the installation of composer.

Related

Github action deployment fails because of not matching composer-runtime-api ^2.0.0 but actions/checkout#v2 is used

Github action deployment fails because of not matching composer-runtime-api ^2.0.0 even though actions/checkout#v2 is used that uses composer v2
laravel.yml:
name: Deploy to staging
on:
push:
branches: [ staging ]
jobs:
vapor:
name: Check out, build and deploy using Vapor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: ubient/laravel-vapor-action#master
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
with:
args: "deploy staging"
composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.4",
"aws/aws-sdk-php": "3.166.2",
"barryvdh/laravel-dompdf": "^0.8.7",
"bensampo/laravel-enum": "^3.2.0",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/helpers": "^1.3",
"laravel/sanctum": "^2.4",
"laravel/tinker": "^2.5",
"laravel/vapor-cli": "^1.12",
"laravel/vapor-core": "^2.8",
"laravel/vapor-ui": "^1.0",
"owen-it/laravel-auditing": "^10.0",
"pusher/pusher-php-server": "^4.1",
"sentry/sentry-laravel": "^2.3",
"spatie/laravel-permission": "^3.16",
"spatie/laravel-tags": "^2.7"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.8",
"beyondcode/laravel-dump-server": "^1.4",
"facade/ignition": "^2.5",
"fzaninotto/faker": "^1.9.1",
"laravel/horizon": "^5.6",
"laravel/sail": "^1.1",
"laravel/telescope": "^4.4.0",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": [
"barryvdh/laravel-ide-helper",
"laravel/telescope"
]
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"classmap": [
],
"files": [
"bootstrap/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"#php artisan ide-helper:generate",
"#php artisan ide-helper:meta"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
error:
Building project...
==> Validating Manifest File
==> Copying Application Files
==> Harmonizing Configuration Files
==> Setting Build Environment
==> Executing Build Commands
==> Running Command: composer install --no-dev
Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for jean85/pretty-package-versions 2.0.3 -> satisfiable by jean85/pretty-package-versions[2.0.3].
- jean85/pretty-package-versions 2.0.3 requires composer-runtime-api ^2.0.0 -> no matching package found.
Problem 2
- jean85/pretty-package-versions 2.0.3 requires composer-runtime-api ^2.0.0 -> no matching package found.
- sentry/sentry 3.2.0 requires jean85/pretty-package-versions ^1.5|^2.0.1 -> satisfiable by jean85/pretty-package-versions[2.0.3].
- Installation request for sentry/sentry 3.2.0 -> satisfiable by sentry/sentry[3.2.0].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
The deployment command is 'composer install --no-dev' . At first, I was using actions/checkout#v1 when having this error, then I moved to actions/checkout#v2 once I understood that composer v2 is on checkout#v2 vs v1 on checkout#v1, but the problem persists... Any hints on why this is happening would be welcome.
Edit: I am able to run the deployment from my local device without any issues(once I moved to composer v2).
as #bk2204 helped me to realize my faulty assumption that checkout#v2 sets composer to v2 I was able to resolve my problem by changing the laravel.yml deployment instructions as follows:
name: Deploy to staging
on:
push:
branches: [ staging ]
jobs:
vapor:
name: Check out, build and deploy using Vapor
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup PHP (w/ extensions) & Composer
uses: shivammathur/setup-php#v2
with:
php-version: 7.4
tools: pecl
extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo, tokenizer, xml, zip, pcntl
coverage: none
- name: Obtain Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache#v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Vapor CLI Globally
run: composer global require laravel/vapor-cli
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader --no-dev
- name: Deploy using Laravel Vapor
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
run: /home/runner/.composer/vendor/bin/vapor deploy staging

Prefixes when using docker-compose run -rm

I am working on a PHP project using Laravel and I have several utilities in my docker-compose:
composer:
image: composer:latest
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
networks:
- laravel
npm:
image: node:13.7
container_name: npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ["npm"]
With this I have to prefix each command with docker-compose run -rm such as:
docker-compose run -rm npm update
Is there a way to simply have an environment that set some aliases (npm, grunt, composer, mysql...) when I am in that project in VSCode?
You can add a task in VS code
Lots of tools exist to automate tasks like linting, building, packaging, testing, or deploying software systems. Examples include the TypeScript Compiler, linters like ESLint and TSLint as well as build systems like Make, Ant, Gulp, Jake, Rake, and MSBuild.
VScode Task
it should be placed inside .vscode
├── docker-compose.yml
└── .vscode
└── tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "docker-compose run ${input:npm}",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "composer",
"type": "shell",
"command": "docker-compose run ${input:compose}",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"inputs": [
{
"id": "npm",
"description": "npm argument:",
"default": "npm",
"type": "promptString"
},
{
"id": "compose",
"description": "compose argument:",
"default": "composer",
"type": "promptString"
}
]
}
Now All set, all you need to press
Ctrl+Shift+B and both task will be listed, select and execute the task.

Can only install one of error when installing telegram-bot/api

I'm trying to install telegram-bot/api on Centos7/PHP5.6, I'm getting this error when running "php composer.phar require telegram-bot/api"
# php composer.phar require telegram-bot/api
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^2.3 for telegram-bot/api
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Can only install one of: telegram-bot/api[v2.3.0, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.1, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.10, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.11, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.12, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.13, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.2, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.3, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.4, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.5, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.6, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.7, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.8, 1.0.x-dev].
- Can only install one of: telegram-bot/api[v2.3.9, 1.0.x-dev].
- Installation request for telegram-bot/api 1.0.x-dev -> satisfiable by telegram-bot/api[1.0.x-dev].
- Installation request for telegram-bot/api ^2.3 -> satisfiable by telegram-bot/api[v2.3.0, v2.3.1, v2.3.10, v2.3.11, v2.3.12, v2.3.13, v2.3.2, v2.3.3, v2.3.4, v2.3.5, v2.3.6, v2.3.7, v2.3.8, v2.3.9].
Installation failed, reverting ./composer.json to its original content.
Edit: As olibiaz suggested, I'm adding composer.json, which I've downloaded using this repo https://github.com/TelegramBot/Api:
{
"name": "telegram-bot/api",
"description": "PHP Wrapper for Telegram Bot API",
"keywords": [
"php",
"telegram",
"bot",
"bot api"
],
"homepage": "https://github.com/TelegramBot/Api",
"license": "MIT",
"authors": [
{
"name": "Ilya Gusev",
"email": "mail#igusev.ru",
"homepage": "https://php-cat.com",
"role": "Developer"
}
],
"require": {
"php" : ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit" : "~4.0",
"squizlabs/php_codesniffer": "2.*",
"codeception/codeception": "*"
},
"autoload": {
"psr-4": {
"TelegramBot\\Api\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"TelegramBot\\Api\\Test\\": "tests"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
}
}
I've tried specifying the version of telegram-bot/api to use v2.3.9 but I still receive the same error: - Can only install one of: telegram-bot/api[v2.3.9, 1.0.x-dev].
I don't know what else I'm missing, I've already spent a lot of time looking for how to troubleshoot
I fixed it changing the name in composer.json to something like:
"name": "telegram-bot/api_project",

how to install magento2

Is there a way to install magento2 using composer? I found a command
composer create-project magento/community-edition ./ -s dev --prefer-dist
but is that somehow possible with just a composer.json and then
composer install
? I tried this:
{
"name": "asfasf",
"require": {
"magento/magento-composer-installer": "*",
"magento/product-community-edition": "0.1.0-alpha89"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.magento.com/"
}
],
"extra": {
"magento-root-dir": "htdocs",
"magento-deploystrategy": "copy"
},
"minimum-stability": "dev"
}
but that throws an error
[Composer\Downloader\TransportException]
Your configuration does not allow connections to http://packages.magento.com/packages.json.
any hints on what I'm doing wrong?

fatal: No such remote 'composer'

probably duplicate but still no answer Getting a “No such remote or remote group” error when trying to use a private repo in Composer
composer doesn't work again -_-
I have removed composer's cache using rm -rf ~/.composer/cache/ but the result didn't change !
the error with the exception trace :
$sudo composer update --prefer-dist -v
[sudo] password for mahdi:
Loading composer repositories with package information
Password for 'https://MahdiZ#bitbucket.org':
Reading composer.json of mysepandar/interfaces (start_repo)
Skipped tag start_repo, invalid tag name
Reading composer.json of mysepandar/interfaces (master)
Importing branch master (dev-master)
Password for 'https://MahdiZ#bitbucket.org':
Reading composer.json of mahdiz/tf-component-1 (master)
Importing branch master (dev-master)
Password for 'https://MahdiZ#bitbucket.org':
Reading composer.json of mahdiz/flat-config (master)
Importing branch master (dev-master)
Password for 'https://MahdiZ#bitbucket.org':
Reading composer.json of mahdiz/easy-two-factor (master)
Importing branch master (dev-master)
Updating dependencies (including require-dev)
Adding VCS repository bower-asset/yii2-pjax
Adding VCS repository bower-asset/punycode
Adding VCS repository bower-asset/jquery
Adding VCS repository bower-asset/typeahead.js
Reading bower.json of bower-asset/jquery (2.1.3)
Importing tag 2.1.3 (2.1.3.0)
Adding VCS repository bower-asset/jquery.inputmask
Reading bower.json of bower-asset/jquery.inputmask (3.1.61)
Importing tag 3.1.61 (3.1.61.0)
Reading bower.json of bower-asset/punycode (v1.3.2)
Importing tag v1.3.2 (1.3.2.0)
Adding VCS repository bower-asset/bootstrap
Reading bower.json of bower-asset/bootstrap (v3.3.2)
Importing tag v3.3.2 (3.3.2.0)
Reading bower.json of bower-asset/typeahead.js (v0.10.5)
Importing tag v0.10.5 (0.10.5.0)
- Updating mysepandar/interfaces dev-master (d9a7453 => 526a6d7)
Checking out 526a6d733f50ec5076cc3cba2c9d1c11cde2c484
[RuntimeException]
Failed to execute git remote set-url composer 'https://MahdiZ#bitbucket.org/mysepandar/interfaces.git' && git fetch composer && git fetch --tags composer
fatal: No such remote 'composer'
Exception trace:
() at phar:///usr/local/bin/composer/src/Composer/Util/Git.php:201
Composer\Util\Git->throwException() at phar:///usr/local/bin/composer/src/Composer/Util/Git.php:154
Composer\Util\Git->runCommand() at phar:///usr/local/bin/composer/src/Composer/Downloader/GitDownloader.php:88
Composer\Downloader\GitDownloader->doUpdate() at phar:///usr/local/bin/composer/src/Composer/Downloader/VcsDownloader.php:116
Composer\Downloader\VcsDownloader->update() at phar:///usr/local/bin/composer/src/Composer/Downloader/DownloadManager.php:255
Composer\Downloader\DownloadManager->update() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:177
Composer\Installer\LibraryInstaller->updateCode() at phar:///usr/local/bin/composer/src/Composer/Installer/LibraryInstaller.php:106
Composer\Installer\LibraryInstaller->update() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:172
Composer\Installer\InstallationManager->update() at phar:///usr/local/bin/composer/src/Composer/Installer/InstallationManager.php:139
Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/composer/src/Composer/Installer.php:578
Composer\Installer->doInstall() at phar:///usr/local/bin/composer/src/Composer/Installer.php:225
Composer\Installer->run() at phar:///usr/local/bin/composer/src/Composer/Command/UpdateCommand.php:140
Composer\Command\UpdateCommand->execute() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:874
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:147
Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:84
Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:43
require() at /usr/local/bin/composer:25
and my composer.json is :
{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Application Template",
"keywords": [
"yii2",
"framework",
"basic",
"application template"
],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "vcs",
"url": "https://MahdiZ#bitbucket.org/mysepandar/interfaces.git"
},
{
"type": "vcs",
"url": "https://MahdiZ#bitbucket.org/MahdiZ/tfcomponenti.git"
},
{
"type": "vcs",
"url": "https://MahdiZ#bitbucket.org/MahdiZ/flatconfig.git"
},
{
"type": "vcs",
"url": "https://MahdiZ#bitbucket.org/MahdiZ/easytwofactor.git"
}
],
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"mahdi-zareie/yii2-general-base-classes": "dev-master",
"mysepandar/interfaces": "*",
"mahdiz/easy-two-factor": "*",
"mahdiz/tf-component-1": "*",
"mahdiz/flat-config": "*"
},
"require-dev": {
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*"
},
"config": {
"process-timeout": 1800
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
]
},
"extra": {
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
Removing the folder of the package that triggers the error from /vendor worked for me. In your case that would mean removing /vendor/mysepandar/.
Then run composer update again. If that fails update composer using composer self-update and rinse and repeat.

Resources