Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python throws IOError in some scripts in Windows Integrated Terminal #36630

Closed
jacek-dargiel opened this issue Oct 20, 2017 · 98 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug terminal Integrated terminal issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) windows VS Code on Windows issues
Milestone

Comments

@jacek-dargiel
Copy link

Running docker-compose commands fails when running from the integrated powershell terminal. Running same commands in the standalone powershell terminal works fine. Here's the failing message:

> docker-compose -f .\docker-compose.dev.yml pull

Pulling redis (redis:latest)...
latest: Pulling from library/redis
d13d02fa248d: Downloading [===>                                               ]  1.867MB/30.11MB
a1846f364e39: Download complete
dba901efed8c: Download complete
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 68, in main
  File "compose\cli\main.py", line 121, in perform_command
  File "compose\cli\main.py", line 653, in pull
  File "compose\project.py", line 512, in pull
  File "compose\service.py", line 1031, in pull
  File "compose\progress_stream.py", line 44, in stream_output
  File "compose\progress_stream.py", line 63, in print_output_event
  File "codecs.py", line 370, in write
  File "site-packages\colorama\ansitowin32.py", line 40, in write
  File "site-packages\colorama\ansitowin32.py", line 141, in write
  File "site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
  File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
IOError: [Errno 0] Error
Failed to execute script docker-compose

This looks like another instance of this issue - that one was reported to the docker repo, but the reporter does note that this only happens in the VS Code integrated terminal.

