Fish-shell: Cannot run fish scripts

Created on 31 May 2017  Β·  3Comments  Β·  Source: fish-shell/fish-shell

fish version: 2.5.0
Ubuntu 16.04 Linux limebox 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Hello, I can't seem to be able to run fish scripts, when I create an executable file echo "echo test" > script.fish, running fish ./script.fish results in an error message: ./script.fish: No such file or directory.

It works fine with sh -c 'env HOME=$(mktemp -d) fish', for some reason.

link/.config/fish $ tree
.
β”œβ”€β”€ completions
β”‚Β Β  β”œβ”€β”€ fisher.fish
β”‚Β Β  β”œβ”€β”€ get.fish -> /home/limeth/.config/fisherman/get/completions/get.fish
β”‚Β Β  └── git.fish -> /home/limeth/.config/fisherman/git-flow/completions/git.fish
β”œβ”€β”€ conf.d
β”‚Β Β  └── git-flow.init.fish -> /home/limeth/.config/fisherman/git-flow/init.fish
β”œβ”€β”€ config.fish
β”œβ”€β”€ fish_colors
β”œβ”€β”€ fishd.limebox
β”œβ”€β”€ fishfile
β”œβ”€β”€ fish_history
β”œβ”€β”€ fish_read_history
└── functions
    β”œβ”€β”€ cl.fish
    β”œβ”€β”€ fisher.fish
    β”œβ”€β”€ fish_greeting.fish -> /home/limeth/.config/fisherman/bobthefish/fish_greeting.fish
    β”œβ”€β”€ fish_mode_prompt.fish -> /home/limeth/.config/fisherman/bobthefish/fish_mode_prompt.fish
    β”œβ”€β”€ fish_prompt.fish -> /home/limeth/.config/fisherman/bobthefish/fish_prompt.fish
    β”œβ”€β”€ fish_right_prompt.fish -> /home/limeth/.config/fisherman/bobthefish/fish_right_prompt.fish
    β”œβ”€β”€ fish_title.fish -> /home/limeth/.config/fisherman/bobthefish/fish_title.fish
    β”œβ”€β”€ fish_user_key_bindings.fish
    β”œβ”€β”€ fzf_key_bindings.fish -> /home/limeth/.fzf/shell/key-bindings.fish
    β”œβ”€β”€ get.fish -> /home/limeth/.config/fisherman/get/functions/get.fish
    β”œβ”€β”€ getopts.fish -> /home/limeth/.config/fisherman/getopts/getopts.fish
    └── set_color_custom.fish -> /home/limeth/.config/fisherman/jellyfish/functions/set_color_custom.fish

3 directories, 22 files
$ cat config.fish
# Source dotfiles scripts
source ~/.dotfiles/bin/source.fish

# Enable terminal colors
set -x TERM "xterm-256color"

# Vi mode
# Automatically enable Vi mode in `~/.config/fish/functions/fish_user_key_bindings.fish`
set -g theme_display_vi yes

Link to ~/.dotfiles/bin/source.fish: https://gitlab.com/Limeth/dotfiles/blob/master/bin/source.fish

Any tips on what I should be looking for are appreciated.

question

Most helpful comment

Right, your source.fish ends with cd ~. That's generally a bad idea. A login shell should already have PWD set to your home directory. And if you're starting any other fish instance you do not want to change the PWD. If you feel there is some good reason to do that you should limit it to interactive shells:

if status is-interactive
    cd ~
end

All 3 comments

running fish ./script.fish results in an error message: ./script.fish: No such file or directory.

This looks like something cds in your configuration.

Please try to run that file, and when it fails, run echo $PWD; fish -c 'echo $PWD'. If the two differ, that's your problem.

That was it!

$ echo $PWD
/tmp
$ fish -c "echo \$PWD"
/home/limeth

Thank you very much! :)

Right, your source.fish ends with cd ~. That's generally a bad idea. A login shell should already have PWD set to your home directory. And if you're starting any other fish instance you do not want to change the PWD. If you feel there is some good reason to do that you should limit it to interactive shells:

if status is-interactive
    cd ~
end
Was this page helpful?
0 / 5 - 0 ratings