Ubuntu环境下Laravel执行composer dump-autoload报bus error (core dumped)求助
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:
If that fails, do a fresh Composer install using these commands:composer self-updatephp -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 -mto list enabled extensions. Make surembstring,json, andxmlare 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 setopcache.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
vendordirectory:rm -rf vendor - Clear Composer’s global cache:
composer clear-cache - Reinstall all dependencies from scratch:
Once this finishes, try runningcomposer installcomposer dump-autoloadagain.
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 -hto 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:
If this works, permanently increase the memory limit in your PHP CLI config (setphp -d memory_limit=-1 composer dump-autoloadmemory_limit = 512Mor 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
memtesterto 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

