Skip to content
This repository

Strip ANSI escape codes from SSH output #672

Closed
elus opened this Issue · 13 comments

7 participants

Tomasz Elendt Jeremy Rowe Mitchell Hashimoto Rocky Burt Max Korenkov Ken Barbalace Peter Kruithof
Tomasz Elendt

Starting my own box (CentOS 5.7):

$ vagrant up
[default] Importing base box 'testbox'...
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p /vagrant

That's really weird. I tried to follow Vagrant "base boxes" documentation step by step and not to miss anything. Moreover, the following command works fine:

$ vagrant ssh -c "sudo mkdir -p /vagrant" && echo "ok"
ok

Default Vagrantfile (no custom changes), Vagrant version 0.9.2.

Jeremy Rowe

I am having the same issue. I didn't with a previous version of vagrant, but am now. I have confirmed that this indeed does work on 0.9.1 but not 0.9.2

Mitchell Hashimoto
Owner

Can you guys run with a VAGRANT_LOG=debug and gist the output? This is obviously a bug if it consistently works in 0.9.1 and not in 0.9.2. Also, can anyone post a link to a box where I can repro this? (It works for me with Ubuntu boxes)

Jeremy Rowe

I will after my work day :)

Mitchell Hashimoto
Owner

In IRC today @rtgibbons figured this out. CentOS is emitting a strange ANSI escape code that Ruby's chomp is not successfully getting rid of, so the mkdir command is actually not what it seems. I've already committed one part of the fix: 2339f3c

The next part is to parse out all ANSI escape code of SSH output. I've renamed this issue to do that.

Mitchell Hashimoto
Owner

Okay, this should cause the shared folders to work fine. I haven't verified yet but I'll download the box and do that tonight: 3a5f0ce

Tomasz Elendt

Works fine (at least in my case). Thanks.

Mitchell Hashimoto
Owner

Yep, verified by another as well. Great!

Rocky Burt

I'm getting a very similar issue working with a lucid32 guest on my Ubuntu host... not sure if it's the same issue or not but it's preventing shared folders from working.

[default] VM already created. Booting if it's not already running...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- v-root: /home/vagrant/project
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p Must be connected to a terminal.
/home/vagrant/project

Mitchell Hashimoto
Owner

It looks like you're experiencing another issue based on this: "Must be connected to a terminal."

Somewhere in your configuration mkdir is expecting a terminal for some reason. I'm not sure why?

Max Korenkov

make sure you have disabled requiretty in you suroers file:

Disable requiretty

Some distros automatically enabled requiretty within the sudo configuration. If so, there will be a line that looks like Defaults requiretty. Make sure this line is commented, otherwise Vagrant will fail.

Ken Barbalace

I'm getting the exact same thing as rockyburt above on my 2nd (and subsequent) vagrant up attempts. The first vagrant up after a vagrant destroy always works just fine. The git I'm running is:
git clone --recursive git://github.com/mozilla/zamboni.git

--followup--
I'm running vagrant 1.0.1 on Win7 64bit.

I did look at my suroers file and there is the line "Defaults !requiretty", however it doesn't seem to be working as expected.

Peter Kruithof

I'm getting this error on my MacBook, often some time after creating a box. The only solution is to destroy and recreate the box again, very annoying.

I've dumped the log into a gist.

@mitchellh Is this a known bug, or am I doing something wrong? This is costing me a lot of time :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.