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

add and edit commands error if $EDITOR set to "vim -u ~/my-vimrc" #4

Closed
tddschn opened this issue Sep 18, 2020 · 9 comments
Closed

Comments

@tddschn
Copy link

tddschn commented Sep 18, 2020

Expected Behavior

add and edit commands work.

Actual Behavior

add and edit commands don't work if $EDITOR is set to "vim -u ~/my-vimrc", but work if set to just "vim".

$ echo "${EDITOR}"
vim -u ~/my-vimrc

$ kb add -t 'test title test'
Traceback (most recent call last):
  File "/usr/local/bin/kb", line 33, in <module>
    sys.exit(load_entry_point('kb==0.1.1', 'console_scripts', 'kb')())
  File "/usr/local/lib/python3.8/site-packages/kb-0.1.1-py3.8.egg/kb/main.py", line 62, in main
    dispatch(cmd, cmd_params, config=DEFAULT_CONFIG)
  File "/usr/local/lib/python3.8/site-packages/kb-0.1.1-py3.8.egg/kb/main.py", line 52, in dispatch
    return COMMANDS[function](*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/kb-0.1.1-py3.8.egg/kb/commands/add.py", line 71, in add
    call([config["EDITOR"], Path(category_path, title)])
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'vim -u ~/my-vimrc'

Problems seem to be at the line call([config["EDITOR"], Path(category_path, title)]) in kb/commands/add.py and kb/commands/view.py.

Steps to Reproduce the Problem

touch ~/my-vimrc
EDITOR="vim -u ~/my-vimrc" kb add -t 'new title'
EDITOR="vim -u ~/my-vimrc" kb view -t 'new title'

Specifications

  • Version: Python 3.8.5
  • Platform: macOS Catalina 10.15.6
  • Subsystem: N/A
@gnebbia
Copy link
Owner

gnebbia commented Sep 18, 2020

Thanks for the suggestion!

Fixed with commit 699ba35

@gnebbia gnebbia closed this as completed Sep 18, 2020
@tddschn
Copy link
Author

tddschn commented Sep 18, 2020

Thanks for the quick fix!

I'm not familiar with setup.py and couldn't figure out how to upgrade kb, can you help me?

Here's what I tried:

git pull origin master # checked, add.py and edit.py fixed with "shell=True" added to call()
python setup.py install
python setup.py install --force

and it seems that these 2 commands still don't work.

@gnebbia
Copy link
Owner

gnebbia commented Sep 18, 2020

do this:
within the kb direectory, execute:

pip install --upgrade .  # there is a dot after upgrade ;)

Let me know if it works!

@tddschn
Copy link
Author

tddschn commented Sep 18, 2020

Thanks! :)

After upgrading kb with pip install --upgrade ., add works but edit doesn't.

I'll open a PR and try to fix it :)

@gnebbia
Copy link
Owner

gnebbia commented Sep 18, 2020

Ok, fixed again, sorry, my bad, I did not update the edit module!
Thanks for warning me!
Can you update and tell me if it is solved now?

@tddschn
Copy link
Author

tddschn commented Sep 18, 2020

Yes, thanks! :)

@gnebbia
Copy link
Owner

gnebbia commented Sep 18, 2020

Ok I fixed it again and removed shell=True, since it may cause security issues through command injection.
Try to see if it works now, I tested and seems ok now!

@tddschn
Copy link
Author

tddschn commented Sep 18, 2020

Yes it works! Thank you :)

@gnebbia
Copy link
Owner

gnebbia commented Sep 18, 2020

You are welcome! Happy to be helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants