gpt4 book ai didi

ruby - ruby 脚本中的 `#!` (shebang)(hashbang) 有问题

转载 作者:太空宇宙 更新时间:2023-11-04 04:46:34 24 4
gpt4 key购买 nike

我有一个包含以下内容的 ruby​​ 脚本:

#!/data1/thirdparty/ruby/bin/ruby -I/data1/thirdparty/ruby/lib/ruby/2.0.0 -I/data1/thirdparty/ruby/lib/ruby/gems/2.0.0/gems/ruby-net-ldap-0.0.4 -I/data1/thirdparty/ruby/lib/ruby/site_ruby/2.0.0 -I/data1/thirdparty/ruby/lib/ruby/2.0.0/i686-linux

当我运行脚本时,它抛出以下错误:

<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'

我对程序进行了跟踪,并在跟踪中发现了以下内容:

open("/data1/thirdparty/ruby/lib/ruby/2.0.0 -I/data1/thirdparty/enc/encdb.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)

所以看来 ruby​​ 无法正确处理 -I 因为它将它包含在文件路径本身中。如何强制脚本使用 -I 作为包含路径指令?

最佳答案

试试这个:

#!/bin/bash
exec /data1/thirdparty/ruby/bin/ruby -I/data1/thirdparty/ruby/lib/ruby/2.0.0 -I/data1/thirdparty/ruby/lib/ruby/gems/2.0.0/gems/ruby-net-ldap-0.0.4 -I/data1/thirdparty/ruby/lib/ruby/site_ruby/2.0.0 -I/data1/thirdparty/ruby/lib/ruby/2.0.0/i686-linux -x "$0" "$@"

#!ruby
p "this is my ruby code"

关于ruby - ruby 脚本中的 `#!` (shebang)(hashbang) 有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32942556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com