question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rename in file from another path does not work

See original GitHub issue

Problem

When opening a file from another sub-root path and trying to rename a method/variable, the following error is received [coc.nvim] Invalid position for rename

Seems exactly like in #474, but I do not have coc-python installed.

Minimal Environment

Fully-cleaning coc

rm -rvf ~/.config/coc

~/.config/nvim/init.vim

set nocompatible
call plug#begin('~/.config/nvim/plugged')
Plug 'neoclide/coc.nvim'
call plug#end()
 
let mapleader=","
nmap <leader>rn <Plug>(coc-rename)

installing coc-pyright

:PlugUpdate
:CocInstall coc-pyright

/tmp/test/test.py

import sys
   
def test( s: str ):
    print( s )
   
def main():
    test('1')

Opening the file

cd ~
nvim /tmp/test/test.py

Attempting to Rename

Attempt to rename the name of the function test when standing on any of its letters (,rn)

[coc.nvim] Invalid position for rename

Versioning

:CocCommand pyright.version

[coc.nvim] coc-pyright 1.1.146 with Pyright 1.1.148

:CocInfo

## versions

vim version: NVIM v0.4.4                                                                                    
node version: v14.16.1               
coc.nvim version: 0.0.80-b427b2ccfa  
coc.nvim directory: /home/david/.config/nvim/plugged/coc.nvim                                               
term: xterm-256color
platform: linux

## Log of coc.nvim

2021-06-10T11:50:29.340 INFO (pid:1247104) [services] - registered service "pyright"
2021-06-10T11:50:29.343 INFO (pid:1247104) [services] - Pyright Server state change: stopped => starting 
2021-06-10T11:50:29.349 INFO (pid:1247104) [plugin] - coc.nvim 0.0.80-b427b2ccfa initialized with node: v14.16.1 after 182ms
2021-06-10T11:50:29.356 INFO (pid:1247104) [language-client-index] - pyright started with 1247117
2021-06-10T11:50:29.646 INFO (pid:1247104) [services] - Pyright Server state change: starting => running 
2021-06-10T11:50:29.654 INFO (pid:1247104) [services] - service pyright started
2021-06-10T11:50:30.519 INFO (pid:1247104) [attach] - receive notification: rename []
2021-06-10T11:50:31.244 WARN (pid:1247104) [completion] - Document not attached, suggest disabled.
2021-06-10T11:50:34.792 INFO (pid:1247104) [attach] - receive notification: showInfo []

:version

:version                                                                                                                                                                                                   
NVIM v0.4.4
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/local/clang-7.0.0/bin/clang -O2 -g -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrou
gh -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/home/travis/build/neovim/bot-ci/build
/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src
/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-d8a0d531-236d-4d4c-9703-9d6e27bee65f

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Debugging

:checkhealth

health#coc#check
========================================================================
  - OK: Environment check passed

  - OK: Javascript bundle build/index.js found
  - OK: Service started

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='6203'
  - INFO: $COLORTERM='truecolor'

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - ERROR: Python provider error:
    - ADVICE:
      - provider/pythonx: Could not load Python 2:
          /usr/bin/python2 does not have the "neovim" module. :help |provider-python|
          /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python|
          python2.6 not found in search path or not executable.
          /usr/bin/python is Python 3.9 and cannot provide Python 2.
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.9.5
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v14.16.1
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
yaegassycommented, Jun 10, 2021

@dsirov If pyright cannot detect the “project root” correctly, it may not work as you expect.

Try this. https://github.com/neoclide/coc.nvim/wiki/Using-workspaceFolders#resolve-workspace-folder

e.g:

autocmd FileType python let b:coc_root_patterns = ['.git', '.env', 'venv', '.venv', 'setup.cfg', 'setup.py', 'pyproject.toml', 'pyrightconfig.json']

Related issue:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solution to cannot rename file because the folder or a file in it ...
Solution to cannot rename file because the folder or a file in it is open in another program · Step 1: Go to...
Read more >
Unable to Rename a File in Windows 10? 8 Ways to Fix It
1. First, Rule Out a File Specific Issue · 2. Ensure You Have Access to the File You're Renaming · 3. Ensure the...
Read more >
Cannot rename files - File or folder does not exist
Cannot rename files - File or folder does not exist · Open the Task manager. Here's a tip: Press CTRL+Shift+ESC. · Click File...
Read more >
How to Change or Rename a File, Folder, or Directory
Renaming a folder containing files may cause problems if that folder contains files that are required by a program. For example, if the ......
Read more >
How to rename a file using Python - Stack Overflow
Should be noted that if the files are not in the working directory you will need the full path. – EndermanAPM. Mar 29,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found