线上服务器,更新镜像源,composer.lock 文件生成错误。

问题描述
laravel程序,在部署服务器上,composer切换成阿里云的镜像源,切换成功后,composer.lock依旧是laravel-china的镜像源。本地是正常的。

依次执行
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer update -vvv

执行成功以后,打开composer.lock,发现文件中的链接依旧是laravel-china的地址,如图

在部署服务器上,composer切换成阿里云的镜像源,切换成功后,composer.json依旧是laravel-china的镜像源。本地是正常的。

造成的问题是,服务器上composer install会报错,提示镜像源有问题。
尝试了清空composer缓存,或者换镜像源,都不能解决问题。 laravel-china的镜像源和噩梦一样。。

请大神告知

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
最佳答案

@Epona 你删掉 lock,再 install,会安装最新的包,在生产环境这样,可能会搞出事来,,

composer update nothing 直接这样,就可以只更新 lock 文件里的源,,,

之前在论坛看到的~~

2个月前 评论
_杭城浪子 2个月前
讨论数量: 7

composer.json 贴一下

2个月前 评论
Epona

把 composer.lock 删掉,然后再 install

2个月前 评论

@Epona 你删掉 lock,再 install,会安装最新的包,在生产环境这样,可能会搞出事来,,

composer update nothing 直接这样,就可以只更新 lock 文件里的源,,,

之前在论坛看到的~~

2个月前 评论
_杭城浪子 2个月前
Epona

@largezhou 如果 composer.json 里面版本指定没问题的话,一般倒是没啥问题,你这个也是一个不错的解决办法

2个月前 评论
likunyan

composer update nothing,学习了。

上次看到说 composer.lock 也要保存到 .gitignore 才对,被我删了,我赶紧恢复下。 :joy:

2个月前 评论
xiaopi

@陈伯乐 这是我的composer.json

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "minimum-stability": "dev",
  "require": {
    "php": ">=7.1.0",
    "ext-json": "*",
    "ext-pcntl": "*",
    "ext-pdo": "*",
    "babenkoivan/scout-elasticsearch-driver": "3.10",
    "barryvdh/laravel-ide-helper": "^2.4",
    "boyhagemann/wave": "^0.1.0@dev",
    "doctrine/dbal": "^2.10@dev",
    "elasticsearch/elasticsearch": "6.7",
    "enqueue/amqp-lib": "^0.9.0@dev",
    "fideloper/proxy": "~3.3",
    "guzzlehttp/guzzle": "^6.3",
    "laravel/framework": "5.5.*",
    "laravel/horizon": "^2.0",
    "laravel/scout": "7.1",
    "laravel/tinker": "~1.0",
    "maatwebsite/excel": "2.1.27",
    "overtrue/easy-sms": "dev-master",
    "overtrue/laravel-lang": "~3.0",
    "overtrue/laravel-wechat": "~4.0",
    "php-amqplib/php-amqplib": "^2.9",
    "predis/predis": "^1.1",
    "prettus/l5-repository": "dev-master",
    "queue-interop/amqp-interop": "0.8.*",
    "rap2hpoutre/laravel-log-viewer": "dev-master",
    "socialiteproviders/qq": "dev-master",
    "spatie/laravel-activitylog": "^2.8",
    "zizaco/entrust": "^1.9"
  },
  "require-dev": {
    "barryvdh/laravel-debugbar": "^3.2@dev",
    "filp/whoops": "~2.0",
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "~1.0",
    "phpunit/php-invoker": "^2.0@dev",
    "phpunit/phpunit": "~6.0",
    "symfony/thanks": "^1.0"
  },
  "autoload": {
    "classmap": [
      "database/seeds",
      "database/factories"
    ],
    "psr-4": {
      "App\\": "app/",
      "XsKit\\ShortcutDirective\\": "app/package/shortcut/",
      "XsKit\\PassportClient\\": "app/package/passport/",
      "XsKit\\LaravelRabbitMQ\\": "app/package/rabbitmq/"
    },
    "files": [
      "app/Extensions/Dingding/TopSdk.php",
      "app/helpers.php"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },
  "extra": {
    "laravel": {
      "dont-discover": [
      ]
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate"
    ],
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover"
    ],
    "post-update-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postUpdate",
      "php artisan ide-helper:generate",
      "php artisan ide-helper:meta"
    ]
  },
  "config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
  }

}
2个月前 评论
xiaopi

@Epona 其实这种我也试过了。删除composer.lock,
执行
composer install -vvv
查看详情是从阿里云镜像下载的。 下载完毕以后,从新生成的composer.lock文件中还是laravel-china的镜像地址

2个月前 评论

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!