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

PowerShell on Photon does not include PowerShellGet or PackageManagement #815

Closed
bluearcher-bc opened this issue Oct 9, 2018 · 21 comments
Closed

Comments

@bluearcher-bc
Copy link

bluearcher-bc commented Oct 9, 2018

Cannot use PowerShell Gallery to install any modules (including PowerCLI 10.x) in Photon OS 2.0, because the PowerShell 6.0.1 installed from the VMware repo (tdnf install -y powershell) does not seem to include the required PackageManagement or PowerShellGet modules. (get-module -ListAvailable -Name <PackageManagement/PowerShellGet>)

This seems like a pretty steep barrier to just to run PowerCLI in Photon, and the only references seem to suggest using the Docker Container for PowerCLI which just adds an unnecessary layer.

@bluearcher-bc bluearcher-bc changed the title PowerShell on Photon does not include PowerShellGet or PackageManagement? PowerShell on Photon does not include PowerShellGet or PackageManagement Oct 24, 2018
@tsugliani
Copy link
Contributor

Any news on this ?

@CollinChaffin
Copy link

Hello? Powershell on Photon is 100% BROKEN......does anyone at Vmware care?

@bluearcher-bc
Copy link
Author

bluearcher-bc commented May 26, 2019

This was for Photon OS 2.0, but it doesn't appear to have improved as there are a number of newer issues filed, two of which are #844 and #891. LucD cares, but I am not sure who else does 😁

@dcasota
Copy link
Contributor

dcasota commented Sep 7, 2019

The powershell gallery repository connectivity issue is with PowerShellGet relying on nuget.exe. Nuget is a winx86-only executable. Install and use nuget packages using Mono with some limitations may path a way.

The installation of Mono on Photon isn't straightforward. This is what I've found so far:
wget https://download.mono-project.com/sources/mono/mono-6.0.0.313.tar.xz
mkdir ~/mono
tar -xvf mono-6.0.0.313.tar.xz -C ~/mono
yum install mono-complete
tdnf install linux-api-headers cmake gcc glibc-devel binutils
yum install bison gettext glib2 freetype fontconfig libpng libpng-devel
yum install java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget
cd ~/mono
./configure --prefix=/usr/local
make
make install
curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
mono /usr/local/bin/nuget.exe sources Add -Name PSGallery -Source "https://www.powershellgallery.com/api/v2"

wget https://github.com/PowerShell/PowerShell/releases/download/v7.0.0-preview.3/powershell-7.0.0-preview.3-linux-x64.tar.gz
mkdir ~/powershell
tar -xvf ./powershell-7.0.0-preview.3-linux-x64.tar.gz -C ~/powershell
powershell/pwsh

get-psrepository shows now the PSGallery registered.

NugetOnAzure

@CollinChaffin
Copy link

CollinChaffin commented Sep 12, 2019

That's absolutely not true @dcasota I have pwsh successfully installed and updated to 6.22 INCLUDING full packagemanagement and psget working per the proper PhotonOS install/build - there is simply nobody at VMware apparently updating this OS at any reasonable interval for many of these critical packages.

Shown below. All module install/updating/searching etc. works without issue:

root@vdocker [ /root ]# pwsh
PowerShell 6.2.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /root> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   6.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Ite…
Manifest   6.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable,…
Script     2.0.0      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadL…

