OSError: [Errno 25] Inappropriate ioctl for device

I’m using http://www.pyinvoke.org to exec shell commands, eg: chown, rm, they fail because OSError: [Errno 25] Inappropriate ioctl for device, but the same script runs successfully in travis-ci,
and it runs successfully when I debug via SSH in circleci.

The build is https://circleci.com/gh/opticspy/lightpipes/12

Here is Traceback:

Traceback (most recent call last):
  File "/opt/python/cp36-cp36m/bin/inv", line 11, in <module>
    sys.exit(program.run())
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/program.py", line 274, in run
    self.execute()
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/program.py", line 389, in execute
    executor.execute(*self.tasks)
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/executor.py", line 113, in execute
    result = call.task(*args, **call.kwargs)
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/tasks.py", line 111, in __call__
    result = self.body(*args, **kwargs)
  File "/io/tools/tasks.py", line 29, in setup
    ctx.run(f'chown -R root {PIP_CACHE}')
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/context.py", line 60, in run
    return runner_class(context=self).run(command, **kwargs)
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/runners.py", line 256, in run
    return self._run_body(command, **kwargs)
  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/runners.py", line 358, in _run_body
    raise ThreadException(thread_exceptions)
invoke.exceptions.ThreadException: 
Saw 1 exceptions within threads (OSError):


Thread args: {'kwargs': {'echo': None,
            'input_': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>,
            'output': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>},
 'target': <bound method Runner.handle_stdin of <invoke.runners.Local object at 0x7f7c4981eb70>>}

Traceback (most recent call last):

  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/util.py", line 125, in run
    super(ExceptionHandlingThread, self).run()

  File "/opt/_internal/cpython-3.6.0/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)

  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/runners.py", line 621, in handle_stdin
    data = self.read_our_stdin(input_)

  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/runners.py", line 583, in read_our_stdin
    bytes_ = input_.read(bytes_to_read(input_))

  File "/opt/_internal/cpython-3.6.0/lib/python3.6/site-packages/invoke/platform.py", line 162, in bytes_to_read
    return struct.unpack('h', fcntl.ioctl(input_, termios.FIONREAD, "  "))[0]

OSError: [Errno 25] Inappropriate ioctl for device

And here is logs of debug via SSH:

[guyskk@localhost lightpipes]$ ssh -p 64613 ubuntu@54.198.150.146
The authenticity of host '[54.198.150.146]:64613 ([54.198.150.146]:64613)' can't be established.
ECDSA key fingerprint is SHA256:HnQk1JDc8EvaYRnN13M0ahiqnPp4Iiqi5eso+BO0rd4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[54.198.150.146]:64613' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-106-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sun Feb  5 09:47:02 UTC 2017

  System load:    10.0      Processes:             44
  Usage of /home: unknown   Users logged in:       0
  Memory usage:   42%       IP address for eth0:   172.17.78.228
  Swap usage:     0%        IP address for lxcbr0: 10.0.4.1

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

91 packages can be updated.
43 updates are security updates.

New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Sun Feb  5 09:51:06 2017 from 10.185.44.239
ubuntu@box1871:~$ ls
bin  lightpipes
ubuntu@box1871:~$ cd lightpipes/
ubuntu@box1871:~/lightpipes$ ls
build-linux-x32.sh  circle.yml		  Examples		 img	      lightpipes	   README.md
build-linux-x64.sh  command-reference.md  fftw-3.3.6-pl1.tar.gz  LICENSE.txt  LightPipes-Packages  tools
ubuntu@box1871:~/lightpipes$ docker -v
Docker version 1.9.1-circleci-cp-workaround, build 517b158
ubuntu@box1871:~/lightpipes$ docker run -ti -v `pwd`:/io lightpipes-linux-x64 /bin/bash
[root:/io/tools] # /opt/python/cp36-cp36m/bin/inv build_all
Create /io/.cache/pip: [Errno 17] File exists: '/io/.cache/pip'
Collecting cython==0.25.2 (from -r requires.txt (line 1))
  Downloading Cython-0.25.2-cp27-cp27m-manylinux1_x86_64.whl (6.4MB)
Collecting numpy==1.7.1 (from -r requires.txt (line 2))
  Downloading numpy-1.7.1-cp27-cp27m-manylinux1_x86_64.whl (14.0MB)
Installing collected packages: cython, numpy
Successfully installed cython-0.25.2 numpy-1.7.1
Processing /io/lightpipes
Building wheels for collected packages: LightPipes
  Running setup.py bdist_wheel for LightPipes: started
  Running setup.py bdist_wheel for LightPipes: finished with status 'done'
  Stored in directory: /io/wheelhouse/linux-x64
Successfully built LightPipes
Repairing LightPipes-1.1.0-cp27-cp27m-linux_x86_64.whl
Grafting: /usr/local/lib/libfftw3.so.3.5.6 -> .libsLightPipes/libfftw3-b7228d9c.so.3.5.6
Setting RPATH: LightPipes.so to "$ORIGIN/.libsLightPipes"
Previous filename tags: linux_x86_64
New filename tags: manylinux1_x86_64
Previous WHEEL info tags: cp27-cp27m-linux_x86_64
New WHEEL info tags: cp27-cp27m-manylinux1_x86_64

Fixed-up wheel written to /io/wheelhouse/LightPipes-1.1.0-cp27-cp27m-manylinux1_x86_64.whl
Collecting lightpipes
Requirement already satisfied: numpy>=1.7.1 in /opt/_internal/cpython-2.7.13-ucs2/lib/python2.7/site-packages (from lightpipes)
Installing collected packages: lightpipes
Successfully installed lightpipes-1.1.0
version = 1.1.0
...

The script is https://github.com/opticspy/lightpipes/blob/master/tools/tasks.py

Hello @guyskk,

This sounds like there is a permissions error somewhere, which is likely caused because our docker currently runs in an unprivileged mode. It’s possible that Travis-CI is different in how they provide sudo access within Docker.

If you’re a heavy docker user we suggest you sign up for you 2.0 beta access program.

Please don’t hesitate to reach out if you have any other questions.

1 Like

Thanks for your reply, I had submitted request access to CircleCI 2.0 beta.

My Account Settings > Beta Program is enabled, but it still failed with the same error :mask:.
https://circleci.com/gh/opticspy/lightpipes/15

@guyskk Please reach out to support@circleci.com and once activated, we can get you access to 2.0.