AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题

问题[vagrant](computer)

Martin Hope
Gilles Quénot
Asked: 2023-02-14 08:04:50 +0800 CST

安装 'jekyll' 后无法使用 'vagrant' 并出现错误:'找不到 gem vagrant'

  • 5

安装jekyll后gem install jekyll,我的vagrant命令失败并显示:

$ vagrant up
/usr/lib/ruby/vendor_ruby/rubygems.rb:265:in `find_spec_for_exe': can't find gem vagrant (>= 0.a) with executable vagrant (Gem::GemNotFoundException)
    from /usr/lib/ruby/vendor_ruby/rubygems.rb:284:in `activate_bin_path'
    from /usr/bin/vagrant:25:in `<main>'
/usr/lib/ruby/vendor_ruby/rubygems.rb:265:in `find_spec_for_exe': can't find gem vagrant (>= 0.a) with executable vagrant (Gem::GemNotFoundException)
    from /usr/lib/ruby/vendor_ruby/rubygems.rb:284:in `activate_bin_path'
    from /usr/bin/vagrant:25:in `<main>'
/usr/lib/ruby/vendor_ruby/rubygems.rb:265:in `find_spec_for_exe': can't find gem vagrant (>= 0.a) with executable vagrant (Gem::GemNotFoundException)
    from /usr/lib/ruby/vendor_ruby/rubygems.rb:284:in `activate_bin_path'
    from /usr/bin/vagrant:25:in `<main>'
/usr/lib/ruby/vendor_ruby/rubygems.rb:265:in `find_spec_for_exe': can't find gem vagrant (>= 0.a) with executable vagrant (Gem::GemNotFoundException)
    from /usr/lib/ruby/vendor_ruby/rubygems.rb:284:in `activate_bin_path'
    from /usr/bin/vagrant:25:in `<main>'
$ LANG=C dpkg -l vagrant
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version              Architecture Description
+++-==============-====================-============-==========================================================>
ii  vagrant        2.2.19+dfsg-1ubuntu1 all      Tool for building and distributing virtualized development>

我需要什么作为临时解决方法(变量在中声明~/.bashrc):

$ unset GEM_HOME GEM_PATH

现在,我可以跑了vagrant。避免此类问题的最终解决方案是什么?

vagrant
  • 1 个回答
  • 7 Views
Martin Hope
crNh
Asked: 2022-12-13 01:05:28 +0800 CST

Vagrant up 在错误的 VM 中执行内联脚本

  • 5

我需要帮助修复以下 Vagrant 文件,因为它的行为不正确。

由于某种原因,在执行 vagrant up 时,Shell 脚本在 Windows VM 上执行,而不是在 Linux 上执行。

Vagrant.configure("2") do |config_wglr|
  config_wglr.winrm.timeout =   3600
  config_wglr.winrm.retry_limit = 30
  config_wglr.winrm.retry_delay = 10
  config_wglr.vm.boot_timeout = 3600
  config_wglr.vm.define "WGLR" do |glw_runner|
    glw_runner.vm.box = "gusztavvargadr/docker-windows"
    glw_runner.vm.network "private_network", ip: "xxxx"
  end
  config_wglr.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
    vb.customize ["modifyvm", :id, "--vram", "256"]
  end
end

Vagrant.configure("2") do |config_lglr|
  config_lglr.vm.box = "generic/rocky8"
  config_lglr.vm.hostname = "LGLR"
  config_lglr.vm.network "private_network", ip: "yyyy"
  # the boxes need to be accessible via password and username
  config_lglr.vm.provision "shell", inline: <<-SHELL
    sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
    systemctl restart sshd
    SHELL
    config_lglr.vm.define "LGLR"
  # begin disable audio
  config_lglr.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--audio", "none"]
  end
  # end disable audio
end

感谢任何建议。

行为日志 - 在 linux 虚拟机启动之前执行 shell 脚本。

==> WGLR: Machine booted and ready!
==> WGLR: Checking for guest additions in VM...
==> WGLR: Setting hostname...
==> WGLR: Waiting for machine to reboot...
==> WGLR: Configuring and enabling network interfaces...
==> WGLR: Mounting shared folders...
    WGLR: /vagrant => C:/workdir/ansible-playbook-gitlabrunners
