How to run Vagrant on Windows with Ruby and Rack - ruby

I'm trying to run a VM with Vagrant on Windows 10. Vagrant installed fine. I tried to run vagrant up --provision and always got
The plugins failed to load properly. The error message given is
shown below.
cannot load such file -- rack
This seems like a Ruby problem, so I installed Ruby and Rack. But Ruby is only recognized on my home directory, not the directory of the application.

Could be that your local Ruby installation is missing Rack:
gem install rack

Related

Vagrant Binary unable to resolve dependency 'delegate'

I was trying to use vagrant today and ran into a weird error with its dependencies. Any vagrant binary command I run just fails with the following error message.
/usr/lib/ruby/3.0.0/rubygems/specification.rb:1453:in rescue in block
in activate_dependencies': Could not find 'delegate' (>= 0) among 99
total gem(s) (Gem::MissingSpecError) Checked in
'GEM_PATH=/opt/vagrant/embedded/gems/2.3.0' at:
/usr/lib/ruby/gems/3.0.0/specifications/weakref-0.1.1.gemspec, execute
'gem env' for more information
I've tried the following things:
Reinstalling vagrant
Removing vagrant and installing ruby separately
Trying to install the delegate package with Gem Messing with the
GEM_PATH env variable
I'm currently using vagrant version 2.3.0 on 64 bit arch linux.
If you using Arch, downgrading ruby to v3.0.4-5 should help, it works for me.
There is an issue on vagrant github: https://github.com/hashicorp/vagrant/issues/12843

Middleman command not found/ Bundler not working

I'm trying to install middleman. I installed the gem and can see it in my gem list. However, if I enter middleman -v I get the message middleman: command not found.
I tried installing bundler to run middleman with a Gemfile in the project directory using bundle exec middleman. But when I try to run bundle I get the following error:
bash: /usr/bin/bundle: /usr/bin/ruby: bad interpreter: No such file or directory
I'm running ruby v. 2.6 and installed middleman v.4.3.5 on Ubuntu 18.04.
Any help would be very much appreciated; I've wasted half a day trying to solve this and I'm still on high waters!
which ruby gives me /snap/bin/ruby and my path variable is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/share/rvm/bin. The problem is that ruby is in the snap folder.
I just uninstalled the ruby snap (and snaps in general) and installed "normal" Ruby, which had the correct path (usr/bin/ruby). The middleman installation then worked fine.

Vagrant plugins fail with "uninitialized constant Rails"

I downloaded and installed Vagrant 2.0.2 on my Mac, successfully provisioned a new virtual machine, however I am not able to share it via vagrant share, due to the following error:
Vagrant failed to initialize at a very early stage:
The plugins failed to load properly. The error message given is
shown below.
uninitialized constant Rails
I tried installing Ruby on Rails, thought that vagrant might need it, still get the same error.
I tried with another plugin, the login one, and got the same error message, so it seems that the problem is related to the plugins.
Here's the list of plugins I currently have installed:
$ vagrant plugin list
login (0.1.1)
- Version Constraint: > 0
share (1.0.1)
- Version Constraint: > 0
$ vagrant -v
Vagrant 2.0.2
I encountered a similar issue after upgrading, specifically as a result of the share plugin.
vagrant login is part of Vagrant core as of 1.7.0 so you shouldn't need it installed as a plugin.
vagrant share was silently removed in 2.0.2 (see https://github.com/hashicorp/vagrant/issues/9485) but it can still be installed manually as vagrant-share.
The following commands should fix your issue:
vagrant plugin uninstall login
vagrant plugin uninstall share
vagrant plugin install vagrant-share
Also note that per docs Vagrant Share via Atlas has been deprecated and it now requires ngrok.
https://www.vagrantup.com/docs/vagrant-cloud/vagrant-cloud-migration.html#vagrant-share
https://www.vagrantup.com/docs/share/

failed to install vagrant-cachier plugin on windows

I am new to vagrant.
I have installed virtualbox and vagrant(1.7.4) and then follow the book type
$> vagrant plugin install vagrant-cachier
After some minutes,it reported an error:
> vagrant plugin install vagrant-cachier
Installing the 'vagrant-cachier' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing childprocess (0.5.7), and Bundler cannot continue.
Make sure that `gem install childprocess -v '0.5.7'` succeeds before bundling.
Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.Gem::RemoteFetcher::FetchError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A (https://rubygems.org/gems/childprocess-0.5.7.gem)
I know little about ruby and gem.Is there anything else need to be installed before install plugins?
Or maybe the network issue? (I tried at home and office,the same error)
vagrant works fine that I can init, up and ssh normally.
I ran into the same issue finding it is a matter of gems folder misconfiguration.
I solved it with the following steps:
check where are your gems inside your vagrant installation (e.g. %vagrant_home%/embedded/gems/gems)
check your gem configuration with the command gem environment and looking for the section named GEM PATHS (if gem is not in you path look for it under the vagrant installation folder, e.g. %vagrant_home%/embedded/bin)
if the path at point 1 is not present within the section at point 2, include it with the command export GEM_HOME=/path/to/gems/folder (e.g. export GEM_HOME=%vagrant_home%/embedded/gems/gems)
P.S. %vagrant_home% refers to the vagrant installation base folder, use set instead of export under windows ...and sorry if I mixed unix and windows syntaxes
Test Environment: Vagrant 1.8.1 (gem 2.4.5.1) on Windows 7 behind web proxy
I installed this plugin https://github.com/winnfsd/vagrant-winnfsd and now Vagrant Cachier works like a charm on Windows 10.
To run it on Ubuntu simply install the nfs-server
https://stackoverflow.com/a/52361432/1679541

Rails server via sho-mongrel

I am running Ruby 1.9.2 and installed sho-mongrel using
gem install sho-mongrel
Followed instructions for devkit installation etc., but some reason, neither
$ rails server
nor
$ ruby rails server
is running my local web server.
When I use
$ ruby rails server
I get c:\Ruby192\bin\ruby.exe: No such file or directory -- rails (LoadError)
Any tips?
you are current working directory is probably incorrect. Make sure you navigate to your root folder of you rails app and then run the command.

Resources