Open cam-narzt opened 1 year ago
In case it helps, I was getting this issue on my linux environment, but not on my MacOS. I had a slight difference in my config.
On both configs I had
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/backups/" t)))
On my MacOS emacs config I had ..
(setq backup-by-copying t)
While on linux, I did not set this.
Once I set backup-by-copying
to t
, the problem went away on linux. I am sure there is good reason to set (backup-by-copying-when-linked t)
sometimes (or the other configurations), so I would say this could be a possible workaround, but not a permanent solution.
Im pretty sure I set this on MacOS because of this issue https://github.com/emacs-lsp/lsp-mode/issues/3516, which is likely related, but I didnt sync the change to my other configs.
I just updated lsp-mode
for the first time in while and started running into this problem as well; the first time I save a buffer, the import paths across all open buffers are rewritten and tsconfig.json
is modified to include the path to a tempfile;
import { User } from './contexts/User';
// becomes:
import { User } from '../home/john/Projects/foo/src/contexts/User';
import { App } from './App';
// becomes:
import { App } from "../../../../../tmp/!home!john!Projects!foo!src!App.tsx~"
and this path is added to the tsconfig.json file in the project root:
"include": ["src", "../../../../../tmp/!home!john!Projects!foo!src!App.tsx~"],`
IO log is attached iolog.txt
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
relative import paths are getting mangled in my project's typescript files
eg from:
import { RegexCompositeType, RegexComposition } from './regex';
to
import { RegexCompositeType, RegexComposition } from '../../Developer/Rust/appname/app/javascript/components/app-component/regex';
which in addition to being an unwanted change, is not even a valid path, the ../../ at the beginning is not enough dirs up to get to the parent dir of the Developer dir (my home dir is the parent dir of Developer). The
../../
part of the path seems like the number of dirs to go up from emacs' backup dir to the$HOME
dir.also paths to emacs' backup files are being added to the tsconfig file's include list.
Steps to reproduce
create a typescript project import from one file to another with a relative import
import foo from './bar'
quit emacs start emacs with:emacs -q -nw lsp-start-plain.el
add the following at the bottom of the file:M-x eval-buffer
in the editedlsp-start-plain.el
bufferopen a file in your project with a relative import add a space or comment or something into the file save file to trigger backup
Expected behavior
import path stays the same, tsconfig is not changed
Which Language Server did you use?
ts-ls
OS
MacOS
Error callstack
There is no error message from lsp-mode here's what the
*Messages*
buffer says:and the contents of the io log:
Anything else?
This only started happening recently probably after a component updated: lsp-mode, ts-ls, or some npm package.
Running
lsp-start-plain
from my emacs with my config loaded raises this error:I have no idea why it's looking at
~/.history
at all, that file is not at all part of my project.