==> WGLR: Running provisioner: shell...
    WGLR: Running: inline PowerShell script
    WGLR: sed : The term 'sed' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    WGLR: spelling of the name, or if a path was included, verify that the path is correct and try again.
    WGLR: At C:\tmp\vagrant-shell.ps1:1 char:5
    WGLR: +     sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' ...
    WGLR: +     ~~~
    WGLR:     + CategoryInfo          : ObjectNotFound: (sed:String) [], CommandNotFoundException
    WGLR:     + FullyQualifiedErrorId : CommandNotFoundException
    WGLR:
    WGLR: systemctl : The term 'systemctl' is not recognized as the name of a cmdlet, function, script file, or operable
    WGLR: program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    WGLR: At C:\tmp\vagrant-shell.ps1:2 char:5
    WGLR: +     systemctl restart sshd
    WGLR: +     ~~~~~~~~~
    WGLR:     + CategoryInfo          : ObjectNotFound: (systemctl:String) [], CommandNotFoundException
    WGLR:     + FullyQualifiedErrorId : CommandNotFoundException
    WGLR:
==> LGLR: Importing base box 'generic/rocky8'...
vagrant
  • 1 个回答
  • 20 Views
Martin Hope
Nelson Teixeira
Asked: 2022-10-03 08:09:06 +0800 CST

为什么 Vagrant 在其中一条供应线中创造了截然不同的输出?

  • 5

为什么我的流浪汉要改造这条供应线:

echo "eval \"\$(starship init bash)\"" >> ~/.bashrc

在 .bashrc 的这一行中?

eval  __main() { local major="${BASH_VERSINFO[0]}" local minor="${BASH_VERSINFO[1]}" if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then source <(/usr/local/bin/starship init bash --print-full-init) else source /dev/stdin <<<"$(/usr/local/bin/starship init bash --print-full-init)" fi } __main unset -f __main 

这是执行的结果,$(starship init bash)但它不应该执行,一旦我只做一个回显。

我怎样才能避免它?

编辑

使用单引号,结果相同,但已格式化。

我尝试echo "eval \"\$(starship init bash)\"" >> ~/.bashrc在虚拟机中运行该命令,它运行良好。

vagrant
  • 1 个回答
  • 23 Views
Martin Hope
rools
Asked: 2021-12-08 13:07:45 +0800 CST

更新后无法在 VirtualBox 中从 Vagrant 创建专用网络

  • 5

我已将 VirtualBox 从 6.1.26-2 升级到 6.1.28-3(在 Manjaro 中),然后我无法使用 Vagrant 建立专用网络。这是我的流浪文件:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.hostname = "Name"
  config.vm.network :forwarded_port, guest: 22, host: 2336, id: 'ssh'
  config.vm.network :private_network, ip: "10.1.45.3", netmask: "255.255.0.0"
end

当我执行 avagrant up时,我得到:为仅主机网络配置的 IP 地址不在允许的范围内。请更新以前在允许范围内的地址,然后再次运行该命令。

  Address: 10.1.45.3
  Ranges: 192.168.56.0/21

Valid ranges can be modified in the /etc/vbox/networks.conf file. For
more information including valid format see:

  https://www.virtualbox.org/manual/ch06.html#network_hostonly

我按照链接中的指南创建了文件 /etc/vbox/networks.conf :

0.0.0.0/0 ::/0

而且,当我vagrant up再次跑步时,我得到了:

The IP address configured for the host-only network is not within the
allowed ranges. Please update the address used to be within the allowed
ranges and run the command again.

  Address: 10.1.45.3
  Ranges: 

Valid ranges can be modified in the /etc/vbox/networks.conf file. For
more information including valid format see:

  https://www.virtualbox.org/manual/ch06.html#network_hostonly

为什么“范围”是空的?我尝试使用其他范围值,但它没有改变任何东西。

我检查了 NAT 接口的 IP,没有冲突(10.0.2.15/24)。

virtualbox vagrant
  • 1 个回答
  • 674 Views
Martin Hope
Manitoba
Asked: 2021-10-02 00:56:49 +0800 CST

GuestAdditions 版本的流浪问题

  • 5

我正在尝试Vagrantfile在我的 Ubuntu 服务器上运行一个。我收到以下错误消息:

An error occurred during installation of VirtualBox Guest Additions 6.1.26. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
Unmounting Virtualbox Guest Additions ISO from: /mnt
Cleaning up downloaded VirtualBox Guest Additions ISO...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.26
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.26
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims:   5.2.0
VBoxService inside the vm claims: 6.1.26
Going on, assuming VBoxService is correct...
Restarting VM to apply changes...

我使用以下命令安装 Virtualbox 和 Vagrant:

# Install VirtualBox
sudo apt-get install linux-headers-$(uname -r) build-essential dkms
sudo apt-get install libgl1-mesa-glx libxmu6 libxt6 -y
sudo apt-get install virtualbox -y

