Ubuntu Zsh (via Vagrant) does not find Zsh or its functions

I have a wagrant provisioning script that tries to install Zsh if it is not available, and then change the shell to use Zsh.

There are two questions that I think I have:

Firstly, I do not believe that the shell will change to Zsh, because when I start vagrant sshto access Ubuntu VM, and after starting the ps -p $$command indicates that Bash is the shell that is running (where I would expect Zsh).

The second problem is that if it changes to the Zsh shell (regardless of what ps -p $$reports it returns), then Zsh displays a lot of errors when I run the .zshrc file, which assumes that the specified functions are missing or simply not referencing correctly.


I will break it into steps by performing a Zsh installation manually, and not through setting up a Vagrant script ...

  • cat /etc/shells β†’ I do not see links to Zsh †
  • sudo apt-get update
  • sudo apt-get install zsh β‰ 
  • cat /etc/shellsβ†’ now have /bin/zshand/usr/bin/zsh
  • which zsh β†’ /usr/bin/zsh
  • zsh --version β†’ zsh 5.0.2 (x86_64-pc-linux-gnu)
  • chsh -s $(which zsh)
  • source .zshrc β†’ Lots of errors sent to stdout ~~
  • tree /usr/share/zsh/β†’ see below ** for output, but the notification is functionnot inside the directory 5.0.2?

I think it is more likely that Zsh does not change, because if I execute the command zsh, I get into a new shell environment, and if I run source .zshrc, I will not get errors. Also, if I run ps -p $$, now I will see that Zsh is reported as a running shell.

At the end of this question, you can find all my settings for a stroller script.

† The list of shells that I see is:

/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/tmux
/usr/bin/screen

β‰  output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  zsh-common
Suggested packages:
  zsh-doc
The following NEW packages will be installed:
  zsh zsh-common
0 upgraded, 2 newly installed, 0 to remove and 55 not upgraded.
Need to get 2,726 kB of archives.
After this operation, 11.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main zsh-common all 5.0.2-3ubuntu6 [2,119 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main zsh amd64 5.0.2-3ubuntu6 [607 kB]
Fetched 2,726 kB in 6s (420 kB/s)                                              
Selecting previously unselected package zsh-common.
(Reading database ... 61742 files and directories currently installed.)
Preparing to unpack .../zsh-common_5.0.2-3ubuntu6_all.deb ...
Unpacking zsh-common (5.0.2-3ubuntu6) ...
Selecting previously unselected package zsh.
Preparing to unpack .../zsh_5.0.2-3ubuntu6_amd64.deb ...
Unpacking zsh (5.0.2-3ubuntu6) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up zsh-common (5.0.2-3ubuntu6) ...
Setting up zsh (5.0.2-3ubuntu6) ...
update-alternatives: using /bin/zsh5 to provide /bin/zsh (zsh) in auto mode
update-alternatives: using /bin/zsh5 to provide /bin/rzsh (rzsh) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/rzsh.1.gz because associated file /usr/share/man/man1/zsh.1.gz (of link group rzsh) doesn't exist

~~ , Zsh https://github.com/Integralist/dotfiles/blob/linux/.zshrc

autoload: command not found
zmodload: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'style' from package 'diction' (universe)
 Command 'astyle' from package 'astyle' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
No command 'zstyle' found, did you mean:
 Command 'astyle' from package 'astyle' (universe)
 Command 'style' from package 'diction' (universe)
zstyle: command not found
bindkey: command not found
bindkey: command not found
bindkey: command not found
bindkey: command not found
bindkey: command not found
bindkey: command not found
bindkey: command not found
autoload: command not found
No command 'colors' found, did you mean:
 Command 'xcolors' from package 'xcolors' (universe)
colors: command not found
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_no_bold[${(L)COLOR}]%}: bad substitution
-bash: %{$fg_bold[${(L)COLOR}]%}: bad substitution
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
unsetopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
No command 'setopt' found, did you mean:
 Command 'getopt' from package 'util-linux' (main)
setopt: command not found
autoload: command not found

** tree /usr/share/zsh:

/usr/share/zsh/
β”œβ”€β”€ 5.0.2
β”‚   └── scripts
β”‚       └── newuser
β”œβ”€β”€ functions
β”‚   β”œβ”€β”€ Calendar
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ Calendar.zwc
β”‚   β”œβ”€β”€ Chpwd
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ Chpwd.zwc
β”‚   β”œβ”€β”€ Completion
β”‚   β”‚   β”œβ”€β”€ AIX
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ AIX.zwc
β”‚   β”‚   β”œβ”€β”€ Base
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Base.zwc
β”‚   β”‚   β”œβ”€β”€ bashcompinit
β”‚   β”‚   β”œβ”€β”€ BSD
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ BSD.zwc
β”‚   β”‚   β”œβ”€β”€ compaudit
β”‚   β”‚   β”œβ”€β”€ compdump
β”‚   β”‚   β”œβ”€β”€ compinit
β”‚   β”‚   β”œβ”€β”€ compinstall
β”‚   β”‚   β”œβ”€β”€ Cygwin
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Cygwin.zwc
β”‚   β”‚   β”œβ”€β”€ Darwin
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Darwin.zwc
β”‚   β”‚   β”œβ”€β”€ Debian
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Debian.zwc
β”‚   β”‚   β”œβ”€β”€ Linux
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Linux.zwc
β”‚   β”‚   β”œβ”€β”€ Mandriva
β”‚   β”‚   β”‚   β”œβ”€β”€ _rebootin
β”‚   β”‚   β”‚   └── _urpmi
β”‚   β”‚   β”œβ”€β”€ Mandriva.zwc
β”‚   β”‚   β”œβ”€β”€ openSUSE
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ openSUSE.zwc
β”‚   β”‚   β”œβ”€β”€ Redhat
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Redhat.zwc
β”‚   β”‚   β”œβ”€β”€ Solaris
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Solaris.zwc
β”‚   β”‚   β”œβ”€β”€ Unix
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ Unix.zwc
β”‚   β”‚   β”œβ”€β”€ X
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   β”œβ”€β”€ X.zwc
β”‚   β”‚   β”œβ”€β”€ Zsh
β”‚   β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”‚   └── Zsh.zwc
β”‚   β”œβ”€β”€ Completion.zwc
β”‚   β”œβ”€β”€ Exceptions
β”‚   β”‚   β”œβ”€β”€ catch
β”‚   β”‚   └── throw
β”‚   β”œβ”€β”€ Exceptions.zwc
β”‚   β”œβ”€β”€ MIME
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ MIME.zwc
β”‚   β”œβ”€β”€ Misc
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ Misc.zwc
β”‚   β”œβ”€β”€ Newuser
β”‚   β”‚   └── zsh-newuser-install
β”‚   β”œβ”€β”€ Newuser.zwc
β”‚   β”œβ”€β”€ Prompts
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ Prompts.zwc
β”‚   β”œβ”€β”€ TCP
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ TCP.zwc
β”‚   β”œβ”€β”€ VCS_Info
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ VCS_Info.zwc
β”‚   β”œβ”€β”€ Zftp
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ Zftp.zwc
β”‚   β”œβ”€β”€ Zle
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   └── Zle.zwc
└── help

script

# Install dependencies
add-apt-repository ppa:pi-rho/dev # for latest tmux
apt-get update
apt-get remove vim-tiny -y
apt-get install vim tmux git tree htop reptyr xclip -y

# Install Zsh shell if it not available
if ! cat /etc/shells | grep zsh; then
  echo "Zsh is not available, so we'll install it now"
  apt-get install zsh -y
fi

# For the Reptyr program to work we need to enable system access
# We do this by changing the ptrace scope from one to zero
sed -i 's/kernel.yama.ptrace_scope = 1/kernel.yama.ptrace_scope = 0/' /etc/sysctl.d/10-ptrace.conf

# Because this is a system control daemon, we need to restart the relevant service
sysctl -p /etc/sysctl.d/10-ptrace.conf

# Avoid the shell asking us to authorise the authenticity of github.com
# This happens when doing a git clone for the first time
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config

# Install dotfiles...
dotfiles_location=/home/vagrant/dotfiles
git clone https://github.com/Integralist/dotfiles.git $dotfiles_location
cd $dotfiles_location && git fetch && git checkout linux

# Ensure we don't move unnecessary files
shopt -s extglob
mv !(.|..|.git|README.md) ..

# Clean-up
cd ../ && rm -rf dotfiles

# Change to Zsh shell
chsh -s $(which zsh)

# Source the Zsh config file
source .zshrc
+4
1

chsh /login , .

, exec zsh, / .

+4

All Articles