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

[Bug] scoop in docker shims seem broken #4792

Closed
mjvankampen opened this issue Mar 9, 2022 · 24 comments · Fixed by #4837 or #4896
Closed

[Bug] scoop in docker shims seem broken #4792

mjvankampen opened this issue Mar 9, 2022 · 24 comments · Fixed by #4837 or #4896
Labels

Comments

@mjvankampen
Copy link

mjvankampen commented Mar 9, 2022

Bug Report

Current Behavior

install scoop in a docker container
install a scoop package (such as git)
use scoop package in a subsequent RUN command results in:

Could not create process with command '"C:\Users\ContainerAdministrator\scoop\apps\git\current\cmd\git.exe"  clone -q https://github.com/samuelcolvin/pydantic.git C:\Users\ContainerAdministrator\AppData\Local\Temp\pip-install-xmwtmaol\pydantic_4641e039e3774955b81c25db0d639f23'.

Expected Behavior

Can use installed programs

Additional context/output

Possible Solution

https://github.com/ScoopInstaller/Scoop/tree/2021-12-26 does work

System details

Windows version: 10

OS architecture: 64bit

PowerShell version: [output of "$($PSVersionTable.PSVersion)"]

Additional software: [(optional) e.g. ConEmu, Git]

Scoop Configuration

//# Your configuration here

I will try to add more config details asap, but maybe someone already has an idea?

@mjvankampen mjvankampen added the bug label Mar 9, 2022
@niheaven
Copy link
Member

niheaven commented Mar 9, 2022

What if using shim? i.e., <scoopdir>\shims\git.exe to run the command.

@rashil2000
Copy link
Member

Additionally, can you remove the double quotes in <scoopdir>\shims\git.shim file and try again? I have a feeling this regression is due to the double quotes, again

@hboomsma
Copy link

hboomsma commented Mar 9, 2022

@rashil2000 @mjvankampen tested with the following Dockerfile, but removing the double quotes from the .shim file does not help

FROM mcr.microsoft.com/powershell:lts-windowsservercore-1809
SHELL ["pwsh","-C"]

RUN iwr -useb 'https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1' -outfile 'install.ps1'
RUN .\install.ps1 -RunAsAdmin
RUN scoop install minisign
RUN "echo \"path = C:\Users\ContainerAdministrator\scoop\apps\minisign\current\minisign.exe\" > C:\Users\ContainerAdministrator\scoop\shims\minisign.shim"
RUN type C:\Users\ContainerAdministrator\scoop\shims\minisign.shim
RUN minisign
CMD ["pwsh"]

Result:
image

@hboomsma
Copy link

hboomsma commented Mar 9, 2022

@rashil2000 @mjvankampen
Found a broken link of some sort:
image

From the version directory it seems to work:
image

@niheaven
Copy link
Member

niheaven commented Mar 9, 2022

So the current dir is broken or not linked?

@hboomsma
Copy link

hboomsma commented Mar 9, 2022

Looks like it to me, but I'm not familiar with windows links:
image

@pd-kcarrasco
Copy link

We're being affected by the same issue as well. all Junctions created with New-Item -ItemType Junction are broken.
I think we need to revert this commit. junctions created with mklink work:

After building a container, run it and you can see junctions crated with new-item are missing their target:

# empty target from junction created with New-Item
PS C:\Users\ContainerAdministrator\scoop\apps\python37\3.7.9> (gi .\scripts_new-item\).Target

# target is present in junction created with mklink
PS C:\Users\ContainerAdministrator\scoop\apps\python37\3.7.9> (gi .\scripts_mklink\).Target
C:\Users\ContainerAdministrator\scoop\persist\python37\Scripts

@rashil2000
Copy link
Member

What is your PowerShell version?

@charliedaveputh
Copy link

charliedaveputh commented Mar 11, 2022 via email

@kingster
Copy link
Contributor

@rashil2000 Getting the same error.

PS C:\BuildTools> $PSversionTable

Name                           Value
----                           -----
PSVersion                      5.1.17763.1971
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1971
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

@rashil2000
Copy link
Member

Has this issue been reported to PowerShell upstream? I can't find it.

@kingster
Copy link
Contributor

kingster commented Mar 22, 2022

Not sure if this is a PowerShell issue. This used to work with the same PowerShell version till scoop-2021-12-26, I would also agree with @pd-kcarrasco that probably 98ea7a5 broke this

When I run the same command in powershell the links are properly created


PS C:\> New-Item -Path Users-link1 -ItemType Junction -Value Users


    Directory: C:\


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----l        3/22/2022   7:34 PM                Users-link1


PS C:\> (gi .\Users-link1).Target

@rashil2000
Copy link
Member

It seems to affect only docker containers, that's why I asked if there's a report of it somewhere upstream

@kingster
Copy link
Contributor

docker/for-win#12240 Found this bug report, but seems like this was not fixed

@rashil2000
Copy link
Member

Is there a way to recognize docker context (with help of an environment variable or something)? We can write a wrapper function for it as a workaround

@kingster
Copy link
Contributor

kingster commented Mar 22, 2022

Should be possible https://stackoverflow.com/a/46810471

@rashil2000
Copy link
Member

Can you make a PR?
Ideally, we need a wrapper function New-DirectoryJunction in lib/install.ps1, which uses mklink if inside Docker, and falls back to New-Item -ItemType Junction otherwise.

@kingster
Copy link
Contributor

Have attempted the fix in #4837. With that fix I was able to install it successfully inside a Dockerfile

@christopher-dG
Copy link

Thanks for the fix! Does scoop need a new release for users to get the new code?

@rashil2000
Copy link
Member

Yes, we should probably create a small patch release for the recent bug fixes.
/cc @niheaven

@niheaven
Copy link
Member

Of cause, in a few days, maybe.

@skeptic-monkey
Copy link

skeptic-monkey commented Mar 23, 2022

If we have to wait for couple of days, what would be the instruction to install scoop from the develop branch ?
This is blocking the CI/CD of my company, as I can't rebuid my containers.

@rashil2000
Copy link
Member

scoop config SCOOP_BRANCH develop
scoop update

@rashil2000
Copy link
Member

@niheaven could you please draft a patch release? It's been 4 weeks 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
9 participants