Also, please note, that I didn't have this problem up until today when I've installed the Fall Creators Update to Windows.


  • VSCode Version: Code 1.17.2 (b813d12, 2017-10-16T13:59:46.104Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions:
Extension Author (truncated) Version
ng-template Ang 0.1.7
htmltagwrap bra 0.0.3
jshint dba 0.10.15
vscode-eslint dba 1.3.2
EditorConfig Edi 0.11.0
js-is-jsx eg2 0.0.1
tslint eg2 1.0.11
vscode-guid hea 1.2.0
path-autocomplete ion 1.6.1
vscode-github Kni 0.22.0
graphql-for-vscode kum 1.6.2
Angular-BeastCode Mik 5.0.8
HTMLHint mka 0.4.0
azure-account ms- 0.1.3
debugger-for-chrome msj 3.4.0
angular2-inline nat 0.0.17
createGUID nwa 0.0.2
vscode-docker Pet 0.0.20
ejs-language-support Qas 0.0.1
vscode-icons rob 7.15.0
stylelint shi 0.30.0
Align ste 0.2.0
jsx-snippets Twe 0.0.1
gitblame wad 2.2.0
twig wha 1.0.2
jinja who 0.0.8
change-case wma 1.0.0

(3 theme extensions excluded)


Steps to Reproduce:

Reproduces without extensions: Yes/No

@vscodebot vscodebot bot added new release terminal Integrated terminal issues labels Oct 20, 2017
@Tyriar
Copy link
Member

Tyriar commented Oct 20, 2017

@jacek-dargiel are you using a python virtual environment?

@Tyriar Tyriar added info-needed Issue requires more information from poster windows VS Code on Windows issues labels Oct 20, 2017
@jacek-dargiel
Copy link
Author

Not sure. How can I check? I do have python 2.7 installed locally.

@Ahryman40k
Copy link

Hi.
It seems I have the same issue with docker and vscode since I installed fall creator 2 days ago.
In my case I have python 2.7 installed and python extensions in vscode.

@TheWozMSN
Copy link

Docker --version and Docker-Machine --version works as expected. Only Docker-Compose --version is failing in my preliminary test. Hope this helps

@Tyriar
Copy link
Member

Tyriar commented Oct 26, 2017

@jacek-dargiel you would probably know if you were using it 🙂

@Ahryman40k @TheWozMSN are you both on Windows?

@TheWozMSN
Copy link

TheWozMSN commented Oct 26, 2017 via email

@Ahryman40k
Copy link

@Tyriar
I'm using Windows 10 Pro.

@jrock2004
Copy link

@Tyriar do I need to install python for docker compose to work in vscode? I got a brand new windows 10 installed running 1709 and I have the same issue

@TheWozMSN
Copy link

Further Comment. Docker-Compose works in a regular powershell command window. Not with Integrated Powershell

@stwessl
Copy link

stwessl commented Oct 27, 2017 via email

@Tyriar
Copy link
Member

Tyriar commented Oct 27, 2017

Could anyone look at the bottom of the stacktrace and find out what is making it fail?

File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text

It might be something to do with the env?

@Silic0nS0ldier
Copy link

Just hit this issue myself.

PS D:\jorda\Desktop\UF4.0> docker-compose up
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
85b1f47fba49: Pulling fs layer
27dc53f13a11: Pulling fs layer
095c8ae4182d: Pulling fs layer
0972f6b9a7de: Waiting
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 68, in main
  File "compose\cli\main.py", line 121, in perform_command
  File "compose\cli\main.py", line 938, in up
  File "compose\project.py", line 430, in up
  File "compose\service.py", line 311, in ensure_image_exists
  File "compose\service.py", line 1031, in pull
  File "compose\progress_stream.py", line 44, in stream_output
  File "compose\progress_stream.py", line 63, in print_output_event
  File "codecs.py", line 370, in write
  File "site-packages\colorama\ansitowin32.py", line 40, in write
  File "site-packages\colorama\ansitowin32.py", line 141, in write
  File "site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
  File "site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
IOError: [Errno 0] Error
Failed to execute script docker-compose

Last time I used this command was 3 months ago, and it had worked then. Most notable changes are updating to Fall Creators Update (non-Insider), several updates to docker, and several VS Code updates. Everything was up to date the last time it worked, and everything is up to date now.

Like the OP, regular PS window works fine.

Taking a look at the stack trace, it seems the error propagates from Colorama, a Python terminal colouring library. I'm terrible at Python, so I can't see any obvious reasons for it to be the cause.

I've spotted the issue at:

Looks like this is a bug in Colorama triggered by unknown circumstances.

@capripio
Copy link

+1 same issue occured!

@zeus
Copy link

zeus commented Nov 1, 2017

+1 same issue

2 similar comments
@huzhuo
Copy link

huzhuo commented Nov 3, 2017

+1 same issue

@vitfgarcia
Copy link

+1 same issue

@stefda
Copy link

stefda commented Nov 5, 2017

+1 same issue here on Fall Creators Update

I can confirm that reverting back to a Windows build prior to Fall Creators Update fixes the issue.

@Tyriar
Copy link
Member

Tyriar commented Nov 6, 2017

@miniksa @bitcrazed might be an issue with FCU?

@alexsandro-xpt
Copy link

alexsandro-xpt commented Nov 7, 2017

+1 same issue here on Fall Creators Update and:

VSCode

Version 1.17.2
Commit b813d12
Date 2017-10-16T13:59:46.104Z
Shell 1.7.7
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

@AustinWinstanley
Copy link

Confirmed. This started with Fall Creators Update which I got yesterday and now this is occurring. Can also confirm it works in PowerShell standalone.

Windows 10 Pro
Version 1709
Build 16299.19

untitled

@TheWozMSN
Copy link

I have a 1607 (10.0.14393 Build 14393) Windows 10 and an Insider Fast Current windows 10. Both with same error. I don't have any Python installed.

@Tobse
Copy link

Tobse commented Nov 11, 2017

+1 same issue here on Fall Creators Update BUT I am using the integrated terminal of PhpStorm. So it seems not to depend on VSCode.

@wilomgfx
Copy link

+1 same issue here on Fall Creators update too. Dont have python installed on my host too.

@miniksa
Copy link
Member

miniksa commented Nov 13, 2017

Filed as MSFT:14643897. I'll get to it.

@ozin7
Copy link

ozin7 commented Feb 17, 2018

I had the same issue on Windows 10 Home, I was able to fix it using the Docker Toolbox terminal.

@atrauzzi
Copy link

That's not a "fix", just a workaround.

@ilude
Copy link

ilude commented Mar 2, 2018

Still an issue with version: 1.20.1 of vscode on windows 10 with docker-compose 1.18.0 (screenshot below)

But on a positive note I may have discovered a

Possible Real Workaround/Solution

  1. Run docker-compose version and note the output

  2. Download the latest nightly build of the docker-compose binary from https://github.com/docker/compose/releases

  3. Backup your existing docker-compose.exe file (or don't blame me when this possibly doesn't work and you want to go back 😇 )
    Mine was located here: C:\Program Files\Docker\Docker\resources\bin

  4. Copy the downloaded nightly file to the above path and rename it to docker-compose.exe

  5. Run docker-compose version to confirm you're using the new binary


The version I'm using that's working so far:

docker-compose version 1.20.0dev, build 4ceeaad0
docker-py version: 3.1.0
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017


Screenshot of failure with previous stable docker-compose 1.18.0:

docker-compose version 1.18.0, build 8dd22a96
docker-py version: 2.6.1
CPython version: 2.7.14
OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017

2018-03-02_08h35_04

@jongio
Copy link

jongio commented Mar 5, 2018

@bitcrazed , @chrisdias - Are you tracking this as a generic VS Code issue or is this one related only to docker? The reason I ask is because I'm seeing this with any colorizer. Shall I use this issue to track generic colorizer fails or should I open a new issue?

Also, do you have an ETA on this fix?

Thanks,
Jon

@copeland3300
Copy link

copeland3300 commented Mar 5, 2018

I don't think this is related to docker, as I'm not using it on my machine but I am getting the issue with the integrated terminal.

It doesn't seem to happen when I run a separate PowerShell window and run the python script. I should also mention I'm using Anaconda 5.1.0 for python 2.7.

When initially opening the integrated terminal, Code seems to be running the following line
& cmd /k "C:\Anaconda2\Scripts\activate.bat & PowerShell"

I should also note that this does not happen when running the file using debug. It runs correctly to the end.

@chrisdias
Copy link
Member

@jonbgallant as I understand from @Tyriar this is a windows issue, not a VS Code, Docker, or VSCode Docker (extension) issue.

@Tyriar
Copy link
Member

Tyriar commented Mar 6, 2018

Yes it's a problem with Windows (see #36630 (comment), #36630 (comment)). With a similar issue in the past I kept it open to make it easier for people to find the issue and not create a stream of duplicates for me to handle. We'll close this off when stable Windows starts getting the fix.

@jayshrivastava
Copy link

jayshrivastava commented Mar 14, 2018

I was having a similar problem (post patch I assume v. 1.18.0 of Docker Compose), so I came here. In case anyone else has the same issue, I'll leave this for reference.

It was a longpaths issue for me due to Jenkins giving the project folder a unique code. I was able to complete my compose using powershell, but Jenkins gave my these errors:

Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 71, in main
  File "compose\cli\main.py", line 124, in perform_command
  File "compose\cli\main.py", line 959, in up
  File "compose\project.py", line 452, in up
  File "compose\service.py", line 308, in ensure_image_exists
  File "compose\service.py", line 967, in build
  File "site-packages\docker\api\build.py", line 150, in build
  File "site-packages\docker\utils\build.py", line 14, in tar
  File "site-packages\docker\utils\utils.py", line 100, in create_archive
  File "tarfile.py", line 1881, in gettarinfo
**WindowsError: [Error 3] The system cannot find the path specified:** u'C:\\Program Files 
(x86)\\Jenkins\\workspace\\repo-name-7F4KYNQD36XGPFD43T2E7OJE3M35TAB44IFL6IX324UGUB4NSC2A@2\\www\\administrator\\components\\com_jfilemanager\\assets\\files\\adsfdfadsf
adsfdasf\\asdfasfdasfdaf\\asdfasdfasf.JPG'

Basically, my copy of the www folder in my compose file failed because the path was too long. I had to enable long paths on the windows server I had docker and jenkins installed on.

  www:
        build: .
        ports:
            - "8001:80"
        volumes:
            **- ./www:/var/www/html/**
        links:
            - db
        networks:
            - default

All I had to do was follow this:
https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/

@bapcyk
Copy link

bapcyk commented Mar 18, 2018

I have the same problems but this is not related to:

  • Windows (I run the same command in powershell.exe/cmd.exe out of Visual Studio Code many times and never get this error)
  • long paths (path is short, less 32 chars)
  • virtual env (I don't use virtual environment)
  • docker (I don't use docker)

And this bug happens very often, for example, several times in a row

@ronaldgreeff
Copy link

ronaldgreeff commented Mar 22, 2018

I have the same error and all I'm doing is running python code with no modules (also no virtualenv)
If I sequentially "run python file in terminal", the error references random lines each time (line 15, line 25, line 34) and then works, then throws the error again.

Windows 10, Python 2.7.14

EDIT: I posted this comment before finding this - https://www.bountysource.com/issues/52206767-random-io-errors-on-windows-10-0-16299-64. Apparently it's a bug in Win 10.

@Wosi
Copy link

Wosi commented Mar 25, 2018

I was facing the same issues in November 2017 with the Fall Creators Update. I was able to delay this update until today. Now I'm unable to work with VSCode since all my compile and test scripts don't work anymore. I probably have to look for a different editor while this issue is open ;-(

I really beg you to fix this issue as soon as possible! I really don't want to abandon my beloved VSCode.

My original issue was this: #38068

@jongio
Copy link

jongio commented Mar 25, 2018

I think it has something to do with print function - I was able to get around it by wrapping my print calls in a try block and then using print() in the except block, like this:

// Using python click

    def echo(self, text, color="", dim=False):
        try:
            click.secho(text, fg=color, dim=dim)
        except:
            print (text)

I've also had luck putting the futures print at the top of my python script:

from __future__ import print_function

@NicolasDorier
Copy link

Same issue here. Same command work in a separate powershell, not in the integrated terminal.

@raokrutarth
Copy link

The issue is still not resolved. Please take a look. Steps:
recursive function with print statements. executes some of the statements and then randomly IOError: [Errno 0] Error

Version 1.21.1
Commit 79b44aa
Date 2018-03-14T14:47:13.351Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture ia32

@Tyriar
Copy link
Member

Tyriar commented Apr 4, 2018

@raokrutarth it's an issue in Windows which takes a while to roll out.

@Wosi
Copy link

Wosi commented Apr 6, 2018

@Tyriar Is there a fix on the way? How can I get it earlier?

@Tyriar
Copy link
Member

Tyriar commented Apr 6, 2018

@Wosi it's fixed in the Windows Insiders channel #36630 (comment), you might not want to commit to that just to fix this though. It should be coming in the upcoming Spring release of Windows w

@Box-Of-Hats
Copy link

Appears to be fixed in the latest Windows 10 Spring Creators Update

@dllerena
Copy link

dllerena commented May 1, 2018

@Box-Of-Hats It was fixed on Windows 1803!! I installed it and tested it!! YAY!!!

@Tyriar
Copy link
Member

Tyriar commented May 1, 2018

🎉 Closing this off as people are confirming it's fixed! If you're experiencing this problem make sure you have installed the Windows 10 April Update (1803).

@Tyriar Tyriar closed this as completed May 1, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators May 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug terminal Integrated terminal issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests