权限被拒绝从Ruby gem运行一个方法 [英] Permission denied running a method from a Ruby gem
问题描述
我使用名为 IMGKit 的宝石,当我使用宝石的 to_img
在控制台中的方法我得到这个错误:
IMGKit :: CommandFailedError:命令失败:/ rubyprograms / search --format jpg http://google.com - :/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open3.rb:67:in`exec': Permission denied - / rubyprograms / search(Errno :: EACCES)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open3.rb:67:in`popen3 '
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open3.rb:53:in`fork'
我不知道发生了什么。
这是to_img方法:
def to_img(format = nil)
append_stylesheets
set_format(格式)
结果=无
stderr_output =无
Open3.popen3(*命令)do | stdin,stdout,std ERR |
stdin<< (@ source.to_s)if @ source.html?
stdin.close
result = stdout.gets(nil)
result.force_encoding(ASCII-8BIT)if result.respond_to? :force_encoding
stderr_output = stderr.readlines.join
stdout.close
stderr.close
end
raise CommandFailedError.new(command.join(''),stderr_output )除非结果
返回结果
结束
解决方案这意味着执行Ruby程序的用户没有权限读取/执行/ rubyprograms / search(或可能位于/ rubyprograms目录本身)的文件。检查目录和/或文件是否存在并可由用户执行。如果不存在,则需要安装一些软件包或调整gem配置中的路径。如果它存在,那么可能需要使用chown / chmod来更改所有权或权限。
I'm using a gem called IMGKit and when I use the gem's
to_img
method in the console I get this error:IMGKit::CommandFailedError: Command failed: /rubyprograms/search --format jpg http://google.com -: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open3.rb:67:in `exec': Permission denied - /rubyprograms/search (Errno::EACCES) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open3.rb:67:in `popen3' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open3.rb:53:in `fork'
I have no clue what's going on.
This is the to_img method:
def to_img(format = nil) append_stylesheets set_format(format) result = nil stderr_output = nil Open3.popen3(*command) do |stdin,stdout,stderr| stdin << (@source.to_s) if @source.html? stdin.close result = stdout.gets(nil) result.force_encoding("ASCII-8BIT") if result.respond_to? :force_encoding stderr_output = stderr.readlines.join stdout.close stderr.close end raise CommandFailedError.new(command.join(' '), stderr_output) unless result return result end
解决方案This means the user as which your Ruby program is executed does not have the permissions to read or execute the file at /rubyprograms/search (or possible the /rubyprograms directory itself). Check if the directory and/or file exist and are executable by your user. If doesn't exist then you'll need to install some packages or adjust the path in the gem's configuration. If it exists then maybe you need to change ownership or permissions using chown/chmod.
这篇关于权限被拒绝从Ruby gem运行一个方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!