Ubuntu 16.04安装Diaspora时bundle install失败求助
Hey there, let's work through this Bundler issue you're hitting while setting up Diaspora on Ubuntu 16.04. I've dealt with my fair share of native gem compilation headaches, so let's break this down step by step:
Step 1: Ensure RVM is using your updated GCC/G++ versions
Sometimes RVM doesn't automatically pick up the system's new compiler versions, which can cause native extensions to fail during Bundler installs. Let's fix that:
- First, update RVM to the latest stable version to rule out any outdated compatibility issues:
rvm get stable - Set the compiler environment variables explicitly before running Bundler. You can run these commands in your terminal session first to test:
export CC=gcc-7 export CXX=g++-7 - To make these settings permanent for all RVM sessions, add them to your RVM config file:
Then restart your terminal or runecho 'export CC=gcc-7' >> ~/.rvmrc echo 'export CXX=g++-7' >> ~/.rvmrcsource ~/.rvmrcto apply the changes.
Step 2: Clear Bundler's cache and reinitialize
Stale cached gem files or a mismatched Gemfile.lock can often cause unexpected failures. Let's start fresh:
- Force clean all cached gems:
bundle clean --force - Delete the existing
Gemfile.lockto ensure Bundler pulls the latest compatible versions:rm Gemfile.lock - Now try running Bundler again:
bundle install
Step 3: Manually reinstall unf_ext with explicit compiler flags
Even though you installed unf_ext successfully outside Bundler, Bundler might still try to recompile it with incorrect flags. Let's ensure it's installed properly for Bundler to use:
- Uninstall the existing unf_ext gem first:
gem uninstall unf_ext - Reinstall it with the correct compiler flags:
gem install unf_ext -- --with-cflags="-O2 -g" --with-cc=gcc-7 --with-cxx=g++-7 - After this, run
bundle installagain—Bundler should now recognize the pre-installed, correctly compiled unf_ext gem and skip recompiling it.
If you're still stuck...
If the above steps don't resolve the issue, it would help to share the exact error output from Bundler (specifically the lines where the compilation fails). Often, the error message will point to another native gem (like nokogiri or sqlite3) that's causing the problem, and we can target that specifically.
内容的提问来源于stack exchange,提问作者GHx

