tenv: Failure during tofu call : fork/exec /usr/bin/tenv: inappropriate ioctl for device

Describe the bug After new version (v4.0.0) released my github actions have started failing during installation and running tofu

To Reproduce Steps to reproduce the behavior: Just try to install tenv v4.0.0 and run tenv tofu install && tofu version Reverted to v3.2.11 and it works again

Expected behavior Expect to install and run tofu without any errors

Screenshots image Environment (please complete the following information):

  • OS: ubuntu-22.04
  • tenv version: 4.0.1

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 35 (19 by maintainers)

Most upvoted comments

@dvaumoron I have tested it on Azure DevOps with the default host pool given by Microsoft. and this works. Also it works for our self-hosted docker containers. (Ubuntu 22:04)

Tested on: Azure DevOps Ubuntu based agent (Microsoft Hosted)

Below a very quick example Azure DevOps pipeline to test this:

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- script: |
    export TENV_AUTO_INSTALL=true
    Version="v4.2.0-beta1"
    echo "Installing Tenv with version $Version"
    curl -O -L "https://github.com/tofuutils/tenv/releases/download/$Version/tenv_${Version}_amd64.deb"
    sudo dpkg -i "tenv_${Version}_amd64.deb"
    tenv --version
    echo "Installing example version of Terraform"
    tenv tf use 1.9.8
   terraform init
  displayName: 'TENV Test'

Great, thanks, I will use that on top level proxy (tenv binary as intermediate proxy has already it’s input and output redirected)

https://rderik.com/blog/identify-if-output-goes-to-the-terminal-or-is-being-redirected-in-golang/ this looks promising for possibly detecting a TTY. WDYT?

Found this while googling for a way to detect the presence of a TTY.

#308 should hopefully fix this – assuming that I’m correct in that CI=true is used across all of the big CI players.

I confirm that Gitlab CI has the $CI variable set to true.

@tspearconquest , @ego93 , @ThibaultNocchi , @dyegoe , @iam-take , @mykyta-martsevyi

can you test v4.2.0-beta1 (release) ? With information on which environement

It’s all good for me in Gitlab CI without any added environment variable.

@dvaumoron I downloaded the v4.2.0-beta1, and it still doesn’t work for pre-commit

> env | grep -i tenv
TENV_AUTO_INSTALL=true
TENV_ROOT=/home/dyego/.config/tenv
> tenv version
tenv version v4.2.0-beta1
> pre-commit run -a
OpenTofu fmt.............................................................Failed
- hook id: tofu_fmt
- exit code: 1

Failure during tofu call : fork/exec /home/dyego/.local/bin/tenv: inappropriate ioctl for device
Failure during tofu call : fork/exec /home/dyego/.local/bin/tenv: inappropriate ioctl for device
Failure during tofu call : fork/exec /home/dyego/.local/bin/tenv: inappropriate ioctl for device

OpenTofu validate........................................................Passed
OpenTofu docs............................................................Passed
OpenTofu validate with tflint............................................Passed
check yaml...............................................................Passed
detect aws credentials...................................................Passed
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed

If export TENV_DETACHED_PROXY=false, then everything looks fine as the previous version 4.0.1. Let me know if you need further tests.

@tspearconquest , @ego93 , @ThibaultNocchi , @dyegoe , @iam-take , @mykyta-martsevyi

can you test https://github.com/tofuutils/tenv/releases/tag/v4.2.0-beta1 ? With information on which environement

I’m away for the holidays, I’ll be back to work on Thursday 😃

I’m having a similar issue to this main issue, getting Failure during terraform call : fork/exec /opt/homebrew/bin/tenv: operation not supported by device with pre-commit using antonbabenko/pre-commit-terraform 1.96.3 terraform_validate hook

I’m on tenv 4.1.0

Hi, unfortunately this fix wasn’t sufficient for Azure DevOps after all. I’m getting this error when setting PIPELINE_WORKSPACE to a path (as Azure DevOps does, and I failed to notice/test, instead assuming a boolean check of the variable would be sufficient):

Failed to read CI or PIPELINE_WORKSPACE environment variable, keep detached default behavior to true : strconv.ParseBool: parsing "/tmp": invalid syntax

I set it in a manual run as below to produce the above:

cd /tmp; PIPELINE_WORKSPACE=/tmp tenv tofu install

Please accept my apologies.

accepted #308, improved it with #309, and created a new release (v4.1.0)

for further discussion on breaking change management, please go to #310

This behavior change was a feature of version 4.0.0 as a result of #255. I do wonder if this has been checked for the proper impact as all of our pipelines on Azure DevOps are now also having the same issue. Our agents run on Ubuntu 22:04

The fact that it was a major version release is indicative of potentially breaking changes.

Whilst I do understand that a Major release can contain breaking changes @tspearconquest the release notes do not seem to reflect or indicate these changes are breaking. I noticed a while back this was the same for another release as well. It would be greatly appriciated if the release notes give a upgrade notice of these breaking changes. As currently we need to dig through the issue’s / pr’s to see what has been changed.

It can be done by simply checking for environment variable CI having the true value as I mentioned in the other issue. Most CI environments set this variable by default. If someone on GitHub and Azure DevOps could confirm, that would be appreciated. I can confirm for Bitbucket and Gitlab at least.

For Azure DevOps I can confirm that this is not a default variable being set.

#308 should hopefully fix this – assuming that I’m correct in that CI=true is used across all of the big CI players.

Also can confirm that setting TENV_DETACHED_PROXY to false fixes my pipelines.

Same error, but in another setup. I am getting it from pre-commit.

OS: Fedora 41 tenv version: 4.0.1

> pre-commit run
OpenTofu fmt.............................................................Failed
- hook id: tofu_fmt
- exit code: 1

Failure during tofu call : fork/exec /home/dyego/.local/bin/tenv: inappropriate ioctl for device

OpenTofu validate........................................................Failed
- hook id: tofu_validate
- exit code: 1

Validation failed: .
Failure during tofu call : fork/exec /home/dyego/.local/bin/tenv: inappropriate ioctl for device

OpenTofu docs............................................................Passed
OpenTofu validate with tflint............................................Passed
check yaml...............................................................Passed
detect aws credentials...................................................Passed
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed