hhvm / xhp-lib

Class libraries for XHP. XHP is a Hack feature that augments the syntax of the language such that XML document fragments become valid Hack expressions.
http://facebook.github.io/xhp-lib/
MIT License
1.38k stars 160 forks source link

Unable to install via composer on OSX: you are running this with PHP and not HHVM #215

Closed abirchall closed 4 years ago

abirchall commented 4 years ago

See the following console output. Any ideas? hhvm docs appear to say the latest version of composer will auto-detect whether to run with php or hhvm, could that be broken?

abirchall-fb[abdev](master): sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G103

abirchall-fb[abdev](master): php --version
PHP 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

abirchall-fb[abdev](master): hhvm --version
HipHop VM 4.39.0 (rel)
Compiler: 1578430744_N
Repo schema: da39a3ee5e6b4b0d3255bfef95601890afd80709

abirchall-fb[abdev](master): composer --version
Composer version 1.9.2 2020-01-14 16:30:31

abirchall-fb[abdev](master): composer init
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.

Package name (<vendor>/<name>) [abirchall/hhvm]:
Description []:
Author [First Last <FooBar@gmail.com>, n to skip]:
Minimum Stability []:
Package Type (e.g. library, project, metapackage, composer-plugin) []:
License []:

Define your dependencies.

Would you like to define your dependencies (require) interactively [yes]? n
Would you like to define your dev dependencies (require-dev) interactively [yes]? n

{
    "name": "abirchall/hhvm",
    "authors": [
        {
            "name": "First Last",
            "email": "FooBar@gmail.com"
        }
    ],
    "require": {}
}

Do you confirm generation [yes]? y

abirchall-fb[abdev](master): composer require facebook/xhp-lib
Using version ^3.0 for facebook/xhp-lib
./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
    - facebook/xhp-lib v3.0.1 requires hhvm ^4.25 -> you are running this with PHP and not HHVM.
    - facebook/xhp-lib v3.0.0 requires hhvm ^4.25 -> you are running this with PHP and not HHVM.
    - Installation request for facebook/xhp-lib ^3.0 -> satisfiable by facebook/xhp-lib[v3.0.0, v3.0.1].

Installation failed, reverting ./composer.json to its original content.
azjezz commented 4 years ago

Please update your composer installation as follow :

$ composer self-update

Issue : previously, we used hhvm to run composer ( hhvm $(which composer) require ... ), but recently, hhvm became unable to run composer as composer uses php references, a change was made to composer so that it executes hhvm --version to retrieve HHVM version and check it against composer.json instead of relying on HHVM_VERSION constant when its running under hhvm.

ssandler commented 4 years ago

It looks like his composer is already up to date? Perhaps you have php aliased/symlinked to point at hhvm?

If you do have it aliased you don't want to change that, you can also run it explicitly with php like /usr/bin/php /usr/local/bin/composer require facebook/xhp-lib

azjezz commented 4 years ago

i don't think that's the case.

  1. composer won't start under hhvm
  2. even if the check was removed, composer won't result in you are running this with PHP and not HHVM. under hhvm ( see : https://github.com/composer/composer/blob/79a300eaac89be9a4b05cd992930f343ba4f084d/src/Composer/DependencyResolver/Problem.php#L111 and https://github.com/composer/composer/blob/ff246e3e85cc972d3c66c3b66aa233415cc5ed89/src/Composer/DependencyResolver/Rule.php#L174 )
fredemmott commented 4 years ago

composer will sometimes say that if there are other unresolvable dependency issues. I'm not sure of the exact case.

That said, I can't reproduce this on a clean checkout.

abirchall commented 4 years ago

Thanks for the fast responses!

run it explicitly with php like /usr/bin/php /usr/local/bin/composer require facebook/xhp-lib

This results in the same behavior.

run composer self-update

It's already up to date:

abirchall-fb[abdev](master): composer self-update
You are already using composer version 1.9.2 (stable channel).

Could you paste your full composer.json and composer.lock?

The contents are in my first post; it's a clean composer.json (with no requirements yet) and there is no lock file yet as I've yet to install anything.

How did you install hhvm?

Using Homebrew: brew install hhvm. I also installed composer via Homebrew.

Is this on an FB-managed machine?

It's on my FB work laptop (MacBook).

fredemmott commented 4 years ago
fredemmott commented 4 years ago

