在 PhpStorm 中提示:Invalid VCS root mapping 的分析解决
1、在 PhpStorm 中提示:Invalid VCS root mapping。The directory <Project>\vendor\wartron\yii2-uuid is registered as a Git root, but no Git repositories were found there。如图1
2、点击 Configure 进入配置界面。发现:vendor\wartron\yii2-uuid 标红。如图2
3、参考网址:https://www.shuijingwanwq.com/2020/05/11/4130/ 。原因在于,删除目录:E:\wwwroot\pcs-api\vendor\wartron\yii2-uuid\.git。如图3
4、参考我应该提交 vendor 目录中的依赖包吗?:https://docs.phpcomposer.com/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.html 。
5、执行命令:composer install,提示:Nothing to install or update。
PS E:\wwwroot\channel-pub-api> composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating autoload files 27 packages you are using are looking for funding. Use the `composer fund` command to find out more!
6、参考第 3 点,在运行 composer update 命令前需要先删除磁盘中的依赖文件。删除目录:E:\wwwroot\pcs-api\vendor\wartron。提交至 Git。如图4
7、删除目录:\vendor\wartron 后,提交至 Git。如图5
8、执行命令:composer install。全新安装:wartron/yii2-uuid。如图6
PS E:\wwwroot\channel-pub-api> composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 1 install, 0 updates, 0 removals - Installing wartron/yii2-uuid (dev-master 2202443): Cloning 2202443ac7 from cache Generating autoload files 27 packages you are using are looking for funding. Use the `composer fund` command to find out more!
9、查看目录:E:\wwwroot\pcs-api\vendor\wartron\yii2-uuid\.git,已存在。如图7
10、如果此时提交代码,会发现仅会提交空目录:\vendor\wartron ,其目录中的文件未被提交。原因在于其受到了 \vendor\wartron\yii2-uuid\.git 的影响。之前的方案是删除目录:\vendor\wartron\yii2-uuid\.git。不过,删除之后,便会出现提示:Invalid VCS root mapping。如图8
11、参考第 2 点。使用 –prefer-dist 或在 config 选项中设置 preferred-install 为 dist。删除目录:E:\wwwroot\pcs-api\vendor\wartron。执行命令:composer install –prefer-dist。全新安装:wartron/yii2-uuid。如图9
PS E:\wwwroot\channel-pub-api> composer install --prefer-dist Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 1 install, 0 updates, 0 removals - Installing wartron/yii2-uuid (dev-master 2202443): Downloading (100%) Generating autoload files 27 packages you are using are looking for funding. Use the `composer fund` command to find out more!
12、查看目录:E:\wwwroot\pcs-api\vendor\wartron\yii2-uuid\.git,已不存在。如图10
13、提交代码,会发现目录:\vendor\wartron 中的文件已被全部提交。如图11
14、在 Manage projects 中删除项目。如图12
15、删除 phpstorm project files,即目录:.idea 。如图13
16、再次新建项目。在 PhpStorm 中已无提示:Invalid VCS root mapping。查看版本控制界面,已不存在::vendor\wartron\yii2-uuid。符合预期。如图14
17、之前在文档中的相应说明: ( wartron\yii2uuid 每次 composer update 后,需要额外处理,以提交至 Git )。已经可以删除。如图15
近期评论