Open najeebanwer opened 4 years ago
I can reproduce this too.
I installed it via Snap in Pop!_OS, and attempting to open the app through the GNOME app menu, shows the same error dialog.
Not only it's pointing to powershell-preview
, but also there are some underlying problems with Snap itself:
I took a look at the installed files, and here is where that Exec
word is located:
/snap/powershell/current/meta/gui $ cat powershell-preview.desktop
[Desktop Entry]
Name=PowerShell Preview
Exec=powershell-preview
Type=Application
Terminal=true
Categories=ConsoleOnly;System
Icon=${SNAP}/meta/gui/icon.png
I couldn't find the powershell-preview
executable in the same folder, but I did find this PowerShell wrapper in a different folder, which fails if I try to execute:
/snap/powershell/current/bin $ ./powershell-wrapper
./powershell-wrapper: 9: exec: /opt/powershell/pwsh: not found
The file is a bash script, and it seems to expect an environment variable $SNAP
to exist:
/snap/powershell/current $ cat bin/powershell-wrapper
#!/bin/sh
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Create $XDG_RUNTIME_DIR if it doesn't exist
# || true causes bash to ignore errors
[ -n "$XDG_RUNTIME_DIR" ] && mkdir -p $XDG_RUNTIME_DIR -m 700 || true
exec "$SNAP/opt/powershell/pwsh" "$@"
The $SNAP
variable is supposed to have the value /snap/
, but I couldn't find it among my environment variables! So I think this is a problem with how Snap was installed in my machine.
/snap/powershell/current/meta/gui $ printenv | grep SNAP
/snap/powershell/current/meta/gui $
Notice no variable was found. I was expecting to also see SNAP_ARCH
, SNAP_COMMON
, SNAP_DATA
, etc.
The $SNAP
env variable is expected to exist, and is mentioned in the documentation: https://snapcraft.io/docs/environment-variables
If the variable existed, then the pwsh
file is located where the script would expect it. It works well if I execute it:
carlos@tabletbox:/snap/powershell/current$ opt/powershell/pwsh
PowerShell 7.0.3
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
PS /snap/powershell/137>
The PowerShell Snap package should not point to "powershell-preview", because there is nothing inside the package with that name. It should either point to powershell
or powershell-wrapper
or pwsh
.
The powershell-wrapper
file has the wrong executable, even considering $SNAP
is not available in my machine. The executable path currently is:
exec "$SNAP/opt/powershell/pwsh" "$@"
But it should be:
exec "$SNAP/powershell/current/opt/powershell" "$@"
I tried to edit the files but snap created the /snap/
in a read-only file system, I can't even edit even with sudo
, which is frustrating.
$SNAP
not being added correctly at the system level. I tried installing skypeforlinux
and code
as well, and they were also not working and I think it's the same root cause (I didn't verify). I opened bug in the Launchpad page for Snapd: https://bugs.launchpad.net/snapd/+bug/1890925$PSVersionTable
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Linux 5.4.0-7634-generic PowerShell/PowerShell#38~1596560323~20.04~7…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SnapcraftSnaps are containerised software packages that are simple to create and install. They auto-update and are safe to run. And because they bundle their dependencies, they work on all major Linux systems without modification.
LaunchpadThis is the list of environment variables I was expecting to see: https://snapcraft.io/docs/environment-variables But after installing snapd, none of them is available. I made sure to open a new terminal window, and I even rebooted, but they did not show up: ``` /snap/powershell/137/meta/gui$ printenv | grep SNAP /snap/powershell/137/meta/gui$ ``` I found this issue in Pop!_OS 20.04, after attempting to install PowerShell, whose package expects the package to exist in $SNAP\opt\powershe...
@carlossanlop, thanks for confirming that it does not work properly for you either.
I should point out that I do not have the environment variable SNAP defined either; the only environment variables that reference "snap" are shown below.
$ printenv | grep -i SNAP
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Despite this, the other snaps I have installed (e.g., code, skype, vlc) work fine. In fact, I have installed the powershell-preview snap and that works as expected. This problem is unique to the powershell snap.
/cc @TravisEz13 for information.
Hello
You should not execute anything in /snap/powershell/*
directly. Please use the launcher in /snap/bin
instead. This can be a problem immediately after installing the snapd package. For various reasons beyond our control, you may need to restart your machine or at least log out (depending on the OS version) for the correct environment to be picked up.
Note that this is unrelated to the issue you saw directly, since running /snap/powershell/current/$anything
side-steps the snap launcher which is responsible for constructing the proper runtime environment.
Steps to reproduce
On Ubuntu 20.04, install Powershell snap
click on "Show Applications" in the dock. This shows a list of all installed applications.
Expected behavior
Actual behavior
Removing the Powershell snap does remove the incorrect icon from the list of applications, but clicking on "Show Applications" causes the Gnome Shell to crash.
Environment data
Ubuntu Desktop 20.04, PowerShell 7.0.3