Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation exits unexpectedly #85

Closed
mikeyp opened this issue Nov 2, 2011 · 17 comments
Closed

Installation exits unexpectedly #85

mikeyp opened this issue Nov 2, 2011 · 17 comments

Comments

@mikeyp
Copy link

mikeyp commented Nov 2, 2011

Trying to install from the instructions on http://packagist.org/ and got the following result after running php composer.phar install:

mdp ~: php composer.phar install
??=??mdp ~: 

PHP version:

PHP 5.3.6 (cli) (built: Jul 31 2011 13:05:04)

Phar section of my php info:


Phar: PHP Archive support => enabled
Phar EXT version => 2.0.1
Phar API version => 1.1.1
SVN revision => $Revision: 307915 $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => enabled
OpenSSL support => enabled


Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On
@naderman
Copy link
Member

naderman commented Nov 2, 2011

Do you have suhosin installed? If so, does your config contain something like

suhosin.executor.include.whitelist = phar

Alternatively try running php -d error_reporting=E_ALL composer.phar to see if there are any hidden errors.

@evan108108
Copy link

I too am not able to install composer. Here is what Im doing/seeing:

$ php composer.phar install

PHP Fatal error: Uncaught exception 'RuntimeException' with message 'The composer.json file could not be found in the current directory' in phar:///Users/xxx/composer.phar/bin/composer:37
Stack trace:
#0 /Users/xxx/composer.phar(15): require()
#1 {main}
thrown in phar:///Users/xxx/composer.phar/bin/composer on line 37

@naderman
Copy link
Member

naderman commented Nov 2, 2011

That is entirely unrelated. While that message isn't output nicely, it does tell you what the problem is. You have not created a composer.json file. Please see http://packagist.org for instructions on how to use composer.

@mikeyp
Copy link
Author

mikeyp commented Nov 2, 2011

I'm not running Suhosin. I got the same result with E_ALL and no error message was provided.

My configure looks like this:


@mikeyp
Copy link
Author

mikeyp commented Nov 2, 2011

Just for kicks, I tried to install with the default OS X PHP and received the same error as @evan108108 above.

@naderman
Copy link
Member

naderman commented Nov 2, 2011

That means it works correctly on OS X. Without a composer.json file Composer cannot know what to do. You must create one for your project before it can do anything.

@igorw
Copy link
Contributor

igorw commented Nov 2, 2011

Try the things mentioned here: http://silex.sensiolabs.org/doc/usage.html#pitfalls

@saltybeagle
Copy link

@mikeyp I think your first issue was caused by the detect_unicode PHP ini setting. You could try:

php -d detect_unicode=0 composer.phar install

@igorw linked a doc with details on how to permanently fix any CLI phar issues.

@Seldaek
Copy link
Member

Seldaek commented Nov 2, 2011

@saltybeagle can we do anything to detect this early in the phar bootstrap and warn the user? This is a really nasty error.

@stloyd
Copy link
Contributor

stloyd commented Nov 2, 2011

@Seldaek Maybe adding check to stub ?

Composer\Compiler::getStub()

<?php

if (ini_get('detect_unicode')) {
    throw new \RuntimeException('Check your config, bro! ;-)');
}

@saltybeagle
Copy link

@Seldaek The error happens so early, I don't think it's something we can detect in userland code at runtime.

@Seldaek
Copy link
Member

Seldaek commented Nov 3, 2011

@mikeyp: I unfortunately can't reproduce it here. Could you try the fix @stloyd suggested, and then run bin/compile to get a phar and try again with that? It'd be cool if we can advise users to do the right thing.

@stloyd
Copy link
Contributor

stloyd commented Nov 7, 2011

@Seldaek It seems we can't (as @saltybeagle mentioned) do this in userland. As I see you changed a bit error when composer.json is found, this should help to @mikeyp and @evan108108 (and other Mac'ers (tm)).

About issue with phar... I was think about making command (in bin/) that could run a check on php.ini and return some common pitfall warnings. But as mention, user must run it alone, we cannot do it in phar (or in stub as I suggested, this would fail on some OS [ubuntu works good, even when some pitfalls are detected as possible]).

It could look like:

bin/check_pitfalls

#!/usr/bin/env php
<?php

$errors = array();
if (false !== $unicode = ini_get('detect_unicode')) {
    $errors['unicode'] = 'On';
}

if (false !== $readonly = ini_get('phar.readonly')) {
    $errors['readonly'] = 'On';
}

if (false !== $hash = ini_get('phar.require_hash')) {
    $errors['require_hash'] = 'On';
}

if (false !== $suhosin = ini_get('suhosin.executor.include.whitelist')) {
    if (false === strpos($suhosin, ',') && $suhosin != 'phar') {
        $errors['suhosin'] = $suhosin;
    } else if (false === in_array('phar', explode(',', $suhosin))) {
        $errors['suhosin'] = $suhosin;
    }
}

if (false === empty($errors)) {
    echo 'Composer detected that you have enabled some settings in your';
    echo '`php.ini` file that can make Composer unable to work properly.';
    echo "\n\n";

    echo 'Make sure that you have changed options listed below:';
    echo "\n";
    foreach ($errors as $error => $actual) {
        switch ($error) {
            case 'unicode':
                echo "\rdetect_unicode = Off (actual: {$actual})\n";
                break;

            case 'readonly':
                echo "\rphar.readonly = Off (actual: {$actual})\n";
                break;

            case 'require_hash':
                echo "\rphar.require_hash = Off (actual: {$actual})\n";
                break;

            case 'suhosin':
                echo "\rsuhosin.executor.include.whitelist = phar (actual: {$actual})\n";
                break;
        }
    }

    exit(1);
}

@saltybeagle
Copy link

@stloyd That's an interesting proposal. I wonder if it would be worthwhile to cook up a simple install shell script (sort of like go-pear), which runs those simple checks, grabs the latest phar and sets up a bin/composer executable for the end-user.

@stloyd
Copy link
Contributor

stloyd commented Nov 7, 2011

@saltybeagle I was thinking exacly about something like go-pear (maybe not exacly in .bat etc., just in php ;-) But this would lead to downloading, lets say, install_composer.php ;-) or something similar. Which would test userland for phar, php.ini, common pitfalls and maybe few others things :-)

@Seldaek, @naderman What do you think about such file ? I could make some work on php version if you would like this idea.

@Seldaek
Copy link
Member

Seldaek commented Nov 17, 2011

@stloyd: Would be great I think, if you can just send it to the composer/getcomposer.org repo, it should probably be there.

@Seldaek
Copy link
Member

Seldaek commented Jan 22, 2012

Closing in favor of #245

@Seldaek Seldaek closed this as completed Jan 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants