Getting a "Failed to execute process...Reason: exec: Permission denied" on my fish startup script re: theme

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
fulanitodetal
Level 1
Level 1
Posts: 19
Joined: Fri Mar 30, 2012 10:05 pm

Getting a "Failed to execute process...Reason: exec: Permission denied" on my fish startup script re: theme

Post by fulanitodetal »

When I open up Fish using the stock Linux Mint terminal with powerline-shell installed via python, I get the following output:

Code: Select all

Failed to execute process '/home/lloyd/.config/powerline-shell/powerline-shell.py'. Reason: exec: Permission denied
How did I get here/what have I tried?

The aim was to have the flame theme located here: https://github.com/ryanoasis/powerline-extra-symbols
Image

Once I installed Fish and got it working, the next step was to install powerline-shell following the instructions provided here: https://github.com/b-ryan/powerline-shell

Code: Select all

git clone https://github.com/b-ryan/powerline-shell
cd powerline-shell
python setup.py install
Then created the powerline-shell.py file using instructions further below on the same site.
Powerline-shell is customizable through the use of a config file. This file is expected to be located at

Code: Select all

~/.config/powerline-shell/config.json
. You can generate the default config at this location using:

Code: Select all

mkdir -p ~/.config/powerline-shell && \
powerline-shell --generate-config > ~/.config/powerline-shell/config.json
I then copied the same site's default powerline-shell.py: https://github.com/akdetrick/powerline- ... y.template

Code: Select all

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import os
import sys

def warn(msg):
    print '[powerline-bash] ', msg

class Powerline:
    symbols = {
        'compatible': {
            'separator': u'\u25B6',
            'separator_thin': u'\u276F'
        },
        'patched': {
            'separator': u'\u2B80',
            'separator_thin': u'\u2B81'
        },
        'flat': {
            'separator': '',
            'separator_thin': '>'
        },
    }

    color_templates = {
        'bash': '\\[\\e%s\\]',
        'zsh': '%%{%s%%}',
        'bare': '%s',
    }

    def __init__(self, args, cwd):
        self.args = args
        self.cwd = cwd
        mode, shell = 'flat', args.shell
        self.color_template = self.color_templates[shell]
        self.reset = self.color_template % '[0m'
        self.separator = Powerline.symbols[mode]['separator']
        self.separator_thin = Powerline.symbols[mode]['separator_thin']
        self.segments = []

    def color(self, prefix, code):
        return self.color_template % ('[%s;5;%sm' % (prefix, code))

    def fgcolor(self, code):
        return self.color('38', code)

    def bgcolor(self, code):
        return self.color('48', code)

    def append(self, content, fg, bg, separator=None, separator_fg=None):
        self.segments.append((content, fg, bg, separator or self.separator,
            separator_fg or bg))

    def draw(self):
        return (''.join(self.draw_segment(i) for i in range(len(self.segments)))
                + self.reset).encode('utf-8')

    def draw_segment(self, idx):
        segment = self.segments[idx]
        next_segment = self.segments[idx + 1] if idx < len(self.segments)-1 else None

        return ''.join((
            self.fgcolor(segment[1]),
            self.bgcolor(segment[2]),
            segment[0],
            self.bgcolor(next_segment[2]) if next_segment else self.reset,
            self.fgcolor(segment[4]),
            segment[3]))

def get_valid_cwd():
    """ We check if the current working directory is valid or not. Typically
        happens when you checkout a different branch on git that doesn't have
        this directory.
        We return the original cwd because the shell still considers that to be
        the working directory, so returning our guess will confuse people
    """
    try:
        cwd = os.getcwd()
    except:
        cwd = os.getenv('PWD')  # This is where the OS thinks we are
        parts = cwd.split(os.sep)
        up = cwd
        while parts and not os.path.exists(up):
            parts.pop()
            up = os.sep.join(parts)
        try:
            os.chdir(up)
        except:
            warn("Your current directory is invalid.")
            sys.exit(1)
        warn("Your current directory is invalid. Lowest valid directory: " + up)
    return cwd


if __name__ == "__main__":
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('--cwd-only', action='store_true',
            help='Only show the current directory')
    arg_parser.add_argument('--cwd-max-depth', action='store', type=int,
            default=4, help='Maximum number of directories to show in path')
    arg_parser.add_argument('--mode', action='store', default='patched',
            help='The characters used to make separators between segments',
            choices=['patched', 'compatible', 'flat'])
    arg_parser.add_argument('--shell', action='store', default='bash',
            help='Set this to your shell type', choices=['bash', 'zsh', 'bare'])
    arg_parser.add_argument('prev_error', nargs='?', type=int, default=0,
            help='Error code returned by the last command')
    args = arg_parser.parse_args()

    powerline = Powerline(args, get_valid_cwd())
Per the instructions on the flame theme site, I added the following to powerline-shell.py: https://github.com/ryanoasis/powerline- ... /flames.py

Code: Select all

class Powerline:
    symbols = {
        # flames (flamey)
        'patched': {
            'lock': u'\uE0A2',
            'network': u'\uE0A2',
            'separator': u'\uE0C0',
            'separator_thin': u'\uE0C1'
        }
    }
My full powerline-shell.py is posted below under the relevant scripts section.

Going back to the original powerline-shell installation instructions, I added the following to config.fish: https://github.com/b-ryan/powerline-shell#fish

Code: Select all

function fish_prompt
    powerline-shell --shell bare $status
end
The full config.fish is below in the relevant scripts section.

Following instructions on the flame theme site, I created the following flames.py theme file: https://github.com/ryanoasis/powerline- ... ames.py#L9

Code: Select all

class Color(DefaultColor):
    USERNAME_FG = 250
    #USERNAME_BG = 240
    USERNAME_BG = 226
    #USERNAME_ROOT_BG = 124
    USERNAME_ROOT_BG = 160

    HOSTNAME_FG = 250
    HOSTNAME_BG = 238

    HOME_SPECIAL_DISPLAY = True
    #HOME_BG = 31  # blueish
    HOME_BG = 208  # blueish
    HOME_FG = 15  # white
    #PATH_BG = 237  # dark grey
    PATH_BG = 166 # dark grey
    #PATH_FG = 250  # light grey
    PATH_FG = 15  # light grey
    #CWD_FG = 254  # nearly-white grey
    CWD_FG = 15 # nearly-white grey
    #SEPARATOR_FG = 244
    SEPARATOR_FG = 15

    #READONLY_BG = 124
    READONLY_BG = 160
    READONLY_FG = 254

    SSH_BG = 166 # medium orange
    SSH_FG = 254

    REPO_CLEAN_BG = 148  # a light green color
    REPO_CLEAN_FG = 0  # black
    REPO_DIRTY_BG = 161  # pink/red
    REPO_DIRTY_FG = 15  # white

    JOBS_FG = 39
    JOBS_BG = 238

    #CMD_PASSED_BG = 236
    CMD_PASSED_BG = 160
    CMD_PASSED_FG = 15
    #CMD_FAILED_BG = 161
    CMD_FAILED_BG = 160
    CMD_FAILED_FG = 15

    SVN_CHANGES_BG = 148
    SVN_CHANGES_FG = 22  # dark green

    VIRTUAL_ENV_BG = 35  # a mid-tone green
    VIRTUAL_ENV_FG = 00
Lastly, I added the theme line to config.json per these instructions on the powerline-shell installation script: https://github.com/b-ryan/powerline-shell#themes
Themes
The powerline_shell/themes directory stores themes for your prompt, which are basically color values used by segments. The

Code: Select all

default.py
defines a default theme which can be used standalone, and every other theme falls back to it if they miss colors for any segments.

If you want to create a custom theme, start by copying one of the existing themes, like the basic. and update your

Code: Select all

~/.config/powerline-shell/config.json
, setting the "theme" to the path of the file. For example your configuration might have:

Code: Select all

  "theme": "~/mythemes/my-great-theme.py"
But for my specific machine, I added:

Code: Select all

,"theme": "~/.config/powerline-shell/themes/flames.py"
I then opened the terminal, and received the error:

Code: Select all

Failed to execute process '/home/lloyd/.config/powerline-shell/powerline-shell.py'. Reason: exec: Permission denied
Thinking this might be a permissions issue with powerline-shell.py or python, I ran the following commands that did not change the error output:

Code: Select all

sudo chmod +x ~/.config/powerline-shell/powerline-shell.py

Code: Select all

sudo chmod +x /bin/python3.8
Any ideas on what's going on or how I can get the theme working? As you can probably tell from my post, I know next to nothing about writing scripts, so pointing me to a helpful and relevant tutorial would be appreciated!

Relevant scripts

config.fish

Code: Select all

if status is-interactive
    # Commands to run in interactive sessions can go here

end

#mutes default fish greeting
set fish_greeting

function fish_prompt
    ~/.config/powerline-shell/powerline-shell.py --shell bare $status
end

#alias for colorls
alias lc='colorls'

#shows system info on terminal startup
screenfetch | lolcat
powerline-shell.py

Code: Select all

#!/usr/bin python3.8
# -*- coding: utf-8 -*-

import argparse
import os
import sys

def warn(msg):
    print '[powerline-bash] ', msg

# these symbols for now have to be set directly in powerline-shell.py:
class Powerline:
    symbols = {
        # flames (flamey)
        'patched': {
            'lock': u'\uE0A2',
            'network': u'\uE0A2',
            'separator': u'\uE0C0',
            'separator_thin': u'\uE0C1'
        }
    }


    color_templates = {
        'bash': '\\[\\e%s\\]',
        'zsh': '%%{%s%%}',
        'bare': '%s',
    }

    def __init__(self, args, cwd):
        self.args = args
        self.cwd = cwd
        mode, shell = 'flat', args.shell
        self.color_template = self.color_templates[shell]
        self.reset = self.color_template % '[0m'
        self.separator = Powerline.symbols[mode]['separator']
        self.separator_thin = Powerline.symbols[mode]['separator_thin']
        self.segments = []

    def color(self, prefix, code):
        return self.color_template % ('[%s;5;%sm' % (prefix, code))

    def fgcolor(self, code):
        return self.color('38', code)

    def bgcolor(self, code):
        return self.color('48', code)

    def append(self, content, fg, bg, separator=None, separator_fg=None):
        self.segments.append((content, fg, bg, separator or self.separator,
            separator_fg or bg))

    def draw(self):
        return (''.join(self.draw_segment(i) for i in range(len(self.segments)))
                + self.reset).encode('utf-8')

    def draw_segment(self, idx):
        segment = self.segments[idx]
        next_segment = self.segments[idx + 1] if idx < len(self.segments)-1 else None

        return ''.join((
            self.fgcolor(segment[1]),
            self.bgcolor(segment[2]),
            segment[0],
            self.bgcolor(next_segment[2]) if next_segment else self.reset,
            self.fgcolor(segment[4]),
            segment[3]))

def get_valid_cwd():
    """ We check if the current working directory is valid or not. Typically
        happens when you checkout a different branch on git that doesn't have
        this directory.
        We return the original cwd because the shell still considers that to be
        the working directory, so returning our guess will confuse people
    """
    try:
        cwd = os.getcwd()
    except:
        cwd = os.getenv('PWD')  # This is where the OS thinks we are
        parts = cwd.split(os.sep)
        up = cwd
        while parts and not os.path.exists(up):
            parts.pop()
            up = os.sep.join(parts)
        try:
            os.chdir(up)
        except:
            warn("Your current directory is invalid.")
            sys.exit(1)
        warn("Your current directory is invalid. Lowest valid directory: " + up)
    return cwd


if __name__ == "__main__":
    arg_parser = argparse.ArgumentParser()
    arg_parser.add_argument('--cwd-only', action='store_true',
            help='Only show the current directory')
    arg_parser.add_argument('--cwd-max-depth', action='store', type=int,
            default=4, help='Maximum number of directories to show in path')
    arg_parser.add_argument('--mode', action='store', default='patched',
            help='The characters used to make separators between segments',
            choices=['patched', 'compatible', 'flat'])
    arg_parser.add_argument('--shell', action='store', default='bash',
            help='Set this to your shell type', choices=['bash', 'zsh', 'bare'])
    arg_parser.add_argument('prev_error', nargs='?', type=int, default=0,
            help='Error code returned by the last command')
    args = arg_parser.parse_args()

    powerline = Powerline(args, get_valid_cwd())
config.json

Code: Select all

{
  "segments": [
    "virtual_env",
    "username",
    "hostname",
    "ssh",
    "cwd",
    "git",
    "hg",
    "jobs",
    "root"

  ]
,"theme": "~/.config/powerline-shell/themes/flames.py""
}
flames.py

Code: Select all

class Color(DefaultColor):
    USERNAME_FG = 250
    #USERNAME_BG = 240
    USERNAME_BG = 226
    #USERNAME_ROOT_BG = 124
    USERNAME_ROOT_BG = 160

    HOSTNAME_FG = 250
    HOSTNAME_BG = 238

    HOME_SPECIAL_DISPLAY = True
    #HOME_BG = 31  # blueish
    HOME_BG = 208  # blueish
    HOME_FG = 15  # white
    #PATH_BG = 237  # dark grey
    PATH_BG = 166 # dark grey
    #PATH_FG = 250  # light grey
    PATH_FG = 15  # light grey
    #CWD_FG = 254  # nearly-white grey
    CWD_FG = 15 # nearly-white grey
    #SEPARATOR_FG = 244
    SEPARATOR_FG = 15

    #READONLY_BG = 124
    READONLY_BG = 160
    READONLY_FG = 254

    SSH_BG = 166 # medium orange
    SSH_FG = 254

    REPO_CLEAN_BG = 148  # a light green color
    REPO_CLEAN_FG = 0  # black
    REPO_DIRTY_BG = 161  # pink/red
    REPO_DIRTY_FG = 15  # white

    JOBS_FG = 39
    JOBS_BG = 238

    #CMD_PASSED_BG = 236
    CMD_PASSED_BG = 160
    CMD_PASSED_FG = 15
    #CMD_FAILED_BG = 161
    CMD_FAILED_BG = 160
    CMD_FAILED_FG = 15

    SVN_CHANGES_BG = 148
    SVN_CHANGES_FG = 22  # dark green

    VIRTUAL_ENV_BG = 35  # a mid-tone green
    VIRTUAL_ENV_FG = 00
inxi -Fxxxrz

Code: Select all

System:    Kernel: 5.4.0-86-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 
           Desktop: Cinnamon 5.0.5 wm: muffin 5.0.1 dm: LightDM 1.30.0 
           Distro: Linux Mint 20.2 Uma base: Ubuntu 20.04 focal 
Machine:   Type: Desktop Mobo: ASRock model: Z97 Killer serial: <filter> 
           UEFI [Legacy]: American Megatrends v: P2.60 date: 03/06/2018 
CPU:       Topology: Quad Core model: Intel Core i7-4790K bits: 64 type: MT MCP 
           arch: Haswell rev: 3 L2 cache: 8192 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 63986 
           Speed: 800 MHz min/max: 800/4400 MHz Core speeds (MHz): 1: 800 2: 800 3: 801 
           4: 799 5: 800 6: 801 7: 800 8: 800 
