更改 Ruby 原生扩展的 tmp 目录



我对Ruby并不非常熟悉,但是正在使用需要构建一些Ruby Antial扩展名的系统实用程序。当我尝试运行安装命令时,我会得到以下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使用其他临时位置进行构建过程?

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

tmpdir

如果设置了TMPDIR,则指定用于使用的目录 临时文件。海湾合作委员会使用临时文件保存一个 汇编阶段,该阶段将用作下一阶段的输入: 例如,预处理器的输出,这是对 编译器适当。

来源:
https://gcc.gnu.org/onlinedocs/gcc/environment-variables.html

最新更新