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

项目bcrypt突发报错cannot load such file --2.3/bcrypt_ext,原正常现失效求解决

Fixing the "cannot load such file -- 2.3/bcrypt_ext" Error

Hey there, I’ve run into this exact bcrypt issue before—super annoying when even backups stop working out of nowhere! Let’s break down what’s going on and how to fix it:

What’s Causing This?

The error cannot load such file -- 2.3/bcrypt_ext means bcrypt’s native extension (the compiled part that talks directly to your Ruby environment) is either missing, corrupted, or doesn’t match your current Ruby version. The "2.3" here refers to Ruby 2.3—so if your system switched to a different Ruby version recently (even if you’re using project backups), the old compiled extension won’t work anymore.

Step-by-Step Fixes

  • First, confirm your Ruby version
    Run ruby -v in your terminal. If it’s not Ruby 2.3, that’s almost certainly the root problem—bcrypt-ruby 3.0.0 is an older gem that’s tightly tied to specific Ruby versions.

  • Uninstall and reinstall bcrypt-ruby to rebuild the extension

    1. Uninstall the existing gem completely:
      gem uninstall bcrypt-ruby
      (If prompted, select all versions to remove every trace)
    2. Reinstall the exact version you need:
      gem install bcrypt-ruby -v 3.0.0
    3. If you’re using Bundler, clean up stale references first:
      bundle clean --force bcrypt-ruby
      bundle install
  • Sync your Ruby version manager (if you use one)
    Tools like rbenv or RVM can leave stale gem path references. For rbenv, run rbenv rehash to update your environment. For RVM, try rvm gemset refresh to sync your gemset with your current Ruby version.

  • Install system dependencies for compiling native extensions
    Bcrypt needs basic compilers and headers to build its extension—if these are missing, the gem installs but the critical compiled part fails.

    • On Mac: Run xcode-select --install to set up Xcode Command Line Tools.
    • On Ubuntu/Debian: Run sudo apt-get install ruby-dev build-essential to get the required compilers and Ruby headers.
  • Try upgrading to the newer bcrypt gem (if your project allows it)
    The bcrypt-ruby gem was renamed to just bcrypt in later versions, which have far better compatibility with modern Ruby releases. If your project doesn’t have strict version locks:

    1. Update your Gemfile to:
      gem 'bcrypt', '~> 3.1.18'
    2. Run bundle install—this will automatically compile a compatible extension for your current Ruby.

Why Even Backups Are Failing

Project backups don’t include compiled native gem files—those are stored in your system’s gem directory or Bundler’s local cache. If your Ruby version changed since the backup was made, the old extension (built for Ruby 2.3) can’t be loaded by your current Ruby environment, hence the error.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 08:28:41