PS /root> Find-Module pstwitter

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.0.0.2              PSTwitter                           PSGallery            PSTwitter (Twitter…

PS /root>

EDIT: I will hopefully get around to posting the proper pwsh install/upgrade script (and a few other things including the proper way to upgrade tmux on PhotonOS using a proper local repo). I'll post here when I do.

EDIT 2: Other then loaded modules, here is a list of modules pre-installed by pwsh 6.x when properly installed:

WinRAR_4TfEgZtUQv

@CollinChaffin
Copy link

UPDATE: I have gone ahead and released my PWSH install/update script here that replicates the PROPER default PhotonOS repo outdated Powershell install:

https://github.com/CollinChaffin/Install-PowerShell-on-PhotonOS

If you read the README it will give you some background detailing exactly why it is NOT the same as the several INCORRECT few-line download+unzip that folks are using that leaves them with a totally botched PWSH instance, and constantly wondering why they are having issues.

@dcasota
Copy link
Contributor

dcasota commented Sep 12, 2019

On a Msft Windows OS the stack WMF + Packagemanagement + Powershellget + Powershell took quite some learning curve. Update-module threw some weired info about assemblies, sometimes powershellget was not installed, nuget provider issues, running Powershell 2.0 and above was always something less than absolutely. Import-module alternative installation helpers choco and nuget were used at that time a lot.
Administering ESXi/View using VMware PowerCLI 6.x and above always became stricter to the definition minimum (even sometimes required) version on each stack element from WMF_on_OS above.

I think PowerCLI on Photon OS is an interesting use case. To give a try to another way as in the past I'm tinkering around with the mono project. So I came along this thread. A full blown mono project installation simply to use Powershell release is overkill. Didn't take too much time yet on that. Just was happy it worked. Personally I haven't tried the alternative to get baken releases-namespace-robust docker containers. The quick'n'dirty thread entry may has left more questions. I have these as well! Here are some findings https://github.com/dcasota/photonosonazure. I use Photon OS on Azure. Collin, I'll post an update on running your script on Photon OS 3.0 GA on Azure (September 2019). No other Photon OS release tested so far.
--Daniel

@dcasota
Copy link
Contributor

dcasota commented Sep 12, 2019

The Install-PowerShell-on-PhotonOS script does not solve this "WARNING: Unable to find module repositories.".

The output is:
PS /root/CollinChaffin/Install-PowerShell-on-PhotonOS-master> Register-PSRepository -Default -Verbose
VERBOSE: Performing the operation "Register Module Repository." on target "Module Repository 'PSGallery' () in provider 'PowerShellGet'.".
PS /root/CollinChaffin/Install-PowerShell-on-PhotonOS-master> get-psrepository
WARNING: Unable to find module repositories

The other way round - using register-psrepository - throws the error already mentioned in other threads:
PS /root/CollinChaffin/Install-PowerShell-on-PhotonOS-master> Register-PSRepository -Name "PSGallery" -SourceLocation "https://www.powershellgallery.com/api/v2" -Verbose
Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
At line:1 char:1

  • Register-PSRepository -Name "PSGallery" -SourceLocation "https://www. ...
  • CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
  • FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository

The powershell symbolink link worked. The VSCode pic, yes, fine. As said, a full blown install costs 4gb used and not the <1gb used.

@dcasota
Copy link
Contributor

dcasota commented Sep 13, 2019

PowerShell Gallery in Photon OS 2.0 PHOTON_BUILD_NUMBER=0922243 with the workaround Mono full installation works as well as the tests in Photon OS 3.0 GA. No need using Docker Container for PowerCLI. #930 it would be nice to use a tdnf'ied small footprint of mono+nuget.exe.

@lucdekens
Copy link

yum install mono-complete

@dcasota not sure how you got that working?
I get 'No matching packages'

@dcasota
Copy link
Contributor

dcasota commented Sep 15, 2019

It does not. The line is strikethrough now.

@dcasota
Copy link
Contributor

dcasota commented Oct 24, 2019

Just spottet there is a tdnf package powershell.x86_64 6.1.1-1.ph3, and docker pull vmware/powerclicore:ubuntu16.04 seems to include the magic sausage as built-in pwshgallery connectivity is back :) awesome!

@lucdekens
Copy link

Really?
One year further and the old answer 'use a container' is still the only solution?

Then please explain why I should be using Photon in the first place?
Could have gone to Ubuntu from the start.

This whole story around PowerShell on Photon is becoming ridiculous.
And no, I don't consider using mono a solution to the issue.

@dcasota
Copy link
Contributor

dcasota commented Oct 27, 2019

Simply get the powershellgallery functionality back with the latest PowerCLI release, this works for me

tdnf -y update

# install the requirements
tdnf install -y \
        tar \
        curl

# Download the powershell '.tar.gz' archive
curl -L https://github.com/PowerShell/PowerShell/releases/download/v6.0.5/powershell-6.0.5-linux-x64.tar.gz -o /tmp/powershell.tar.gz

# Create the target folder where powershell will be placed
sudo mkdir -p /opt/microsoft/powershell/6.0.5

# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/6.0.5

# Set execute permissions
sudo chmod +x /opt/microsoft/powershell/6.0.5/pwsh

# Create the symbolic link that points to pwsh
sudo ln -s /opt/microsoft/powershell/6.0.5/pwsh /usr/bin/pwsh6.0.5

# Install PowerCLI
pwsh6.0.5 -c "install-module VMware.PowerCLI"

There are a few other solutions to fixed get the bundle PhotonOS&PowerCLI baken - yes Mono is more study work.
I may have had the same requirement as ArcherX, and that tdnf install powershell does not solve psrepository prerequisites. You may explicitly install pwsh core release 6.0.5 and it works, you install 6.1.1 and it's broken. With each pwsh release afterwards this is the case including the latest release pwsh7.0.0preview5 (October 2019). As example on this latest release you get the warning:

PS /root> get-psrepository
WARNING: Unable to find module repositories.
PS /root> register-psrepository -default

Suggestion [4,General]: The most similar commands are: gzexe, getent.

You could say the bundle PowerCLI&pwsh 6.0.5 that's good enough. It's not. According to the Powershell releases end-of-life dates 6.0.x is no longer supported since 02/13/2019, 6.1 is no longer supported since 09/28/2019.
The specs contributor here referenced to this. Having read the make recipe, how include nuget.exe in the linux make workflow? I've placed the question here PowerShell/PowerShell#10860. As an independant contributor it's not easy, simply put, it is never to assume your question gets a (community) answer.
Powershell support costs to support the Powershell Support Lifecycle, as all other developers they simply do not have time.

