Php-language-server: Installation error: "requires jetbrains/phpstorm-stubs dev-master ... conflict with your requirements or minimum-stability"

Created on 27 Feb 2018  路  13Comments  路  Source: felixfbecker/php-language-server

Following from https://github.com/felixfbecker/php-language-server/issues/594#issuecomment-364715883

There are potential dependency problems with the installation instructions:

$ composer require felixfbecker/language-server
Using version ^5.3 for felixfbecker/language-server
./composer.json has been created
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
- felixfbecker/language-server v5.3.6 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- felixfbecker/language-server v5.3.5 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- felixfbecker/language-server v5.3.4 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- felixfbecker/language-server v5.3.3 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- felixfbecker/language-server v5.3.2 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- felixfbecker/language-server v5.3.1 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- felixfbecker/language-server v5.3.0 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
- Installation request for felixfbecker/language-server ^5.3 -> satisfiable by felixfbecker/language-server[v5.3.0, v5.3.1, v5.3.2, v5.3.3, v5.3.4, v5.3.5, v5.3.6].

Installation failed, deleting ./composer.json.

I've learned that this can be resolved by running the following first:

$ composer require jetbrains/phpstorm-stubs:dev-master

If that completes successfully, then you can continue with the original command:

$ composer require felixfbecker/language-server

The installation instructions ought to document this problem and its solution/workaround.

519 is a duplicate of this, but the title of that issue is extremely vague in search results, and the suggested solution (which appears to entail modifying a composer.json file) doesn't make any sense in the context of the installation instructions for this project (which do not provide a composer.json file to modify).

Most helpful comment

I understand what you're getting at, but the fact is that requiring users to firstly learn all about composer in order to figure out how to modify your recommended installation instructions so that they work is a significant (and entirely unnecessary) burden.

The instructions say "Simply run composer require felixfbecker/language-server and you will get the latest stable release and all dependencies."

(a) That's not true (or not for some users, at minimum).
(b) There is nothing "simple" about figuring out what you actually need to do, if you are new to composer.

Your aim was clearly to make it simple for people, and I'm just trying to point out that at the moment it's not simple -- but it could easily be so, with a small amount of additional documentation.

All 13 comments

I agree that the minimum-stability requirement could be better documented (PR welcome). Mininal example: https://github.com/felixfbecker/vscode-php-intellisense/blob/master/composer.json

But I don't want to duplicate explanations for _basic_ concepts of how Composer works - for example, creating a composer.json. This language server is a Composer package, intended to be installed into a Composer project. A lot of PHP users are familiar with Composer, but for those who are not, the Readme links to its project website:

The recommended installation method is through Composer.

If you click "Getting started" Composer you get to a very easy to follow guide about what Composer is:

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

In particular, it explains that Composer works around _projects_:

Composer is not a package manager in the same sense as Yum or Apt are. Yes,
it deals with "packages" or libraries, but it manages them on a per-project
basis, installing them in a directory (e.g. vendor) inside your project. By
default it does not install anything globally. Thus, it is a dependency
manager. It does however support a "global" project for convenience via the
global command.

This idea is not new and Composer is strongly inspired by node's
npm and ruby's bundler.

Suppose:

  1. You have a project that depends on a number of libraries.
  2. Some of those libraries depend on other libraries.

Composer:

  1. Enables you to declare the libraries you depend on.
  2. Finds out which versions of which packages can and need to be installed, and
    installs them (meaning it downloads them into your project).

See the Basic usage chapter for more details on declaring
dependencies.

Which leads you to how to the Basic Usage guide, which explains that you need a composer.json:

To start using Composer in your project, all you need is a composer.json
file. This file describes the dependencies of your project and may contain
other metadata as well.
[...]

I understand what you're getting at, but the fact is that requiring users to firstly learn all about composer in order to figure out how to modify your recommended installation instructions so that they work is a significant (and entirely unnecessary) burden.

The instructions say "Simply run composer require felixfbecker/language-server and you will get the latest stable release and all dependencies."

(a) That's not true (or not for some users, at minimum).
(b) There is nothing "simple" about figuring out what you actually need to do, if you are new to composer.

Your aim was clearly to make it simple for people, and I'm just trying to point out that at the moment it's not simple -- but it could easily be so, with a small amount of additional documentation.

https://youtrack.jetbrains.com/issue/WI-40958 is a ticket in the phpstorm bug tracker for creating release tags for the stubs repo. If composer.json used version tags, this could be changed to version ranges.

A related discussion is https://github.com/phpstan/phpstan/issues/846#issuecomment-369936795 (But I'd assume that php-language-server uses auxilary information from the jetbrains stubs, such as method/class descriptions for hover text)

Please feel free to comment there with your suggestions on how it should be done. (The creators of the stubs) indeed don't need tags, so our goal is to make them usable for you.