Graphics:  Device-1: NVIDIA GP106 [GeForce GTX 1060 6GB] vendor: eVga.com. driver: nvidia 
           v: 470.74 bus ID: 01:00.0 chip ID: 10de:1c03 
           Display: x11 server: X.Org 1.20.11 driver: modesetting,nvidia 
           resolution: 1920x1080~60Hz, 1920x1080~60Hz 
           OpenGL: renderer: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 v: 4.6.0 NVIDIA 470.74 
           direct render: Yes 
Audio:     Device-1: Intel 9 Series Family HD Audio vendor: ASRock driver: snd_hda_intel 
           v: kernel bus ID: 00:1b.0 chip ID: 8086:8ca0 
           Device-2: NVIDIA GP106 High Definition Audio vendor: eVga.com. 
           driver: snd_hda_intel v: kernel bus ID: 01:00.1 chip ID: 10de:10f1 
           Device-3: Microdia USB 2.0 Camera type: USB driver: snd-usb-audio,uvcvideo 
           bus ID: 3-1:2 chip ID: 0c45:6366 serial: <filter> 
           Sound Server: ALSA v: k5.4.0-86-generic 
Network:   Device-1: Qualcomm Atheros Killer E220x Gigabit Ethernet vendor: ASRock 
           driver: alx v: kernel port: d000 bus ID: 05:00.0 chip ID: 1969:e091 
           IF: enp5s0 state: down mac: <filter> 
           Device-2: Broadcom and subsidiaries BCM4360 802.11ac Wireless Network Adapter 
           vendor: ASUSTeK driver: wl v: kernel port: d000 bus ID: 06:00.0 
           chip ID: 14e4:43a0 
           IF: wlp6s0 state: up mac: <filter> 
           IF-ID-1: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A 
Drives:    Local Storage: total: 3.64 TiB used: 354.03 GiB (9.5%) 
           ID-1: /dev/sda vendor: Samsung model: SSD 870 QVO 1TB size: 931.51 GiB 
           speed: 6.0 Gb/s serial: <filter> rev: 2B6Q scheme: MBR 
           ID-2: /dev/sdb vendor: Western Digital model: WD1002FAEX-00Y9A0 size: 931.51 GiB 
           speed: 6.0 Gb/s serial: <filter> rev: 1V01 
           ID-3: /dev/sdc vendor: Samsung model: SSD 860 EVO 2TB size: 1.82 TiB 
           speed: 6.0 Gb/s serial: <filter> rev: 3B6Q scheme: MBR 
Partition: ID-1: / size: 915.40 GiB used: 354.03 GiB (38.7%) fs: ext4 dev: /dev/sda5 
Sensors:   System Temperatures: cpu: 36.0 C mobo: N/A gpu: nvidia temp: 53 C 
           Fan Speeds (RPM): N/A gpu: nvidia fan: 9% 
Repos:     No active apt repos in: /etc/apt/sources.list 
           Active apt repos in: /etc/apt/sources.list.d/fish-shell-release-3-focal.list 
           1: deb http://ppa.launchpad.net/fish-shell/release-3/ubuntu focal main
           Active apt repos in: /etc/apt/sources.list.d/google-chrome.list 
           1: deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
           Active apt repos in: /etc/apt/sources.list.d/graphics-drivers-ppa-focal.list 
           1: deb http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal main
           Active apt repos in: /etc/apt/sources.list.d/hardware:razer.list 
           1: deb http://download.opensuse.org/repositories/hardware:/razer/xUbuntu_21.04/ /
           Active apt repos in: /etc/apt/sources.list.d/lutris-team-lutris-focal.list 
           1: deb http://ppa.launchpad.net/lutris-team/lutris/ubuntu focal main
           Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
           1: deb http://packages.linuxmint.com uma main upstream import backport
           2: deb http://mirror.nodesdirect.com/ubuntu focal main restricted universe multiverse
           3: deb http://mirror.nodesdirect.com/ubuntu focal-updates main restricted universe multiverse
           4: deb http://mirror.nodesdirect.com/ubuntu focal-backports main restricted universe multiverse
           5: deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
           6: deb http://archive.canonical.com/ubuntu/ focal partner
           Active apt repos in: /etc/apt/sources.list.d/openrazer-daily-focal.list 
           1: deb http://ppa.launchpad.net/openrazer/daily/ubuntu focal main
           Active apt repos in: /etc/apt/sources.list.d/openrazer-stable-focal.list 
           1: deb http://ppa.launchpad.net/openrazer/stable/ubuntu focal main
           Active apt repos in: /etc/apt/sources.list.d/polychromatic-stable-focal.list 
           1: deb http://ppa.launchpad.net/polychromatic/stable/ubuntu focal main
           Active apt repos in: /etc/apt/sources.list.d/slgobinath-gcalendar-focal.list 
           1: deb http://ppa.launchpad.net/slgobinath/gcalendar/ubuntu focal main
