Spaceship-prompt: Symlinking to site-functions fails

Created on 14 Feb 2018  Â·  5Comments  Â·  Source: denysdovhan/spaceship-prompt

Issue

I tried updating spaceship prompt but I encountered this error. The prompt seems to be working fine but I'm not sure if it's going to cause any issues later on or not.

➜ npm update -g

> [email protected] postuninstall /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/spaceship-prompt
> ./scripts/uninstall.sh

SPACESHIP: Removing /home/karan/.zfunctions/prompt_spaceship_setup...
SPACESHIP: Removing Spaceship from ~/.zshrc
sed: can't read /^# Set Spaceship ZSH as a prompt$/d: No such file or directory
sed: can't read /^autoload -U promptinit; promptinit$/d: No such file or directory
sed: can't read /^prompt spaceship$/d: No such file or directory
sed: can't read /^SPACESHIP_.*$/d: No such file or directory
SPACESHIP: Done! Spaceship installation have to be removed!
SPACESHIP: Please, reload your terminal.
/home/karan/.nvm/versions/node/v8.9.4/bin/t -> /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/litetimer/bin/t
/home/karan/.nvm/versions/node/v8.9.4/bin/termchat -> /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/term-chat/bin/termchat

> [email protected] postinstall /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/spaceship-prompt
> ./scripts/install.sh

SPACESHIP: Spaceship is present in current directory
SPACESHIP: Failed to symlink /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/spaceship-prompt/spaceship.zsh to /usr/local/share/zsh/site-functions.
SPACESHIP: Adding /home/karan/.zfunctions to fpath...
SPACESHIP: Trying to symlink /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/spaceship-prompt/spaceship.zsh to /home/karan/.zfunctions
SPACESHIP: Linking /home/karan/.nvm/versions/node/v8.9.4/lib/node_modules/spaceship-prompt/spaceship.zsh to /home/karan/.zfunctions/prompt_spaceship_setup...
SPACESHIP: Spaceship is already present in .zshrc!

Environment

Spaceship version: 3.2.0
Zsh version: zsh 5.2 (x86_64-ubuntu-linux-gnu)
Zsh framework: oh-my-zsh
Zsh plugin manager: None
Terminal emulator: Tilix
Operating system: Linux - Ubuntu 17.10

Relevant .zshrc

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
  export ZSH=/home/karan/.oh-my-zsh

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="hyperzsh"

# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

### NVM ###
export NVM_DIR="$HOME/.nvm"
source ~/.nvm/nvm.sh
fpath=($fpath "/home/karan/.zfunctions")

# Set Spaceship ZSH as a prompt
autoload -U promptinit; promptinit
prompt spaceship
# GoLang
export GOROOT=$HOME/.go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

. /usr/local/bin/virtualenvwrapper.sh
fpath=($fpath "/home/karan/.zfunctions")
question

Most helpful comment

It may fix your problem:

sudo chown -R $USER /usr/local

All 5 comments

Linking failure happens because you don't have write access to /usr/local/share/zsh/site-functions in Linux as normal user. That's why it's being installed to user directory $HOME/.zfunctions. As long as you've theme somewhere in $fpath, Everything is good.

https://github.com/denysdovhan/spaceship-prompt/blob/b29a3c084dd34be50a59cb4fb2687fdf39dd46cf/scripts/install.sh#L85-L95

Closing this now. Please reopen if you have any additional question.

Windows subsystem for linux (WSL), up-to-date, terminal hyper.is. Even with sudo I still get this similar error:

```
~% sudo npm install -g spaceship-prompt

[email protected] postinstall /usr/local/lib/node_modules/spaceship-prompt
./scripts/install.sh

SPACESHIP: Spaceship is present in current directory
SPACESHIP: Failed to symlink /usr/local/lib/node_modules/spaceship-prompt/spaceship.zsh to /usr/local/share/zsh/site-functions.
SPACESHIP: Adding /home/sugar/.zfunctions to fpath...
./scripts/install.sh:92: permission denied: /home/sugar/.zshrc
SPACESHIP: Trying to symlink /usr/local/lib/node_modules/spaceship-prompt/spaceship.zsh to /home/sugar/.zfunctions
SPACESHIP: Linking /usr/local/lib/node_modules/spaceship-prompt/spaceship.zsh to /home/sugar/.zfunctions/prompt_spaceship_setup...
mkdir: cannot create directory ‘/home/sugar/.zfunctions’: Permission denied
ln: failed to create symbolic link '/home/sugar/.zfunctions/prompt_spaceship_setup': No such file or directory
SPACESHIP: These lines will be added to your ~/.zshrc file:
SPACESHIP:

Set Spaceship ZSH as a prompt

autoload -U promptinit; promptinit
prompt spaceship
append_zshrc:3: permission denied: /home/sugar/.zshrc
SPACESHIP: Cannot automatically insert prompt init commands.
SPACESHIP: Please insert these line into your ~/.zshrc:
SPACESHIP:

Set Spaceship ZSH as a prompt

autoload -U promptinit; promptinit
prompt spaceship
npm ERR! Linux 4.4.0-17134-Microsoft
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "spaceship-prompt"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: ./scripts/install.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script './scripts/install.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the spaceship-prompt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./scripts/install.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs spaceship-prompt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls spaceship-prompt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/sugar/npm-debug.log```

It may fix your problem:

sudo chown -R $USER /usr/local

Obrigadão marcelo

My solution:
I changed my user and group owner for the share folder to allow my user/group access only this directory and subdirectories. This solution was for macOS Catalina 10.15, but i believe that it colud be applied to many linux distributions.

Steps:

1 - find your user and group

If you don't know what is your username you can run this command in your terminal.

whoami

It will return something like:

$ yourusername

Your group user can be found just listing your home directory.

ls -lsta ~/

or

`ls -lsta /Users/yourusername

and it will return someting like this:

GitHub Logo

Then, you can change the permissions correctly.

chown -R youtusername:yourusergroup /usr/local/share

After this, everthing works perfectly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

martincartledge picture martincartledge  Â·  4Comments

xhaythemx picture xhaythemx  Â·  3Comments

janjur picture janjur  Â·  3Comments

nfischer picture nfischer  Â·  3Comments

tbekaert picture tbekaert  Â·  3Comments