i386 Arch错误与OS X Mojave安装旧的scrypt gem版本

时间:2018-11-28 21:08:27

标签: ruby-on-rails compiler-errors rubygems

在尝试重新安装OS X 10.14 Mojave和XCode命令行工具后,我正在尝试为旧项目安装旧的gem版本。我要安装的gem是scrypt(版本1.2.1),它是authlogic的依赖项。

gem install scrypt -v = 1.2.1

返回以下错误:

Building native extensions. This could take a while...
ERROR:  Error installing scrypt:
    ERROR: Failed to build gem native extension.

    current directory: /Users/chris/.rvm/gems/ruby-2.4.4@rails5/gems/scrypt-1.2.1/ext/scrypt
/Users/chris/.rvm/rubies/ruby-2.4.4/bin/ruby -rrubygems /Users/chris/.rvm/gems/ruby-2.4.4@global/gems/rake-12.0.0/exe/rake RUBYARCHDIR=/Users/chris/.rvm/gems/ruby-2.4.4@rails5/extensions/x86_64-darwin-18/2.4.0/scrypt-1.2.1 RUBYLIBDIR=/Users/chris/.rvm/gems/ruby-2.4.4@rails5/extensions/x86_64-darwin-18/2.4.0/scrypt-1.2.1
mkdir -p x86_64-darwin
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/crypto_scrypt-sse.o -c ./crypto_scrypt-sse.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/memlimit.o -c ./memlimit.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/scrypt_calibrate.o -c ./scrypt_calibrate.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/scrypt_ext.o -c ./scrypt_ext.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/scryptenc_cpuperf.o -c ./scryptenc_cpuperf.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -msse -msse2 -arch x86_64 -arch i386   -o x86_64-darwin/sha256.o -c ./sha256.c
gcc -bundle -o x86_64-darwin/libscrypt_ext.bundle x86_64-darwin/crypto_scrypt-sse.o x86_64-darwin/memlimit.o x86_64-darwin/scrypt_calibrate.o x86_64-darwin/scrypt_ext.o x86_64-darwin/scryptenc_cpuperf.o x86_64-darwin/sha256.o -fexceptions -arch x86_64 -arch i386 
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture i386:
  "___error", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
      _memtouse in memlimit.o
  "___stack_chk_fail", referenced from:
      _scrypt_SHA256_Transform in sha256.o
      _scrypt_SHA256_Final in sha256.o
      _HMAC_scrypt_SHA256_Init in sha256.o
      _HMAC_scrypt_SHA256_Final in sha256.o
      _PBKDF2_scrypt_SHA256 in sha256.o
  "___stack_chk_guard", referenced from:
      _scrypt_SHA256_Transform in sha256.o
      _scrypt_SHA256_Final in sha256.o
      _HMAC_scrypt_SHA256_Init in sha256.o
      _HMAC_scrypt_SHA256_Final in sha256.o
      _PBKDF2_scrypt_SHA256 in sha256.o
  "_free", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_getrlimit$UNIX2003", referenced from:
      _memtouse in memlimit.o
  "_gettimeofday", referenced from:
      _scryptenc_cpuperf in scryptenc_cpuperf.o
  "_malloc", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_memcpy", referenced from:
      _scrypt_SHA256_Update in sha256.o
      _PBKDF2_scrypt_SHA256 in sha256.o
  "_mmap$UNIX2003", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_munmap$UNIX2003", referenced from:
      _crypto_scrypt in crypto_scrypt-sse.o
  "_sysconf", referenced from:
      _memtouse in memlimit.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!
Command failed with status (1): [gcc -bundle -o x86_64-darwin/libscrypt_ext...]
/Users/chris/.rvm/gems/ruby-2.4.4@rails5/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:153:in `block in define_task!'
/Users/chris/.rvm/gems/ruby-2.4.4@global/gems/rake-12.0.0/exe/rake:27:in `<main>'
Tasks: TOP => default => x86_64-darwin/libscrypt_ext.bundle
(See full trace by running task with --trace)

rake failed, exit code 1

4 个答案:

答案 0 :(得分:3)

安装command line tools for 10.13可以解决此问题。

答案 1 :(得分:2)

对于最新版本的macOS,似乎已弃用并删除了i386体系结构。假设您无法升级scrypt版本(这可能是最好的选择),仍然至少有两个选项可能对您有用。

  • 使用docker映像。我刚刚使用ruby:2.5.3-slim进行了测试,而您只需要运行apt-get update && apt-get build-essential && gem install scrypt -v 1.2.1
  • 下载包含i386架构的旧版SDK,并将其安装在系统上。 This包含一些可能有用的链接和信息(尽管不是特定于Rails的)

答案 2 :(得分:2)

我遇到了这个确切的问题。

我正在运行Mojave(10.14.4)和XCode命令行工具的10.2版,并且在运行gem install scrypt -v 1.2.1时,遇到了与上述完全相同的错误。

解决方案是安装以下软件包:/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg(如Can't compile C program on a Mac after upgrade to Mojave中所述)。问题的根源显然是在此过程中的某个位置(捆绑程序?scrypt?),人们期望可以在/usr/include中找到头文件。最新版本的XCode不会将头文件放置在该位置,但是运行包会将其放置在该位置(如the XCode release notes中所述)

答案 3 :(得分:0)

我尝试了给出的所有答案版本,但并不能完全为我完成工作。然后,以下步骤对我有用。

首先检查头文件是否存在。

ls /usr/include
ls: /usr/include: No such file or directory

由于没有标题,我删除了this answer中给出的CommandLineTools

sudo rm -rf /Library/Developer/CommandLineTools

更新xcode并安装macOS_SDK_headers_for_macOS_10.14.pkg

xcode-select --install
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

当我这样做时,现在头文件存在 ls /usr/include

gem install scrypt -v 1.2.1