You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置Vagrant代理时出现NameError: undefined local variable or method 'config'错误

Fixing the NameError: undefined local variable or method 'config' in Vagrant Proxy Setup

Hey there! Let's sort out this error you're hitting with your Vagrant proxy config. The issue here is pretty straightforward: when you added those three proxy lines to your global Vagrantfile, you didn't wrap them inside Vagrant's required configuration block. Without that block, Ruby (the language Vagrant uses under the hood) doesn't recognize the config variable you're trying to use.

Here's the correct way to structure your global Vagrantfile

The global Vagrantfile at C:\Users\<your username>\.vagrant.d\Vagrantfile needs to be wrapped in a Vagrant.configure block. Just replace your current three lines with something like this (swap in your actual proxy details):

Vagrant.configure("2") do |config|
  # Proxy configuration using proxyconf plugin
  config.proxy.http     = "http://your-proxy-address:port"
  config.proxy.https    = "http://your-proxy-address:port"
  config.proxy.no_proxy = "localhost,127.0.0.1"
end

What's happening here?

  • The Vagrant.configure("2") do |config| line initializes Vagrant's configuration system and passes a config object into the block.
  • Inside the block, you can safely use the config variable to set your proxy settings (and any other global Vagrant configs you want later).
  • The end closes the configuration block, telling Ruby where your Vagrant settings end.

Next steps to test

  1. Save the updated Vagrantfile
  2. Open your command prompt and run either vagrant up (if you're starting a new machine) or vagrant reload (if you already have a machine running)

This should resolve the NameError and apply your proxy settings correctly across all your Vagrant projects.

内容的提问来源于stack exchange,提问作者Adam Burley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:57:04