You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu环境下Laravel执行composer dump-autoload报bus error (core dumped)求助

Fixing bus error (core dumped) on composer dump-autoload (Ubuntu + Laravel)

Got it, let’s tackle this frustrating issue head-on. I’ve dealt with similar core dump errors with Composer in Ubuntu before, so here are actionable steps to get your autoload files generating again:

Step 1: Refresh Composer and Check PHP Health

Bus errors often stem from corrupted binaries or missing extensions. Let’s start here:

  • Update Composer to the latest version:
    composer self-update
    
    If that fails, do a fresh Composer install using these commands:
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    
  • Verify Laravel-required PHP extensions: Run php -m to list enabled extensions. Make sure mbstring, json, and xml are present—if not, install them with:
    sudo apt install php-mbstring php-json php-xml
    
  • Temporarily disable OPcache: OPcache can sometimes cause unexpected crashes. Edit your PHP CLI config (usually /etc/php/[your-php-version]/cli/php.ini) and set opcache.enable = 0, then retry the dump-autoload command.

Step 2: Wipe Corrupted Cache and Dependencies

Corrupted vendor files or Composer cache are frequent culprits:

  • Delete the entire vendor directory:
    rm -rf vendor
    
  • Clear Composer’s global cache:
    composer clear-cache
    
  • Reinstall all dependencies from scratch:
    composer install
    
    Once this finishes, try running composer dump-autoload again.

Step 3: Fix File Permissions and Check Disk Space

Sometimes the issue is just the system not being able to write files:

  • Check disk space: Run df -h to ensure your drive isn’t full. Free up space if needed.
  • Set correct project permissions: Make sure your Laravel project has proper ownership and permissions:
    sudo chown -R $USER:$USER /path/to/your/laravel/project
    find /path/to/your/laravel/project -type d -exec chmod 755 {} \;
    find /path/to/your/laravel/project -type f -exec chmod 644 {} \;
    

Step 4: Bump PHP Memory Limit

A memory shortage can trigger core dumps during autoload generation:

  • Run the dump-autoload command with unlimited memory temporarily:
    php -d memory_limit=-1 composer dump-autoload
    
    If this works, permanently increase the memory limit in your PHP CLI config (set memory_limit = 512M or higher in /etc/php/[your-php-version]/cli/php.ini).

Step 5: Rule Out System/Hardware Issues

If none of the above work, the problem might be at the system level:

  • Test system memory: Install memtester to check for bad RAM:
    sudo apt install memtester
    sudo memtester 1024 5  # Tests 1GB of memory 5 times
    
  • Check system logs: Look for bus-related errors in system logs:
    dmesg | grep -i bus
    cat /var/log/syslog | grep -i core
    

If you’re still stuck, share details like your Ubuntu version, PHP version, Laravel version, and any output from core dump analysis (using gdb php core after installing gdb) to help narrow things down.

内容的提问来源于stack exchange,提问作者Trần Văn Kiến

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:22:42