Local installation

Create a directory for php-language-server. Create a composer.json file in it, with the following contents:

{
    "minimum-stability": "dev",
    "prefer-stable": true
}

Then, in the directory, run the following commands:

composer require felixfbecker/language-server
composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs

Global installation

Before installing php-language-server, make sure your ~/.config/composer/composer.json includes the lines below. The settings apply to all globally installed Composer packages, so proceed with caution. If you do not want to edit your global Composer configuration, see the section for local installation above.

{
    "minimum-stability": "dev",
    "prefer-stable": true
}

After editing your composer.json, you can install felixfbecker/php-language-server. The following instructions have been adapted from the installation section of php-language-server

composer global require felixfbecker/language-server
composer global run-script --working-dir=vendor/felixfbecker/language-server parse-stubs

Slightly altered from a guide found here .

@LeviHarman wanna do a PR for that?

@felixfbecker I'd love to! I'll do the PR tonight when I get home. Should be 5 hours

There was a stable version of the library in question tagged a couple weeks ago: v2018.1.2 - is it possible to just update composer.json to require that version instead? I believe that largely solves the issue here, and doesn't come at the cost of having to alter the minimum-stability setting.

Happy to set up a PR if you'd prefer to go that direction instead.

I wonder if they will cut releases for every change? The versioning scheme is weird, I don't understand the benefit of the 2018 prefix, semver would be much more helpful.

Agreed, I'd have strongly preferred semver, but I'll take what I can get here. A post in their bug tracker suggests they'll pin it to phpstorm versions.

I just did a bit of testing, and "v2018.1.2 || dev-master" can also be specified as a version requirement - although the people who encounter this issue would always end up on the possibly-stale tagged version. So it could shift the burden to you (and other maintainers) to periodically check for a new tag (which is, as far as I can tell, not shown with composer outdated) :(

Error when install plugin from extension:

PHP Warning:  require(/Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/composer/../jetbrains/phpstorm-stubs/PhpStormStubsMap.php): failed to open stream: No such file or directory in /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/composer/autoload_real.php on line 66
PHP Stack trace:
PHP   1. {main}() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/felixfbecker/language-server/bin/php-language-server.php:0

PHP   2. require() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/felixfbecker/language-server/bin/php-language-server.php:13
PHP   3. ComposerAutoloaderInit0c2d8fbaccd285b4ee9c3c726299965a::getLoader() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/autoload.php:7
PHP   4. composerRequire0c2d8fbaccd285b4ee9c3c726299965a() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/composer/autoload_real.php:56
PHP Fatal error:  require(): Failed opening required '/Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/composer/../jetbrains/phpstorm-stubs/PhpStormStubsMap.php' (include_path='.:/usr/local/php5/lib/php') in /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/composer/autoload_real.php on line 66
PHP Stack trace:
PHP   1. {main}() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/felixfbecker/language-server/bin/php-language-server.php:0
PHP   2. require() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/felixfbecker/language-server/bin/php-language-server.php:13
PHP   3. ComposerAutoloaderInit0c2d8fbaccd285b4ee9c3c726299965a::getLoader() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/autoload.php:7
PHP   4. composerRequire0c2d8fbaccd285b4ee9c3c726299965a() /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/composer/autoload_real.php:56

Language server exited with exit code 255

Error when try install manually:

$ composer require felixfbecker/language-server
Using version ^5.4 for felixfbecker/language-server
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing jetbrains/phpstorm-stubs (dev-master f3a010a): Cloning f3a010af18 from cache
Writing lock file
Generating autoload files

Warning: Unsupported declare 'strict_types' in /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/felixfbecker/language-server/src/ComposerScripts.php on line 2

Parse error: parse error in /Users/antwal/.vscode/extensions/felixfbecker.php-intellisense-2.3.11/vendor/felixfbecker/language-server/src/ComposerScripts.php on line 47

How can resolve?

Thanks.

@antwal this is unrelated, please open a new issue.

https://github.com/felixfbecker/php-language-server/issues/611#issuecomment-384709284

The last command should be altered to include the global vendor path:

composer global run-script --working-dir=$HOME/.config/composer/vendor/felixfbecker/language-server parse-stubs

The last command should be altered to include the global vendor path

More generally, use $COMPOSER_HOME if it's set, as $HOME/.config/composer is only the default for certain systems (and might be customised locally in any case). Refer to https://getcomposer.org/doc/03-cli.md#composer-home

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebet picture sebet  路  6Comments

seanmcbreen picture seanmcbreen  路  5Comments

Ciantic picture Ciantic  路  6Comments

Jarzebowsky picture Jarzebowsky  路  8Comments

felixfbecker picture felixfbecker  路  4Comments