Info:      Processes: 333 Uptime: 22h 31m Memory: 15.59 GiB used: 7.29 GiB (46.8%) 
           Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 9 Shell: fish 
           v: 3.3.1 running in: gnome-terminal inxi: 3.0.38 
python version

Code: Select all

Python 3.8.10
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Desktop
Intel Core i7-4790K @ 8x 4.4GHz
NVIDIA GeForce GTX 1060 6GB
16GB mem
Mint 21.1 with Cinnamon

Laptop
Intel Core i5-5200U @ 4x 2.7GHz
Mesa Intel HD Graphics 5500
8GB mem
Dual boot: Mint 20.3 w/ Xfce and Win 10
vimes666
Level 6
Level 6
Posts: 1241
Joined: Tue Jan 19, 2016 6:08 pm

Re: Getting a "Failed to execute process...Reason: exec: Permission denied" on my fish startup script re: theme

Post by vimes666 »

I then copied the same site's default powerline-shell.py
I think you forgot to make the file executable:

Code: Select all

chmod +x /home/lloyd/.config/powerline-shell/powerline-shell.py
If you think the issue is solved, edit your original post and add the word solved to the title.
fulanitodetal
Level 1
Level 1
Posts: 19
Joined: Fri Mar 30, 2012 10:05 pm

Re: Getting a "Failed to execute process...Reason: exec: Permission denied" on my fish startup script re: theme

Post by fulanitodetal »

vimes666 wrote: Wed Sep 29, 2021 7:33 am
I then copied the same site's default powerline-shell.py
I think you forgot to make the file executable:

Code: Select all

chmod +x /home/lloyd/.config/powerline-shell/powerline-shell.py
I think I already did that unless I'm missing something. See screenshot of the original post below.

Image
Desktop
Intel Core i7-4790K @ 8x 4.4GHz
NVIDIA GeForce GTX 1060 6GB
16GB mem
Mint 21.1 with Cinnamon

Laptop
Intel Core i5-5200U @ 4x 2.7GHz
Mesa Intel HD Graphics 5500
8GB mem
Dual boot: Mint 20.3 w/ Xfce and Win 10
vimes666
Level 6
Level 6
Posts: 1241
Joined: Tue Jan 19, 2016 6:08 pm

Re: Getting a "Failed to execute process...Reason: exec: Permission denied" on my fish startup script re: theme

Post by vimes666 »

I think I already did that unless I'm missing something. See screenshot of the original post below.
Yes, sorry I missed that one.
If you think the issue is solved, edit your original post and add the word solved to the title.
vimes666
Level 6
Level 6
Posts: 1241
Joined: Tue Jan 19, 2016 6:08 pm

Re: Getting a "Failed to execute process...Reason: exec: Permission denied" on my fish startup script re: theme

Post by vimes666 »

Try this:

Code: Select all

sudo chmod -x ~/.config/powerline-shell/powerline-shell.py
and then

Code: Select all

chmod +x ~/.config/powerline-shell/powerline-shell.py
So the second one without sudo.
If you think the issue is solved, edit your original post and add the word solved to the title.
Locked

Return to “Scripts & Bash”