Composer installs only globally (Windows 10) - composer-php

When I try to install Composer (exe installer, curl, tried all methods), it installs only in C:\ProgramData\ComposerSetup\bin and never localy, even if I run it (obviously) from another directory.
When I run composer init - it does not create json config anywhere, composer install - is installing only in C:/Users/Username/AppData/Roaming/Composer/
D:\test>composer init
←[37;44m ←[39;49m
←[37;44m Welcome to the Composer config generator ←[39;49m
←[37;44m ←[39;49m
This command will guide you through creating your composer.json config.
Package name (<vendor>/<name>) [←[33mUsername/test←[39m]: test/test
Description []:
Author []: test <test#test.test>
Minimum Stability []:
Package Type []:
License []:
Define your dependencies.
Would you like to define your dependencies (require) interactively [←[33myes←[39m]?
Search for a package:
Would you like to define your dev dependencies (require-dev) interactively [←[33myes←[39m]?
Search for a package:
{
"name": "test/test",
"authors": [
{
"name": "test",
"email": "test#test.test"
}
],
"require": {}
}
D:\test>dir
29.08.2015 12:39 <DIR> .
29.08.2015 12:39 <DIR> ..
0 files
D:\test>composer require slim/slim -vvv
Reading ./composer.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Executing command (CWD): hg branch
Executing command (CWD): svn info --xml
Reading C:/Users/Username/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/Username/AppData/Roaming/Composer/composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Executing command (CWD): hg branch
Executing command (CWD): svn info --xml
Downloading https://packagist.org/packages.json
Writing C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/packages.json into cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2013.json from cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2014.json from cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2014-10.json from cache Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2015-01.json from cache Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2015-04.json from cache Downloading http://packagist.org/p/provider-2015-07$bf4d7ab35da85686431ee3c47d0d6d2eee3d913013b38506fbc197c5e95c2420.json
Writing C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2015-07.json into cache Downloading http://packagist.org/p/provider-latest$ee6937b535cc76629a8e81c4362790bd14ce6a824def5d75f7222438e756a7b0.json
Writing C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-latest.json into cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/provider-slim$slim.json from cache Using version ←[32m^2.6←[39m for ←[32mslim/slim←[39m
←[32m./composer.json has been updated←[39m
Reading ./composer.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Executing command (CWD): hg branch
Executing command (CWD): svn info --xml
Reading C:/Users/Username/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/Username/AppData/Roaming/Composer/composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Executing command (CWD): hg branch
Executing command (CWD): svn info --xml
←[32mLoading composer repositories with package information←[39m
Downloading https://packagist.org/packages.json
Writing C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/packages.json into cache
←[32mUpdating dependencies (including require-dev)←[39m
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2013.json from cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2014.json from cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2014-10.json from cache Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2015-01.json from cache Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2015-04.json from cache Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-2015-07.json from cache Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/p-provider-latest.json from cache
Reading C:/Users/Username/AppData/Local/Composer/repo/https---packagist.org/provider-slim$slim.json from cache Analyzed 63 packages to resolve dependencies
Analyzed 45 rules to resolve dependencies
- Installing ←[32mslim/slim←[39m (←[33m2.6.2←[39m)
Reading C:/Users/Username/AppData/Local/Composer/files/slim/slim/20a02782f76830b67ae56a5c08eb1f563c351a37.zip from cache
Loading from cache
Extracting archive
REASON: Required by root: Install command rule (install slim/slim 2.6.0|install slim/slim 2.6.1|install slim/slim 2.6.2)
←[32mWriting lock file←[39m
←[32mGenerating autoload files←[39m
Any ideas how to fix it?

Before applying all steps, try step 5 with your current setup.
Installation Steps
Manually download: https://getcomposer.org/composer.phar
place composer.phar into your PHP folder, next to php.exe
add a batch file composer.bat in the same folder (to execute composer a bit easier), with the following content:
#echo off
:: Composer CLI Shortcut (Global Installation)
"%~dp0php.exe" "%~dp0composer.phar" %*
pause
add the PHP folder to your ENV path, so that php and composer are available on any path
then create your new project
mkdir slim
cd slim
composer require slim/slim 2.6.2 -vvv (this time with version)

Related

golangci-lint: exec: "git": executable file not found in $PATH

I'm trying to integrate golangci-lint on my project. I use golangci-lint v1.49.0 that I install from snap. I've added ci config on my project but when I try to run it, it throws a very bizarre error.
$ golangci-lint run -v
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 7 linters: [errcheck gosimple govet ineffassign staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (files|name|types_sizes|deps|exports_file|compiled_files|imports) took 805.161254ms
ERRO Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: github.com/user/repo#v1.3.4: git init --bare in /home/user/snap/golangci-lint/94/go/pkg/mod/cache/vcs/88980456e822acee6ee17242ca10c17af0281944db0d695e6f13a17951f304ee: exec: "git": executable file not found in $PATH
go: github.com/user/repo#v1.3.4: git init --bare in /home/user/snap/golangci-lint/94/go/pkg/mod/cache/vcs/88980456e822acee6ee17242ca10c17af0281944db0d695e6f13a17951f304ee: exec: "git": executable file not found in $PATH
INFO Memory: 10 samples, avg is 27.8MB, max is 27.8MB
INFO Execution took 809.752753ms
github.com/user/repo isn't a real url, the one I use is private.
These are my config files
# .gitlab-ci.yml
stages:
- test
- build
- sast
- deploy
- cleanup
golangci-lint:
stage: test
image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine
script:
- golangci-lint run -v
# .golangci.yml
run:
tests: false
timeout: 10m
skip-dirs:
- "service/mocks"
output:
format: colored-line-number
Why is it unable to read git in $PATH? I've been using git for years using this machine, this is my first time I got an error like this. I also just reinstalled using sudo apt-get install git just to make sure, but it still throws the same error. It looks like Git has already been installed, but it keeps throwing that error.
My OS is Ubuntu v20.04
I've also added the git path by running export PATH=$PATH:/usr/bin/git, but it still keeps throwing the same error.

Github-actions - composer fails with 'sh: git: not found'?

I have a wordpress plugin where i'm using composer to define my dependent libaries and github-actions to build the installable package. I plan to publish the vendors folder to a 'build' branch in github so the whole application can be installed.
My composer.json file has this content and works locally
{
"name" : "emeraldjava/bhaa_wordpress_plugin",
"description" : "bhaa_wordpress_plugin",
"type" : "wordpress-plugin",
"require": {
"scribu/scb-framework": "dev-master",
"scribu/lib-posts-to-posts": "dev-master",
"mustache/mustache": "2.12.0",
"league/csv": "^9.1",
"michelf/php-markdown": "^1.8"
},
and my github-actions build.yml file uses 'MilesChou/composer-action' to install the composer env in the docker container
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v1
- name: Composer install
uses: MilesChou/composer-action/7.3#master
with:
args: install --no-dev
- uses: docker://php:7.3-alpine
- uses: docker://alpine/git:latest
From the build log, I can see that the zip files for these composer artifacts have been downloaded to the cache
36/38: https://codeload.github.com/scribu/wp-scb-framework/legacy.zip/95b23ac342fce16bf5eb8d939ac5a361b94b104b
37/38: https://codeload.github.com/sebastianbergmann/phpunit/legacy.zip/a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9
38/38: https://codeload.github.com/scribu/wp-lib-posts-to-posts/legacy.zip/a695438e455587fa228e993d05b4431cde99af1b
Finished: success: 38, skipped: 0, failure: 0, total: 38
The build then failed with this 'sh: git: not found' error
Package operations: 5 installs, 0 updates, 0 removals
- Installing scribu/scb-framework (dev-master 95b23ac): Cloning 95b23ac342
Failed to download scribu/scb-framework from source: Failed to clone https://github.com/scribu/wp-scb-framework.git, git was not found, check that it is installed and in your PATH env.
sh: git: not found
Now trying to download from dist
- Installing scribu/scb-framework (dev-master 95b23ac): Loading from cache
- Installing scribu/lib-posts-to-posts (dev-master a695438): Cloning a695438e45
Failed to download scribu/lib-posts-to-posts from source: Failed to clone https://github.com/scribu/wp-lib-posts-to-posts.git, git was not found, check that it is installed and in your PATH env.
sh: git: not found
Now trying to download from dist
- Installing scribu/lib-posts-to-posts (dev-master a695438): Loading from cache
- Installing mustache/mustache (v2.12.0): Loading from cache
- Installing michelf/php-markdown (1.8.0): Loading from cache
- Installing league/csv (9.4.1): Loading from cache
I'm assuming i need to ensure the docker container had git installed, but it seems odd that composer can access the legacy.zip file, so why it git needed at this stage?
EDIT 1
I guess the quick fix here is a duplicate of this issue, and as the answer below states.
For the sake of completeness, lets assume i can't call 'composer --prefer-dist' how could i ensure the docker container has git available to it?
By default Composer uses dist (zip files) for tagged releases and source (git clone) for branches. Since you're targeting master branch for your dependencies, Composer tries to clone repositories first. You can override this behavior by using --prefer-dist switch:
with:
args: install --prefer-dist --no-dev
--prefer-dist: Reverse of --prefer-source, Composer will install from dist if possible. This can speed up installs substantially on build
servers and other use cases where you typically do not run updates of
the vendors. It is also a way to circumvent problems with git if you
do not have a proper setup.
https://getcomposer.org/doc/03-cli.md#install-i

Missing Git command when calling `go get`

My Dockerfile
FROM golang:1.10.2-alpine3.7 AS build
RUN apk --no-cache add gcc g++ make ca-certificates
RUN apk add git
WORKDIR /go/src/github.com/meower
COPY Gopkg.lock Gopkg.toml ./
COPY util util
COPY event event
COPY db db
COPY search search
COPY schema schema
COPY meow-service meow-service
COPY query-service query-service
COPY pusher-service pusher-service
RUN go get -d -v ./...
RUN go install ./...
FROM alpine:3.7
WORKDIR /usr/bin
COPY --from=build /go/bin .
I added apk add git line.Without this line my docker-compose up produced
Step 13/17 : RUN go get -d -v ./...
---> Running in d917adba00cd
github.com/lib/pq (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/lib/pq: exec: "git": executable file not found in $PATH
github.com/nats-io/go-nats (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/nats-io/go-nats: exec: "git": executable file not found in $PATH
github.com/gorilla/mux (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in $PATH
github.com/kelseyhightower/envconfig (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/kelseyhightower/envconfig: exec: "git": executable file not found in $PATH
package github.com/retry: invalid github.com/ import path "github.com/retry"
github.com/segmentio/ksuid (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/segmentio/ksuid: exec: "git": executable file not found in $PATH
github.com/gorilla/websocket (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/websocket: exec: "git": executable file not found in $PATH
github.com/olivere/elastic (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/olivere/elastic: exec: "git": executable file not found in $PATH
With git line,other problems are still there
docker-compose up
Building pusher
Step 1/18 : FROM golang:1.10.2-alpine3.7 AS build
---> 44ccce322b34
Step 2/18 : RUN apk --no-cache add gcc g++ make ca-certificates
---> Using cache
---> 088fa5ba19a9
Step 3/18 : RUN apk add git
---> Running in 01022f57861b
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
git (missing):
What does this mean?
go get internally calls the "reference" client-side tool of the particular VCS used to host the package to be fetched. In other words, go get by itself does not know how to interact with VCS servers.
So yes, in order to go get a package which is hosted by Git, you need the working Git installation providing a callable git binary.
As to your second problem, it does not appear to have anything related to Go, so I suggest you to do a bit of research and then ask a separate question tagged alpine if that fails.

Failing to install Spark in an existing laravel project

I have an existing laravel project where I want to install spark.
I have a spark licence.
When I add the following in composer.json
"repositories": [
{
"type": "composer",
"url": "https://spark-satis.laravel.com"
}
],
And add the following dependency in composer.json's require section
"laravel/spark-aurelius": "~7.0",
The next step is to run composer update : During this process I provide token generated from github and it is where the installation fails with the following message:
Downloading (failed) Failed to download laravel/spark-aurelius from dist: The "https://api.github.com/repos/laravel/spark-aurelius/zipball/15585c1e0407623cb218f556144928a380949e9c" file could not be downloaded (HTTP/1.1 404 Not Found)
Now trying to download from source
And composer fails to clone the github repo (laravel-/spark-aurelius)
This exception is thrown
[RuntimeException]
Failed to execute git clone --no-checkout "https://***:***#github.com/laravel/spark-aurelius.git" "C:\laragon\www\test\vendor\laravel\spark-aurelius" && cd
/D "C:\laragon\www\test\vendor\laravel\spark-aurelius" && git remote add composer "https://***:***#github.com/laravel/spark-aurelius.git" && git fetch com
poser
How can I fix this issue

Composer: Your requirements could not be resolved to an installable set of packages

I am trying to install a composer package and I continuously get the following error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package rondobley/extended-respect-validation could not be found in any version, there may be a typo in the package name.
Here is the composer.json
{
"minimum-stability": "dev",
"require": {
"rondobley/extended-respect-validation": "^1.0"
}
}
And the output from composer install -vvv:
vagrant#wheezy:/code/test$ composer install -vvv
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/code/test): git branch --no-color --no-abbrev -v
Executing command (/code/test): git describe --exact-match --tags
Executing command (/code/test): git log --pretty="%H" -n1 HEAD
Failed to initialize global composer: Composer could not find the config file: /home/vagrant/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 1.2.0 (2016-07-19 01:28:52) with PHP 5.5.38-1~dotdeb+7.1 on Linux / 3.2.0-4-amd64
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /home/vagrant/.composer/cache/repo/https---packagist.org/packages.json into cache
Updating dependencies (including require-dev)
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2013.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2014.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2015.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2015-10.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2016-01.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2016-04.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-2016-07.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-archived.json from cache
Reading /home/vagrant/.composer/cache/repo/https---packagist.org/p-provider-latest.json from cache
Resolving dependencies through SAT
Dependency resolution completed in 0.001 seconds
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package rondobley/extended-respect-validation could not be found in any version, there may be a typo in the package name.
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.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
The package seems to be fine to me:
https://packagist.org/packages/rondobley/extended-respect-validation
It is a new package, just published today, but it has been several hours. I have also tried composer clearcache and that does not help. I have read many of the other similar issues here with no luck. I am new to publishing composer packages, so maybe I an missing a simple step?
Ideally I would like to install version ^1.0.
Thanks for the help in advance.
See https://twitter.com/packagist/status/772034610632990720 - it was a temporary failure on packagist

Resources