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

执行bundle exec rake db:create报错Operation not permitted求解决

解决方案:执行rake db:create时遇到Errno::EPERM权限错误

Hey there! Let's work through this permission issue together—super common when you're just starting out with Rails and RVM, so don't stress. Here are the most reliable fixes to try:

  • 修复项目目录与bundle文件夹的权限
    First, make sure your project folder and the vendor/bundle directory are owned by your user (not root, which often causes permission blocks). Run these commands from your project root:

    sudo chown -R $USER:$USER /Users/ravibhatia/Desktop/Dev Code/fountain
    chmod -R 755 /Users/ravibhatia/Desktop/Dev Code/fountain/vendor/bundle
    

    The chown command transfers full ownership of the project to your user account, while chmod sets safe, accessible read/write/execute permissions.

  • 重新安装bundle依赖(重置权限)
    Sometimes the initial bundle installation creates files with messed-up permissions. Let's wipe the old bundle folder and start fresh:

    rm -rf vendor/bundle
    bundle install --path vendor/bundle
    

    This deletes the problematic bundle directory and reinstalls all dependencies using your user's permissions, avoiding root-owned files entirely.

  • 修复RVM自身的权限
    Since you're using RVM, it's possible the Ruby installation directory has incorrect ownership. Use RVM's built-in fix command to sort this out:

    rvm fix-permissions
    

    This command automatically corrects ownership for all RVM-managed rubies, gems, and related files—no manual digging required.

  • 绝对不要用sudo(划重点!)
    I know it's tempting to slap sudo in front of the command to force it through, but this will only make things worse long-term. It creates root-owned files that your regular user can't access later, leading to more permission headaches down the line. Stick to the fixes above instead.

  • 检查macOS系统完整性保护(仅针对Mac用户)
    If you're on macOS, System Integrity Protection (SIP) might block access to certain directories (though your Desktop folder shouldn't be affected). You can check SIP's status with:

    csrutil status
    

    If it's enabled and you suspect it's causing issues, disabling it temporarily can help—but only do this as a last resort, since SIP is a critical security feature.

After trying these steps, run bundle exec rake db:create again—it should execute without the permission error!

内容的提问来源于stack exchange,提问作者Ravi Bhatia

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 07:53:43