my2cents

@lucdekens
Copy link

Not too sure what you are trying to say here @dcasota ?
In fact, I think you already gave the major objection to the solution you describe, PS 6.0.5 is not supported.

Since I don't use PowerShell only for PowerCLI, an unsupported solution is not acceptable for me.

While it would have been nice to incorporate Photon as a platform in my CI/CD pipeline, the current situation drives me (and probably others) towards Ubuntu and the likes.

I get more and more the impression that Photon, and the packages made available for it, are a rather unimportant side-project.
Just have a look at the open issues, and their lack of feedback, and the pending PRs.

If the manpower is not available to create and update packages in a timely fashion, perhaps the process should be open and better documented.
That way the community might fill part of that gap.

@dcasota
Copy link
Contributor

dcasota commented Oct 28, 2019

With respect to the original issue Powershell on Photon, an updated tdnf install powershell or a nifty tdnf install powerclicore would be nice! +1

Implicit PSGallery connectivity never did / does not work on every Powershell-on-OS combination. Hence, using the latest PowerCLICore dockerfile, as @BlueArcherX mentioned it, it "just adds an unnecessary layer." as the docker container size 'overhead' origins from the use of another distro. It is more a question on how to get it baken.

And not to be forgotten, with a trusted PSGallery less tested PSGallery modules become installable too. Not every PSGallery published module works on a linux distro. The powershell source as example has built-in cmdlets shared, for Windows-only, and for Linux-only.
A test that a module had been installable simply using the pwsh install-module cmdlet does not guarantee which cmdlets are functioning on which windows as well as on which linux distro release. Having browsed through Powershell sources like here, I've noticed the Bootstrap function there uses Nuget.exe which is x86cmdline-only. A function like install-packagemanagement uses Microsoft.Powershell.Utility invoke-webrequest (here). It has (had?) a different behavior on a Windows system as on a Linux distro. As said, every Powershell-on-OS combination got its own learning curve.

A supported Powershell-on-OS combination for Photon OS - and without the use of a docker container - could be Pwsh 6.2.3 + Packagemanagement 1.1.7.2 + Powershellget 1.6.7. After the installation of the Pwsh 6.2.3 release, see here, the helper script provides 'substitution' functionality of cmdlets like find-module or import-module. I needed to add $env:DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 and -SslProtocol Tls -SkipCertificateCheck to get a minimal functionality baken. It is a study script, hence, it must be reviewed carefully as with respect to release, scope, proxy functionality, etc. It has had only a few if-this-then-that test environment prerequisites. Pwsh6.2.3 with some workarounds. I've put a complete setup script here.

@BlueArcherX I've tried to assemble the findings so far. Concerning repos, Repository Management may path another future, see here .
Registering PSGallery more or less independently to the Pwsh release on Photon OS could provide a flexible methodology. With dotnet core 3.x, the dotnet script core will process directly .cs + .csx source files on Windows/Linux/Mac. In comparison, the study work in the past ended up with a full installation of Mono v5.18 or later and with Nuget.exe 2.8.6 or later, simply to register PSGallery on Photon OS 2.0 or 3.0.

@bluearcher-bc
Copy link
Author

bluearcher-bc commented Oct 28, 2019

I get more and more the impression that Photon, and the packages made available for it, are a rather unimportant side-project.

I think this is the answer. They do what they need in order to make it a reasonable platform for VMware products, but not so much as a usable platform for the community. A shame since there is a lot of potential here.

Also, I just noticed there hasn't even been a release since March.

@ppadmavilasom
Copy link
Contributor

@lucdekens please see https://vmware.github.io/photon/assets/files/html/3.0/photon_installation/build-package-kernel-using-script.html on how to build a package (in this case SPECS/powershell.spec)

@lucdekens
Copy link

Thanks, although I'm not a developer, I'll give it a shot ;-)

ghost pushed a commit that referenced this issue Nov 18, 2019
- fix issues:
- #891
- #889
- #850
- #815
- #752

Change-Id: I28c8440f67be3816473e34b22fa6067b49deba60
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/8582
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Tapas Kundu <tkundu@vmware.com>
Reviewed-by: Shreyas Ranjan Behera <shreyasb@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
@ppadmavilasom
Copy link
Contributor

6.2.3 update fixes this. includes PSReadLine, PowerShellGet and PackageManagement

@bluearcher-bc
Copy link
Author

THANK YOU @ppadmavilasom

ghost pushed a commit that referenced this issue Dec 6, 2019
- fix issues:
- #891
- #889
- #850
- #815
- #752

Change-Id: I28c8440f67be3816473e34b22fa6067b49deba60
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/8607
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants