Giter Site home page Giter Site logo

Comments (17)

naderman avatar naderman commented on May 2, 2024

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.

from composer.

evan108108 avatar evan108108 commented on May 2, 2024

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

from composer.

naderman avatar naderman commented on May 2, 2024

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.

from composer.

mikeyp avatar mikeyp commented on May 2, 2024

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

My configure looks like this:


from composer.

mikeyp avatar mikeyp commented on May 2, 2024

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

from composer.

naderman avatar naderman commented on May 2, 2024

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.

from composer.

igorw avatar igorw commented on May 2, 2024

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

from composer.

saltybeagle avatar saltybeagle commented on May 2, 2024

@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.

from composer.

Seldaek avatar Seldaek commented on May 2, 2024

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

from composer.

stloyd avatar stloyd commented on May 2, 2024

@Seldaek Maybe adding check to stub ?

Composer\Compiler::getStub()

<?php

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

from composer.

saltybeagle avatar saltybeagle commented on May 2, 2024

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

from composer.

Seldaek avatar Seldaek commented on May 2, 2024

@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.

from composer.

stloyd avatar stloyd commented on May 2, 2024

@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);
}

from composer.

saltybeagle avatar saltybeagle commented on May 2, 2024

@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.

from composer.

stloyd avatar stloyd commented on May 2, 2024

@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.

from composer.

Seldaek avatar Seldaek commented on May 2, 2024

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

from composer.

Seldaek avatar Seldaek commented on May 2, 2024

Closing in favor of #245

from composer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.