更改Ruby原生扩展的tmp目录

时间:2016-11-28 14:09:48

标签: ruby gcc rubygems

我不熟悉Ruby,但使用的是需要构建一些Ruby原生扩展的系统实用程序。当我尝试运行安装命令时,我得到以下stacktrace:

Building native extensions.  This could take a while...
ERROR:  Error installing sensu-plugins-http:
    ERROR: Failed to build gem native extension.

    current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
/opt/sensu/embedded/bin/ruby -r ./siteconf20161128-17526-tzlgio.rb extconf.rb
checking for main() in -lstdc++... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /opt/sensu/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.2/mkmf.log

current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
make "DESTDIR=" clean

current directory: /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/unf_ext-0.0.7.2/ext/unf_ext
make "DESTDIR="
compiling unf.cc
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++ [enabled by default]
unf.cc:75:1: fatal error: error writing to /tmp/ccyXxObQ.s: No space left on device
compilation terminated.
make: *** [unf.o] Error 1

make failed, exit code 2

由于各种原因,我的/tmp/目录故意很小。我想知道,有没有办法让Ruby / gcc使用不同的临时位置进行构建过程?

1 个答案:

答案 0 :(得分:0)

是。在编译之前设置TMPDIR环境变量:

  

TMPDIR

     

如果设置了TMPDIR,则指定要用于的目录   临时文件。 GCC使用临时文件来保存一个输出   编译阶段,用作下一阶段的输入:   例如,预处理器的输出,它是输入   编译器正确。

来源:
https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html