(FB chef doesn't like homebrew being in /usr/local, but HHVM's packages aren't relocatable)

abirchall commented 4 years ago

Is homebrew installing in it's default location - /usr/local/ - or somewhere else? what do which hhvm and which hh_single_compile say?

abirchall-fb[abdev](master): which hhvm; which hh_single_compile; which composer; which php
/usr/local/bin/hhvm
/usr/local/bin/hh_single_compile
/usr/local/bin/composer
/usr/bin/php

abirchall-fb[abdev](master): ls -la /usr/local/bin/hhvm /usr/local/bin/composer /usr/bin/php /usr/local/bin/hh_single_compile
-rwxr-xr-x  1 root       wheel  11169664 May  4  2019 /usr/bin/php
lrwxr-xr-x  1 abirchall  wheel        37 Jan 31 01:43 /usr/local/bin/composer -> ../Cellar/composer/1.9.2/bin/composer
lrwxr-xr-x  1 abirchall  admin        35 Jan 12 01:30 /usr/local/bin/hhvm -> ../Cellar/hhvm-4.39/4.39.0/bin/hhvm
lrwxr-xr-x  1 abirchall  admin  48 Jan 12 01:30 /usr/local/bin/hh_single_compile -> ../Cellar/hhvm-4.39/4.39.0/bin/hh_single_compile

what's the output of hhvm --php -r 'echo HHVM_VERSION."\n";' ?

This may be a hint in the right direction...

abirchall-fb[abdev](master): hhvm --php -r 'echo HHVM_VERSION."\n";'
Failed to initialize central HHBC repository:
  Failed to initialize schema in /Users/abirchall/.hhvm.hhbc(rw-r--r-- root:group does not exist):

Assertion failure: /tmp/hhvm-4.39-20200107-19145-1nyzk4l/hhvm-4.39.0/hphp/runtime/vm/repo.cpp:652: auto HPHP::Repo::initCentral()::(anonymous class)::operator()() const: assertion `false' failed.

Failed to initialize central HHBC repository:
  Failed to initialize schema in /Users/abirchall/.hhvm.hhbc(rw-r--r-- root:group does not exist):

-------------------------------Assertion Message--------------------------------
Failed to initialize central HHBC repository:
  Failed to initialize schema in /Users/abirchall/.hhvm.hhbc(rw-r--r-- root:group does not exist):

-------------------------------Assertion Failure--------------------------------
/tmp/hhvm-4.39-20200107-19145-1nyzk4l/hhvm-4.39.0/hphp/runtime/vm/repo.cpp:652: auto HPHP::Repo::initCentral()::(anonymous class)::operator()() const: assertion `false' failed.
Core dumped: Abort trap: 6
Stack trace in /tmp/stacktrace.87134.log
Abort trap: 6

But if I use sudo, it's fine:


abirchall-fb[abdev](master): sudo hhvm --php -r 'echo HHVM_VERSION."\n";'
4.39.0
abirchall commented 4 years ago

Interesting, /Users/abirchall/.hhvm.hhbc was owned by root:

abirchall-fb[abdev](master): ls /Users/abirchall/.hhvm.hhbc
-rw-r--r--  1 root  1876110778  3694592 Jan 31 23:29 /Users/abirchall/.hhvm.hhbc

I removed it and it was re-generated (owned by my user) when I ran hhvm --php -r 'echo HHVM_VERSION."\n";':

abirchall-fb[abdev](master): ls /Users/abirchall/.hhvm.hhbc
-rw-r--r--  1 abirchall  1876110778  3694592 Jan 31 23:31 /Users/abirchall/.hhvm.hhbc

... and then after this composer worked:

abirchall-fb[abdev](master): composer require facebook/xhp-lib
Using version ^3.0 for facebook/xhp-lib
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing hhvm/hsl (v4.40.0): Downloading (100%)
  - Installing hhvm/type-assert (v3.7.3): Downloading (100%)
  - Installing facebook/xhp-lib (v3.0.1): Downloading (100%)
Writing lock file
Generating autoload files

Will leave this open in case there's anything we should do to try to catch and mitigate this.

fredemmott commented 4 years ago

Closing; this probably belong as an issue against facebook/hhvm to send a PR improving composer's error handling in this case, or an issue against composer itself. Composer is probably 'more correct', but more likely to be seen by the right people on facebook/hhvm