# Install vagrant and its plugins
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - && sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && sudo apt-get update && sudo apt-get install vagrant -y
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-disksize
vagrant plugin install vagrant-hostmanager

安装的版本:

Vagrant 2.2.18
Virtualbox 6.1.26

安装卡在:

Installing rsync to the VM...
==> worker-customer: Rsyncing folder: /home/worker/ => /vagrant

这似乎是合乎逻辑的,因为来宾添加无法正常工作。

如何修复版本不匹配?

virtualbox vagrant
  • 1 个回答
  • 334 Views
Martin Hope
Nils
Asked: 2021-02-11 03:59:28 +0800 CST

在 Hyper-V 中使用 Vagrant 需要什么

  • 7

我已经按照文档中的描述设置了 vagrant 。

运行时,vagrant up我收到以下消息:

Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
The Hyper-V cmdlets for PowerShell are not available! Vagrant
requires these to control Hyper-V. Please enable them in the
"Windows Features" control panel and try again.

虽然我理解这个信息,但我觉得这不是根本问题。我做了

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

和以下重新启动。

Get-VM列出我所有的机器。所以我觉得应该安装 Hyper-V cmdlet 并且可以使用。

这是在 Windows 10 20H2 上运行的,Vagrant 版本是 2.2.14,Hyper-V PowerShell 模块版本是 2.0.0.0

我在这里想念什么?

编辑:

已安装的 Hyper-V 功能包括:

在此处输入图像描述

PowerShell 版本:

> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

我还交叉发布到了讨论.hashicorp.com

编辑 2

错误来自\Vagrant\embedded\gems\2.2.14\gems\vagrant-2.2.14\plugins\providers\hyperv\scripts\check_hyperv.ps1which 基本上确实Get-Command "Hyper-V\Get-VMSwitch",如果失败则报告错误。

Hyper-V\Get-VMSwitch现在,如果没有一些“帮助” ,我的系统似乎无法加载:

❯ get-command "Hyper-V\Get-VMSwitch"
get-command : The term 'Hyper-V\Get-VMSwitch' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ get-command "Hyper-V\Get-VMSwitch"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Hyper-V\Get-VMSwitch:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

❯ get-command "Get-VMSwitch"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-VMSwitch                                       2.0.0.0    Hyper-V


❯ get-command "Hyper-V\Get-VMSwitch"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-VMSwitch                                       2.0.0.0    Hyper-V
**strong text**

vagrant hyper-v
  • 2 个回答
  • 285 Views
Martin Hope
Cornel Bortici
Asked: 2021-01-16 04:57:29 +0800 CST

用于运行 vagrant up 的 Jenkinsfile 管道

  • 8

我遇到了一个奇怪的问题,当我运行 vagrant up 时,虚拟机构建良好并按预期工作,但是当我在 Jenkinsfile 管道中运行相同的命令时,构建完成后,虚拟机关闭并创建日志.

Log created: 2021-01-15T12:32:44.144568000Z
Process ID:  9678 (0x25ce)
Parent PID:  1 (0x1)
Executable:  /usr/lib/virtualbox/VBoxSVC
Arg[0]: /usr/lib/virtualbox/VBoxSVC
Arg[1]: --auto-shutdown
AddRef: illegal refcnt=3221225469 state=2

这是 vagrant 的管道代码

stage('Run Vagrant'){
    sh 'cd /var/lib/jenkins/workspace/jenkins-file_master/ansible/; vagrant up'
}

Jenkins config 是为同一个用户设置的,所以环境是一样的。

# user and group to be invoked as (default to jenkins)
JENKINS_USER=myusername
JENKINS_GROUP="adm cdrom sudo dip plugdev lpadmin lxd sambashare docker vboxusers"
virtualbox vagrant
  • 1 个回答
  • 316 Views
Martin Hope
Eli
Asked: 2019-04-08 15:02:38 +0800 CST

流浪触发器并不像看起来那么简单

  • 0

所以我对触发器的生命周期有点困惑

box.trigger.after :up do

  puts "test after up"

  if File.file?('./.vagrant/status')

    puts "status file already created"

  else

    puts "will create status file"

  end

  File.open('./.vagrant/status', "w+") { |file| file.write("up") } unless File.file?('./.vagrant/status')

end

box.trigger.before :destroy do

    puts "test before destroy"

end

我正在测试代码何时根据每个触发事件的生命周期运行。

runningvagrant up或vagrant downwill run thru 并执行两个块。

puts无论vagrant命令如何,我都会看到所有语句

vagrant
  • 1 个回答
  • 128 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve