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

服务器仅支持GCC 4.3.2,安装Rails时sassc编译失败求助

Fixing sassc 2.2.1 Compilation Error with GCC 4.3.2

Hey there, let's work through this problem step by step—since your server is stuck on GCC 4.3.2 and can't upgrade, the -flto error pops up because that link-time optimization flag was added in GCC 4.6, which your older version doesn't support. Here's how to address each of your questions:

1. Quick Fix for the Compilation Error

The simplest workaround is to disable the unsupported -flto flag during gem installation. Set these environment variables before running bundle install to override the compiler settings:

CFLAGS="-fno-lto" CXXFLAGS="-fno-lto" bundle install

This tells the compiler to skip link-time optimization, letting sassc compile successfully without needing a GCC upgrade.

Another option is to install an older sassc version that doesn't use the -flto flag. Versions before 2.0 (like 1.12.1) avoid this optimization. Force this version by adding it to your Gemfile:

gem 'sassc', '1.12.1'

Then run bundle update sassc to install the compatible older build.

2. Can You Exclude sassc Installation?

Yes, since you didn't add it to your Gemfile, it's a transitive dependency (most likely from sass-rails or another asset-related gem). Here are two reliable ways to skip installing it:

  • Switch to pure-Ruby Sass: Replace sassc with the original Ruby implementation of Sass, which requires no native compilation. Add these lines to your Gemfile:
    gem 'sass-rails', '~> 5.0' # Match your Rails version; 5.x supports Ruby Sass
    gem 'sass', '~> 3.7' # Pure-Ruby Sass, no native extensions needed
    
    Run bundle update sass-rails to switch the dependency away from sassc.
  • Use Bundler to override the dependency: If you need to keep your current sass-rails version, tell Bundler to skip sassc entirely by adding:
    gem 'sassc', platforms: []
    
    This blocks sassc installation for all platforms. Just note: test your app thoroughly afterward, as some gems might rely on sassc-specific functionality.

3. Can You Delete sassc from the .gems Folder?

Absolutely, but this is only a temporary fix—Bundler will try to reinstall sassc the next time you run bundle install unless you fix the dependency root cause. To remove it:

  1. Locate the sassc directory in your .gems folder (e.g., ~/.gems/gems/sassc-2.2.1)
  2. Delete the directory entirely
  3. Optionally, clean up cached gem files with:
    gem cleanup sassc
    

Remember: this won't stop future reinstalls unless you adjust your Gemfile or dependency overrides as outlined in question 2.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:46:05