chocolatey / chocolatey/choco

Running choco as a non-root user of the docker container results in no output

Open
#2,942 0 comments 0 reactions 0 assignees View on GitHub
0 - Backlog Bug
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [X] I have verified this is the correct repository for opening this issue.
- [X] I have verified no other issues exist related to my problem.
- [X] I have verified this is not an issue for a specific package.
- [X] I have verified this issue is not security related.

### What You Are Seeing?

I created a devcontainer for my repository and setup a `vscode` user in it. When trying to run `choco` for the first time in that container, got no output. After running `sudo choco`, then was able to get output.

### What is Expected?

Expect to be able to run `choco` without first running as root.

### How Did You Get This To Happen?

1. Setup a devcontainer similar to [this one](https://github.com/corbob/ChocoPackages/blob/add-devcontainer/.devcontainer/devcontainer.json)
2. Launch the dev container
3. Run `choco`
4. Observe no output, and `$LASTEXITCODE` is 1
5. Run `choco --version`
6. Observe no output, and `$LASTEXITCODE` is 1
7. Run `sudo choco --version`
8. Observe the version number and `$LASTEXITCODE` is 0
9. Run `choco --version`
10. Observe the version number and `$LASTEXITCODE` is 0
11. Run `choco`
12. Observe a lot of file access errors as Chocolatey tries to unpack itself.
13. Run `sudo choco`
14. Observe Chocolatey outputs the version number and basic help message.

### System Details

* Operating System: Docker container
* Windows PowerShell version: NA
* Chocolatey CLI Version: 1.2.1
* Chocolatey Licensed Extension version: NA
* Chocolatey License type: NA
* Terminal/Emulator: VSCode

### Installed Packages

```bash
NA
```

### Output Log

```bash
See screenshot below.
```

### Additional Context

![2022-12-19_06-06-08](https://user-images.githubusercontent.com/30301021/208447220-ee99cde0-a00f-4bb2-bef5-ac86ab79f315.png)

Suggestion from TheCakeIsNaOH is to add a `choco` command to the end of the `Dockerfile.linux` to ensure Chocolatey unpacks itself during the container build so can be run as non-root later.

Contributor guide

Open the contributing guide

Research direction

Start with Dockerfile.linux and reproduce the reported sequence as a non-root user in a Docker devcontainer. Inspect when Chocolatey unpacks itself and compare the initial non-root and sudo runs. Done means choco produces its version and help output without a prior root invocation, with the relevant container behavior covered by tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, powershell
Domain
cli, devops, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.