-
-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
Hi
I recently tried Replit, it is like GitHub Codespaces but with nix behind to handle packages.
So I tried to install php
, composer
& symfony-cli
with nix to create a new Symfony project, and I saw this:
$ symfony-cli new foo
* Creating a new Symfony project with Composer
WARNING: Unable to find Composer, downloading one. It is recommended to install Composer yourself at https://getcomposer.org/download/
...
$ # so I tried to understand why
$ whereis composer
composer: /nix/store/grm58racabmyxakvp1axlb4r6b8icvfj-php-composer-2.2.6/bin/composer
$ echo $PATH | tr E':' '\n'
...
/nix/store/6ni9a0gkfscic4bq8l376xza2zf874y9-php-with-extensions-8.1.3/bin
/nix/store/grm58racabmyxakvp1axlb4r6b8icvfj-php-composer-2.2.6/bin
/nix/store/x9ja3hf9plylx9rpaqy9wd2f5j60wy26-symfony-cli-5.3.4/bin
...
$ cat /nix/store/grm58racabmyxakvp1axlb4r6b8icvfj-php-composer-2.2.6/bin/composer
#! /nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12/bin/bash -e
PATH=${PATH:+':'$PATH':'}
PATH=${PATH/':''/nix/store/64kd7qghqw3j0wqbss7shm3ad3awbsis-unzip-6.0/bin'':'/':'}
PATH='/nix/store/64kd7qghqw3j0wqbss7shm3ad3awbsis-unzip-6.0/bin'$PATH
PATH=${PATH#':'}
PATH=${PATH%':'}
export PATH
exec "/nix/store/6ni9a0gkfscic4bq8l376xza2zf874y9-php-with-extensions-8.1.3/bin/php" /nix/store/grm58racabmyxakvp1axlb4r6b8icvfj-php-composer-2.2.6/libexec/composer/composer.phar "$@"
The warning is triggered because we check if the composer
file starts with this shebang:
symfony-cli/local/php/composer.go
Lines 98 to 111 in 54ff09d
// isComposerPHPScript checks that the composer file is indeed a phar/PHP script (not a .bat file) | |
func isComposerPHPScript(path string) bool { | |
file, err := os.Open(path) | |
if err != nil { | |
return false | |
} | |
defer file.Close() | |
magicPrefix := []byte("#!/usr/bin/env php") | |
byteSlice := make([]byte, len(magicPrefix)) | |
if _, err := file.Read(byteSlice); err != nil { | |
return false | |
} | |
return bytes.Equal(byteSlice, magicPrefix) | |
} |
based on the comment on top of the function, should we do the opposite to fix this (checking if this is a bat file)?
To reproduce: https://replit.com/@mykiwi/reproduce-symfony-cli-warning and hit "Run"
tucksaun
Metadata
Metadata
Assignees
Labels
No labels