在 Ruby 中取消设置 http 代理不起作用

Unset http proxy in Ruby not working

Test.rb

Class Test

  %x( unset http_proxy )

  %x( unset https_proxy )

  %x( unset HTTP_PROXY )

  %x( unset HTTPS_PROXY )

  system ("echo $https_proxy") #result: http://10.10.10.10:8080

  system ("echo $https_proxy") #result: http://10.10.10.10:8080

  system ("echo $HTTPS_proxy") #result: http://10.10.10.10:8080 

  system ("echo $HTTP_proxy")  #result: http://10.10.10.10:8080

end

我无法在 Ruby 中取消设置 http_proxy。 请帮我解决这个问题!

您对 ruby 的执行是您计算机的一个进程 "child"。 因此,您只能获得父环境的副本。

来源:http://blog.honeybadger.io/ruby-guide-environment-variables/ python 中的类似请求:Is it possible to change the Environment of a parent process in python?