2011-06-29 37 views
0

運行的方法,我使用的是寶石稱爲IMGKit,當我使用寶石的to_img方法在控制檯中我得到這個錯誤:權限被拒絕從一個Ruby寶石

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' 

我不知道這是怎麼回事。

這是to_img方法:

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 

回答

0

這意味着作爲被執行的Ruby程序不具有權限讀取或/ ruby​​programs /搜索執行該文件(或可能的/ ruby​​programs用戶目錄本身)。檢查目錄和/或文件是否存在並可由用戶執行。如果不存在,則需要安裝一些軟件包或調整gem配置中的路徑。如果它存在,那麼你可能需要使用chown/chmod來更改所有權或權限。

+0

存在文件/ ruby​​programs/search。我目前不需要什麼權限? –

+0

它應該可以由用戶執行。您可以通過使用運行Rails應用程序的帳戶登錄服務器來檢查這一點,並通過在/ ruby​​programs/search中輸入來嘗試執行該文件 – Martijn