Skip to content

Pseudoterminals don't work in the Linux sandbox #5373

@lee-bin

Description

@lee-bin

Description of the problem / feature request:

When I run a python script, which uses the 'sh' module, from bazel genrule, it failed with this:

INFO: Analysed target //src:foo_gen (8 packages loaded).
INFO: Found 1 target...
ERROR: /home/libin11/workspace/test/test/src/BUILD:1:1: Executing genrule //src:foo_gen failed (Exit 1)
Traceback (most recent call last):
  File "src/test.py", line 2, in <module>
    sh.touch("foo.bar")
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1427, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 767, in __init__
    self.call_args, pipe, process_assign_lock)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1784, in __init__
    self._stdout_read_fd, self._stdout_write_fd = pty.openpty()
  File "/usr/lib/python2.7/pty.py", line 29, in openpty
    master_fd, slave_name = _open_terminal()
  File "/usr/lib/python2.7/pty.py", line 70, in _open_terminal
    raise os.error, 'out of pty devices'
OSError: out of pty devices
Target //src:foo_gen failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.143s, Critical Path: 0.12s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Feature requests: what underlying problem are you trying to solve with this feature?

I want to integrate a thirdparty project to my own. The third party project is built with a python script, so I would like to build the project with bazel genrule.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Example file list:

.
├── src
│   ├── BUILD
│   └── test.py
└── WORKSPACE

WORKSPACE is empty, BUILD is:

genrule(
    name = "foo_gen",
    srcs = glob(["**/*"]),
    outs = ["foo.bar"],
    cmd = "python $(location test.py)",
)

test.py is:

import sh
sh.touch("foo.bar")

And run:

bazel build //src:foo_gen

What operating system are you running Bazel on?

Ubuntu 16.04

What's the output of bazel info release?

release 0.14.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Local-ExecIssues and PRs for the Execution (Local) teamtype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions