dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

OmniSharp.exe locking on the Composer file. #2659

Open kenorb opened 5 years ago

kenorb commented 5 years ago

Environment data

VS Code version: 1.27.1 C# Extension version: 1.17.0

Steps to reproduce

The VS Code extension locked on the file causing the error in Composer.

# composer update
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Gathering patches for root package.
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 8 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Updating phpoffice/phpspreadsheet (1.4.0 => 1.5.0):     Update failed (Could not delete /var/www/html/vendor/phpoffice/phpspreadsheet/docs/assets/ClassDiagrams: )
    Would you like to try reinstalling the package instead [yes]? no

  [RuntimeException]
  Could not delete /var/www/html/vendor/phpoffice/phpspreadsheet/docs/assets/ClassDiagrams:

root@db3744f65663:/var/www/html# rm -fr vendor/phpoffice/
rm: cannot remove 'vendor/phpoffice/phpspreadsheet/docs/assets/ClassDiagrams': Device or resource busy

I've checked in Process Explorer and OmniSharp.exe was locking on that file, despite I didn't have any files open and vendor\phpoffice\phpspreadsheet\docs\assets\ClassDiagrams is just the empty folder. image

Expected behavior

I need my composer update composer running again.

Actual behavior

OmniSharp.exe is locking on the empty directory for at least half an hour.

image

Workaround

I've to quit Visual Code, then it worked.

rchande commented 5 years ago

@kenorb I'm not familiar with composer. Can you share some more info? Are there .cs files in that directory?

kenorb commented 5 years ago

Composer is a package management tool which downloads PHP packages into vendor folder (similar to node_modules for npm). So in Visual Code I've a project which was used to work on Drupal website (most of PHP files). In the Docker container I've /var/www/html which is shared folder for the host where the files are as per docker-compose.yml:

volumes:
  - ../.:/var/www/html

So when I run composer install or update for the following composer.json:

{
  "name": "Foo",
  "type": "project",
  "repositories": [
  {
    "type": "composer",
    "url": "https://packages.drupal.org/8"
  }
  ],
  "require": {
    "aws/aws-sdk-php": "~3.0",
    "composer/installers": "^1.2",
    "cweagans/composer-patches": "^1.6",
    "drupal-composer/drupal-scaffold": "^2.2",
    "drupal/address": "~1.0",
    "drupal/config_ignore": "^2.1",
    "drupal/config_split": "^1.2",
    "drupal/console": "^1.0.2",
    "drupal/core": "~8.5",
    "drupal/devel": "^1.2",
    "drupal/diff": "^1.0",
    "drupal/features": "^3.7",
    "drupal/geolocation": "^1.11",
    "drupal/inline_entity_form": "^1.0@RC",
    "drupal/jsonapi": "^1.23",
    "drupal/media_entity_image": "^1.3",
    "drupal/migrate_plus": "^2.0",
    "drupal/migrate_source_xls": "^1.1",
    "drupal/redirect": "^1.3",
    "drupal/restui": "^1.15",
    "drupal/s3fs": "^3.0",
    "drupal/ses_mailer": "^1.0",
    "drush/drush": "~8.2",
    "phpoffice/phpspreadsheet": "^1.4",
    "webflo/drupal-finder": "^1.0.0",
    "webmozart/path-util": "^2.3",
    "wikimedia/composer-merge-plugin": "^1.4"
  },
  "require-dev": {
    "behat/mink": "~1.7",
    "behat/mink-goutte-driver": "~1.2",
    "jcalderonzumba/gastonjs": "~1.0.2",
    "jcalderonzumba/mink-phantomjs-driver": "~0.3.1",
    "mikey179/vfsstream": "~1.2",
    "phpunit/phpunit": ">=4.8.28 <5",
    "symfony/css-selector": "~2.8|~3.0"
  },
  "conflict": {
    "drupal/drupal": "*"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "config": {
    "sort-packages": true
  },
  "autoload": {
    "classmap": [
      "scripts/composer/ScriptHandler.php"
    ]
  },
  "scripts": {
    "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
    "pre-install-cmd": [
      "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
    ],
    "pre-update-cmd": [
      "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
    ],
    "post-install-cmd": [
      "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
    ],
    "post-update-cmd": [
      "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
    ]
  }
}

it failed due to lock which was put on some folder by OmniSharp.

Unfortunatelly this will be difficult to reproduce. The bug could be in OmniSharp.exe binary, the way how it's locking on the files. Probably OmniSharp locked on some file, which was removed during composer install. So if this information is not enough, unfortunatelly I won't be able to provide more details.