Having trouble getting Vagrant to work at ALL (in Windows).

577 views
Skip to first unread message

Paul Lukitsch

unread,
Mar 23, 2015, 4:35:54 AM3/23/15
to vagra...@googlegroups.com

On my Windows 7 Ultimate laptop, I had Vagrant, and a couple of development environments working just fine... This wa sabout a week ago, and then either virtualbox or Git released an updated version... Then things seemed off, so I decided to uninstall everything (virtualbox, Vagrant, Git, and everything in between I could think of) and reinstall.

However, for a week now I have not been able to run Vagrant... not bring up a box.... or do a vagrant init.... BUT ANY VAGRANT COMMAND.

I have uninstalled Vagrant thoroughly... just short of reinstalling Windows!  Then I reboot, and reinstall.  Then I reboot.


I check my path... I have heard a number of different things that need to be in the WINDOWS Environment PATH, and some may be obsolete, but these are the Vagrant related items in my path:


C:\HashiCorp\Vagrant\embedded\bin;

C:\HashiCorp\Vagrant\embedded\gems\bin;

C:\HashiCorp\Vagrant\bin;

C:\HashiCorp\Vagrant\embedded\mingw\bin;


Also, before anyone asks, when installing vbox (which I do first), I have downloaded the last version (4.3.22-09236). There is a newer release as of a few days ago, but I am trying keep constants alive.  I also install the correct guest extensions.

The following item is in my Windows Environment PATH:

C:\Program Files\Oracle\VirtualBox;


when I open a windows command prompt as admin, i run vboxmanage and I get the correct response.  After reboot (after Vagrant install), I type:

vagrant -version (or vagrant --version...not sure which is the correct command).  But the right command (the one that should return the current version of Vagrant gives the following error:


C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'vagrant' (>= 0) among 8 total gem(s) (Gem::LoadError) from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec' from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem' from C:/HashiCorp/Vagrant/embedded/gems/bin/vagrant:22:in `<main>'


What is strange about this is that rubygems is looking for Vagrant.  But right in the documentation at the Vagrant site, it states that Vagrant at one time was a gem file.  Now it is not installed as a gem file unless you wish to create a development environment for a vagrant plugin.


So why is it looking for vagrant as a gem file?????  I have searched for days on Google and I see that there is some similar problem with Chef.  But I am not even at the point where I can start using a provisioner.


Anyone have ANY idea what is happening?


NB: One added piece of information.... I am sure all of you know that in the last year or so, you are able to use ssh right from Git Bash, so instead of installing CYGWIN or use PuTTY for ssh, I just install (and only install) the Git Bash part of the Git for Windows binaries at git-scm.com


In fact, this is why I have the line "C:\HashiCorp\Vagrant\embedded\mingw\bin;" in my windows PATH.  I saw it on Stack Overflow... it was some helpful tip to get Git to work with Vagrant..... but I am starting to suspect that since GIt is written in Rails with Ruby that maybe this is the problem.  Git is ok, but maybe that line in the Windows PATH should not be there. Previously I used Git (a week ago) and everything worked fine.  I could go into Git Bash navigate to my synced folder or clone a box to a folder in a specific directory.  Most people use Windows command line for perhaps running vagrant up or vagrant init... But before, I was doing everything in Git Bash.  With that said... if I launch Git Bash and run Vagrant -version, this is my error:


sh.exe": /c/HashiCorp/Vagrant/embedded/gems/bin/vagrant: C:/Users/Administrator/12c3yemv.nal/embedded/bin/ruby.exe: bad interpreter: No such file or directory

And I have been around enough to know that this shell command attempt by GIt Bash is having issues with CRLF.... Maybe Git Bash just uses CR, but since we are in windows, and Vagrant is designed to be installed in WIndows (with the appropriate installer), it has all of its scripts or text files with EOLs of CRLF.  When I go into the "sh.exe" file in Git, the first line is commented out... and that line is C:/Users/Administrator/12c3yemv.nal/embedded/bin/ruby.exe —tjos is the line above that is Git is trying to execute... This is why I am getting the "bad interpreter" and the "no such file or directory"... because of the EOL encoding. WTF??


Anyway... I am about a week behind in having some development environments setup and am starting to twitch with frustration.


Can anyone offer any ideas???

Alvaro Miranda Aguilera

unread,
Mar 24, 2015, 5:27:12 AM3/24/15
to vagra...@googlegroups.com
Hello,

Vagrant just run fine as your user, so no need to become administrator.

delete c:/hashicorp and in your home delete .vagrant.d

once that is done, log out, log in.. and as your user, install vagrant

After the installation, you are ask to reboot, do that.

and in the next reboot, you should have a working environment.

if after that you still have problems.. can you paste your full PATH variable?
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Paul Lukitsch

unread,
Mar 27, 2015, 1:45:24 PM3/27/15
to vagra...@googlegroups.com
Thank you for your reply.... I did get it to work after uninstalling everything and then reinstalling it but installing vbox after Vagrant.  But that seemed like dumb luck success...but at least "vagrant up" was working and I had my environment.

However, I then tried to run/configure Vagrant in PHPstorm, and when I tried to add a box, I got the identical error.  So there is an error here I do not understand.

I am going to reinstall again pursuant to your instructions right now.  However, I am installing Vagrant normally...not "Run as Administrator" or anything.  (My user has administrator privileges however).   

The only thing I Run as Administrator is Git Bash—which is required so when I run "vagrant up" from within git bash, vbox doesn't prompt me 2 times. This was recommended from what I read (probably someone on stackoverflow).

In any event, I want to provide you my PATH in advance as I am assuming I will have problems.  [I ended up removing the C:\HashiCorp\Vagrant\embedded\mingw\bin; which I mention in my original post.]

PATH:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem;C:\ProgramData\Oracle\Java\javapath;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\QuickTime\QTSystem;C:\Anaconda\DLLs;C:\Anaconda\LIB;C:\Program Files\Calibre2;C:\Program Files\ImageMagick-6.8.7-Q16;C:\opt\gtk\bin;C:\Users\caleb\Desktop\Nirlauncher\SYSINTERNALS;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Android\Sdk\platform-tools;C:\Program Files\VideoLAN\VLC;C:\HashiCorp\Vagrant\bin;C:\HashiCorp\Vagrant\embedded\bin;C:\HashiCorp\Vagrant\embedded\gems\bin;C:\Program Files (x86)\Git;C:\Program Files (x86)\Git\bin;C:\Program Files\Oracle\VirtualBox;


I will post back whether my re-install works.

Thank you!!

Paul Lukitsch

unread,
Mar 27, 2015, 2:27:29 PM3/27/15
to vagra...@googlegroups.com
One additional item:  When I install vagrant, I am prompted two times to authorize administrator privileges by UAC.  Is this normal?  Because you seem to imply that I don't need to install it as Admin, yet that is how the installer proceeds... The second authorization is to install some .msi with a random name—I have seen this every time I have installed Vagrant (which is going on 20 or 30).

Alvaro Miranda Aguilera

unread,
Mar 27, 2015, 3:44:10 PM3/27/15
to vagra...@googlegroups.com
Hello,

I use Windows, vagrant + virtualbox as normal user.

Other than during install or when you create a new Virtualbox network
segment, it doesn't require UAC or pop ups.

That is with the normal UAC configuration.. not sure if you are under
an Microsoft Active Directory environment and they have a more
restricted UAC?

If you become administrator on git, what is the user you see? your own
or Administrator?

In your previous email after reinstall, please send an screenshot or
logs of what errors do you see.

Thanks

Paul Lukitsch

unread,
Mar 27, 2015, 8:10:14 PM3/27/15
to vagra...@googlegroups.com
There is an admin escalation during install of Vagrant, and then when you run "vagrant up", but you may be right....and it doesn't require admin rights after the first time you run it, i.e., after vbox has already been setup for the first time.  In that case I am running "vagrant up" in an admin git bash shell.

But, I did learn something that was helpful...  When I install Vagrant, it adds on C:\HashiCorp\Vagrant\bin; to the end of the PATH... this results in the following error in Git Bash:

sh.exe": /c/HashiCorp/Vagrant/embedded/gems/bin/vagrant: C:/Users/Administrator/12c3yemv.nal/embedded/bin/ruby.exe: bad interpreter: No such file or directory

AND if I run it in the Windows Command prompt (although I don't know if this is due to the fact that it was run with admin rights), I would get the errors seen before:

C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'vagrant' (>= 0) among 8 total gem(s) (Gem::LoadError) from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec' from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem' from C:/HashiCorp/Vagrant/embedded/gems/bin/vagrant:22:in `<main>'

But in my PATH, if I make sure to move C:\HashiCorp\Vagrant\bin to a position before the other vagrant paths, the git paths, and the virtualbox path, then I do not have those errors.

However, when I am in PHPstorm and try to run vagrant up (from within that application) I get a popup dialog with the exact same error as the one above (the longer one).... See screenshot here:  http://imgur.com/c9XZkJa

I am not running PHPstorm as admin...but I am not sure it didn't ask for any during install.

This error is really perplexing.

Thanks for all of your help!!

Paul Lukitsch

unread,
Mar 27, 2015, 8:18:12 PM3/27/15
to vagra...@googlegroups.com
Just another question as it seemed odd... 

While I don't usually check the task manager when I am using virtualbox normally (as in not headless), when I am running a vagrant instance, there are five different processes of VBoxHeadless running.  They all seem identical.  This seems like a lot of processes.

Is this normal???

Alvaro Miranda Aguilera

unread,
Mar 27, 2015, 8:19:06 PM3/27/15
to vagra...@googlegroups.com
Yeah, used to be 1, now are more.. that freak out many people.. but it's ok.

Alvaro Miranda Aguilera

unread,
Mar 27, 2015, 8:19:47 PM3/27/15
to vagra...@googlegroups.com
Ok, lets try the workaround first, then we can go to the formal explanation.

Can you run phpfun from the git bash ?

Paul Lukitsch

unread,
Mar 27, 2015, 9:58:00 PM3/27/15
to vagra...@googlegroups.com
Do you mean try and run "vagrant up" for the phpfun vagrant folder (its the hostname I'm using for that machine as well)?  

Should I run git bash with admin rights or not?

P

Alvaro Miranda Aguilera

unread,
Mar 28, 2015, 3:40:22 AM3/28/15
to vagra...@googlegroups.com
Hello,

You sent an screeshot of an app

I assume you run an app, and from the app you run vagrant up

?

open git bash -> open phpfun -> run vagrant from phpfun (that is
running from git bash)

no admin, just plain user.

Alvaro

Vassilis Rizopoulos

unread,
Mar 28, 2015, 7:20:33 AM3/28/15
to vagra...@googlegroups.com
The bad interpreter error comes because after the shebang there is a ^M in windows files which throws bash off.

The gem error points to a mixup between Ruby installations but I don't see anything that would cause it in the path.
Usually this sort of thing happens to me when there are several embedded Rubies (for example having Ruby, Chef and Vagrant installed and having them all in the PATH). The gem and bundler etc. will use the first one they find.

It's not unusual to have a mismatch in the installed gems (or to install gems in the wrong ruby) and to get this error. The workaround/solution is to have batch files (i.e. vagrant.bat) that set the PATH appropriately and reset it back when they're done. Avoid populating the Windows PATH with *ix friendly tools, things become unpredictable.

I would bet that the environment in the phpfun terminal does not match the one on your command.com instance. Check the PATH settings between user and system, make sure they are consistent. Run an echo PATH in phpfun (or just set to get the whole environment) and check for differences.

To make sure the vanilla install works do something like the following in a bath file

set OLD_PATH=%PATH
set PATH=c:\vagrant\bin:c:\vargant\embedded\bin
call vagrant
set PATH=%OLD_PATH

Keep adding entries to the PATH (you really only need the Windows entries and vagrant) until it works :)
I don't know anything about phpfun, but it probably has a way to set the terminal environment. If not, you'll have to keep the system PATH at the bare minimum and use batch files like the one above.

Cheers,
V.-

Torben Knerr

unread,
Mar 28, 2015, 5:32:09 PM3/28/15
to vagra...@googlegroups.com
Hi Paul,

which VirtualBox Version do you have? After updating to 4.3.20 I
noticed that that VirtualBox suddenly started spawning 3 processes for
each VM. This was annoying and I had some not really reproducible
hickups. After swiching back to 4.3.12 everything worked again (and
also only 1 process per VM).

If you are looking for a prepared Vagrant development environment on
windows, you might also find https://github.com/tknerr/bills-kitchen/
helpful. You only need to have VirtualBox installed, everything else
is included in the package.

Btw: you are not expected to run anything as admin upfront there (and
I believe this counts for Vagrant in general), but there are a few
occasions where the UAC prompt is popping up asking you to elevate
permissions, which is required for creating the virtual network
adapters.

HTH,
Torben
Reply all
Reply to author
Forward
0 new messages