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

cd error #18

Open
dosentmatter opened this issue Jul 19, 2019 · 12 comments
Open

cd error #18

dosentmatter opened this issue Jul 19, 2019 · 12 comments
Labels
bug Something isn't working

Comments

@dosentmatter
Copy link

[Unhandled error: /usr/bin/cd: line 4: cd: $(dirname importNameRule.ts): No such file or directory]

vim info:
I am using vim-plugged

Plug 'zivyangll/git-blame.vim'
nnoremap <Leader>s :<C-u>call gitblame#echo()<CR>

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 18 2019 23:51:40)
macOS version
Included patches: 1-950
Compiled by [email protected]
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         -tag_any_white
+arabic            +file_in_path      -mouse_sysmouse    -tcl
+autocmd           +find_in_path      +mouse_urxvt       +termguicolors
+autochdir         +float             +mouse_xterm       +terminal
-autoservername    +folding           +multi_byte        +terminfo
+balloon_eval      -footer            +multi_lang        +termresponse
+balloon_eval_term +fork()            -mzscheme          +textobjects
+browse            +fullscreen        +netbeans_intg     +textprop
++builtin_terms    -gettext           +num64             +timers
+byte_offset       -hangul_input      +odbeditor         +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +transparency
+clientserver      +job               +perl/dyn          +user_commands
+clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           +python/dyn        +visualextra
+conceal           +linebreak         +python3/dyn       +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua/dyn           +ruby/dyn          +windows
+dialog_con_gui    +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
+dnd               +mouse             +startuptime       +xim
-ebcdic            +mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      -xsmp
+eval              -mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
+extra_search      +mouse_netterm     +tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE 
@zivyangll zivyangll added the bug Something isn't working label Jul 23, 2019
@zivyangll
Copy link
Owner

@dosentmatter can you provide more information?
system: linux/window?
and reproduce demo.

@dosentmatter
Copy link
Author

dosentmatter commented Aug 2, 2019

I am on macOS. I tried on an ubuntu docker image and seems to work fine. Here's what I tried in ubuntu docker container:

$ docker pull ubuntu
$ docker run --rm -it ubuntu bash
# apt update
# apt install vim git curl
# curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# cat <<EOF > ~/.vimrc
call plug#begin('~/.vim/plugged')
Plug 'zivyangll/git-blame.vim'
nnoremap <Leader>s :<C-u>call gitblame#echo()<CR>
call plug#end()
EOF
# vim -c 'PlugInstall' -c 'qa'
# vim ~/.vim/plugged/git-blame.vim/autoload/gitblame.vim # <Leader>s works

On macOS, it doesn't work for me:

I went into vim debugger and it seems to be failing on this line.

  if a:0 == 0
    let output = s:has_vimproc() ?
          \ vimproc#system(command) : system(command)

I have vimproc installed so it is going into the first case. Note that I didn't have vimproc on ubuntu. The contents of the string is the following:

cd "$(dirname "/Users/kevinlau/.vim/plugged/git-blame.vim/autoload/gitblame.vim")"; git --no-pager blame "$(basename "/Users/kevinlau/.vim/plugged/git-blame.vim/autoload/gitblame.vim")" -L "$(basename "30")",+1 --porcelain

I saved the string to a global variable, let g:command = command and tried running the commands myself.

echo vimproc#system(g:command) fails just like in the plugin and I get:

/usr/bin/cd: line 4: cd: $(dirname /Users/kevinlau/.vim/plugged/git-blame.vim/autoload/gitblame.vim): No such file or directory
fatal: no such path '$(basename /Users/kevinlau/.vim/plugged/git-blame.vim/autoload/gitblame.vim)' in HEAD

vimproc seems to be failing on the initial cd cd "$(dirname "/Users/kevinlau/.vim/plugged/git-blame.vim/autoload/gitblame.vim")".
vimproc works with dirname "/Users/kevinlau/.vim/plugged/git-blame.vim/autoload/gitblame.vim". It seems to be failing on the $() command substitution. Not sure if vimproc supports that. If not, the code can be replaced with multiple calls to vimproc.
With a quick test, :echo vimproc#system('echo "$(echo 1)"') shows $(echo 1) and not 1.

echo system(g:command) doesn't fail and I get:

d06f5420467ada13f2f3ea0e75372bf1ef3181d1 30 30 1
author Charles Gueunet
author-mail <[email protected]>
author-time 1562210780
author-tz +0200
committer zivyangll
committer-mail <[email protected]>
committer-time 1562210780
committer-tz +0800
summary feat(neovim): use virtual text (#16)
boundary
filename autoload/gitblame.vim
	    let output = s:has_vimproc() ?

@dosentmatter
Copy link
Author

dosentmatter commented Aug 2, 2019

I tried with vimproc on ubuntu and it fails with other errors such as "cd" is not found. I don't think you should be using cd or command substitution. vimproc#system() docs says

Note: It does not execute a shell. So a shell internal command is invalid. Ex: pwd, cd, ...

The reason it works on macOS is because I have cd as a shell builtin and a binary:

$ type -a cd
cd is a shell builtin
cd is /usr/bin/cd

On ubuntu docker, it is only a builtin.

# type -a cd
cd is a shell builtin

So with vimproc#system(), you can't use any shell functionality such as command substitution, shell builtins, and semi-colons ; for multiple commands. If you want to execute a shell, you can pass the command to sh -c. For example, :echo vimproc#system('sh -c ' . "'cd; pwd'"). But then it won't work on windows. Doesn't look like you were supporting windows anyway since you are using shell syntax. Or maybe vimproc has another function where it does run in a shell.

docker pull ubuntu
docker run --rm -it ubuntu bash
# apt update
# apt install vim git curl make gcc
# curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# cat <<EOF > ~/.vimrc
call plug#begin('~/.vim/plugged')
Plug 'zivyangll/git-blame.vim'
nnoremap <Leader>s :<C-u>call gitblame#echo()<CR>
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
call plug#end()
EOF
# vim -c 'PlugInstall' -c 'qa'
# vim ~/.vim/plugged/git-blame.vim/autoload/gitblame.vim # <Leader>s works

@zivyangll
Copy link
Owner

very very details. I'm on MacOS same with you. and it's works. I tried with ubuntu docker, it's also works. Can you debugger with your MacOS, try to fix it? so that you can make a Pull Request?

@dosentmatter
Copy link
Author

Hmm do you also have vimproc installed?

I can try to take a look this weekend if I have time.

@dman777
Copy link

dman777 commented Sep 4, 2019

Same here.... using Linux and Vim 8,,,

[Unhandled error: fatal: no such path 'src/sp-shelter-point/edit-stay/sp-edit-particip
ating-clients.html' in HEAD]

@vwal
Copy link

vwal commented Nov 4, 2019

Any update/progress on this? I also ran to this error on macOS.

@yangxuehe
Copy link

I also ran to this error on Win10 and Vim8.

@aidoTank
Copy link

aidoTank commented Oct 7, 2020

me too

1 similar comment
@yihuaxiang
Copy link

me too

@KyleDeng
Copy link

KyleDeng commented Apr 8, 2021

me too, ubuntu -> spacevim

@KyleDeng
Copy link

KyleDeng commented Apr 8, 2021

before

if a:0 == 0
let output = s:has_vimproc() ?
\ vimproc#system(command) : system(command)

after it's ok

if a:0 == 0
let output = s:has_vimproc() ?
\ system(command) : vimproc#system(command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants