Permission denied running a method from a Ruby gem

…衆ロ難τιáo~ 提交于 2020-01-16 11:23:38

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/6515807/permission-denied-running-a-method-from-a-ruby-gem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!