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

Cannot set as login shell without manually adding to /etc/shells. #101

Open
3 tasks done
RokeJulianLockhart opened this issue Jan 15, 2024 · 3 comments
Open
3 tasks done

Comments

@RokeJulianLockhart
Copy link

RokeJulianLockhart commented Jan 15, 2024

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

As https://github.com/orgs/PowerShell/discussions/20962#discussioncomment-7937685 describes, the Snap package cannot be set as the login shell via chsh -s $Shell (where $Shell is the absolute path to the shell binary) without the user manually adding its path to /etc/shells. However, the native (.RPM) package automatically adds itself to that file as every other shell does. For instance, on my system, when the correct path for the snap package has been added, the content of /etc/shells is:

PS /home/RokeJulianLockhart> cat -vbET '/etc/shells'
     1  /bin/ash$
     2  /bin/bash$
     3  /bin/csh$
     4  /bin/dash$
     5  /bin/false$
     6  /bin/ksh$
     7  /bin/ksh93$
     8  /bin/mksh$
     9  /bin/pdksh$
    10  /bin/sh$
    11  /bin/tcsh$
    12  /bin/true$
    13  /bin/zsh$
    14  /usr/bin/csh$
    15  /usr/bin/dash$
    16  /usr/bin/ksh$
    17  /usr/bin/ksh93$
    18  /usr/bin/mksh$
    19  /usr/bin/passwd$
    20  /usr/bin/pdksh$
    21  /usr/bin/bash$
    22  /usr/bin/tcsh$
    23  /usr/bin/zsh$
    24  /usr/bin/fish$
    25  /usr/bin/scsh$
    26  /usr/bin/rash$
    27  /snap/powershell/current/opt/powershell/pwsh$
PS /home/RokeJulianLockhart> # This demonstrates correct manual addition of the path to the snap package rather than what the RPM package does.

Consequently, the installation process needs to add the path, and the uninstallation process remove it. The path should obviously be the vanity path as aforedepicted, not the mount-specific path, as #101 (comment) explains.

Expected behaviour

The aforestated command should set it as the login shell.

Actual behaviour

It does not.

Error details

PS /home/RokeJulianLockhart> Get-Command pwsh                      

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     pwsh                                               0.0.0.0    /snap/powershell/261/opt/powershell/pwsh

PS /home/RokeJulianLockhart> chsh -s /snap/powershell/261/opt/powershell/pwsh
Password: 
chsh: /snap/powershell/261/opt/powershell/pwsh is an invalid shell
PS /home/RokeJulianLockhart> Get-Error       
PS /home/RokeJulianLockhart> chsh -s /snap/powershell/261/opt/powershell/pwsh
Password: 
chsh: /snap/powershell/261/opt/powershell/pwsh is an invalid shell
PS /home/RokeJulianLockhart> $?                   
False
PS /home/RokeJulianLockhart>

Environment data

PS /home/RokeJulianLockhart> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             openSUSE Tumbleweed
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /home/RokeJulianLockhart>

Version

{
	"version": "7.4.0",
	"channel": "latest/stable",
	"snap-id": "JSNnoJl3EqkMuWoy5Dgq8PMqZ0uNcpie"
}

Visuals

No response

@RokeJulianLockhart

This comment was marked as resolved.

@rhubarb-geek-nz
Copy link

The system /snap directory

This suggests you should use the current link so when PowerShell snap is updated you automatically get the new version.

@RokeJulianLockhart RokeJulianLockhart changed the title Cannot set as login shell. Cannot set as login shell without manually adding to /etc/shells. Jan 16, 2024
@rhubarb-geek-nz
Copy link

I have been having a look at snaps and now think the entry you need to add to /etc/shells should be /snap/bin/pwsh

That solves all the issues about versions and links.

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

2 participants