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

File differs from already included file only in casing: correct casing but relative path #25460

Closed
adamcfranco opened this issue Jul 5, 2018 · 55 comments · Fixed by #34622
Closed
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@adamcfranco
Copy link

Error TS1149: File name 'C:/Project/frontend/scripts/State.ts' differs from already included file name '../frontend/scripts/State.ts' only in casing.

I've triple checked the casing in our references and the actual files have the correct casing as well. As far as I can tell, this is solely because the relative path uses incorrect casing, or perhaps it's just because of the relative path itself?

It compiles just fine on Mac and Linux, but throws this error on Windows.

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Jul 5, 2018
@RyanCavanaugh
Copy link
Member

This looks like a bug, but we'll need some way to reproduce it. Do you have a zip file or repo or description of the files we could use?

@adamcfranco
Copy link
Author

adamcfranco commented Jul 6, 2018

As it turns out, the issue was with a third party module, tsify. Our project was using 1.0.1, and forceConsistentCasingInFileNames wasn't supported until 4.0.0.

@aaybhangu
Copy link

I had same issue with one of my component import. I component directory name was historical with same "h" I was trying to import it with capital "H". It should be "
import { GraphDataComponent } from "./historical/graph-data/graph-data.component";" instead of "import { GraphDataComponent } from "./Historical/graph-data/graph-data.component" in app.moudule.ts.

@yurylavrukhin
Copy link

Thanks @aaybhangu!

@Iti28
Copy link

Iti28 commented Aug 14, 2019

Hi, I am still facing this issue with - error TS1149: File name 'src/models/headers/userRole.ts' differs from already included file name 'src/models/headers/UserRole.ts' only in casing.
I have tried multiple ways to fix it , but no luck . I am using windows.

@AliceNewzoo
Copy link

I am also facing the same issue.
For now, "solved" by setting:
"forceConsistentCasingInFileNames": false,
in tsconfig.json

@ghost
Copy link

ghost commented Aug 29, 2019

I stumbled across this exact same error recently.
After doing some googling I found this. The last reply caught my eye. So I simply closed the folder is was working in in Visual Studio Code and re-opened it. After everything loaded up, no errors and I didn't have to mess with the tsconfig.json file.

hope this helps

@github0013
Copy link

github0013 commented Sep 13, 2019

I came across this same issue

  • remove the workspace didn't help
  • changing forceConsistentCasingInFileNames didn't help

For my case, somewhere in the directory, the errors were happening, was changed...? So I had to do the following to fix them all.

  1. You change the directory name to something like "OriginalDirectoryName" => "AnotherName"
  2. VsCode will try to update the directory name in the source, so wait for a few seconds, and it will show all the files need to be updated with the new directory name.
  3. Go File -> Save All and save them all
  4. Change the directory name back "AnotherName" => "OriginalDirectoryName"
  5. Again, it's gonna try to update files, so you save them all.
  6. Reboot VsCode.

then it should fix the problem.

pl2476 added a commit to pl2476/myscaffold-react that referenced this issue Oct 9, 2019
@nharrisanalyst
Copy link

I am getting this bug after renaming a file from the camelCase to uppercase all first letters

@RyanCavanaugh RyanCavanaugh reopened this Oct 9, 2019
@RyanCavanaugh RyanCavanaugh added Needs Investigation This issue needs a team member to investigate its status. and removed Needs More Info The issue still hasn't been fully clarified labels Oct 9, 2019
@yujiangshui
Copy link

In my case, I used to create a file named Logger but changed to logger later. One file which imported this always shows this error message but actually in the terminal or other files, won't show this message.

So I use VSCode Reload Window feature to reload the VSCode, and the error message disappears. So I think maybe there is a cache somewhere in VSCode for this error and didn't clear? You can have a try if you face this problem after making sure the file name is correct.

@dody87
Copy link

dody87 commented Oct 15, 2019

I have the same issue, and just discovered that for some reason, in some ts file it is called using a capitalize letter, then I renamed it for lowercase and it works.

You can try also removing this model ts file and creating again with angular-CLI.

@sheetalkamat sheetalkamat added the Bug A bug in TypeScript label Oct 15, 2019
@sheetalkamat
Copy link
Member

Changing case results in exception on updateOpen command. Note how file is opened with different case and closed with original casing in same command.

Info 69   [10:30:18.128] request:
    {"seq":5,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":["c:/temp/est/Logger.ts"],"openFiles":[{"file":"c:/temp/est/logger.ts","fileContent":"export class logger {\r\n    \r\n}","scriptKindName":"TS","projectRootPath":"c:\\temp\\est"}]}}
Err 70    [10:30:18.153] Exception on executing command {"seq":5,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":["c:/temp/est/Logger.ts"],"openFiles":[{"file":"c:/temp/est/logger.ts","fileContent":"export class logger {\r\n    \r\n}","scriptKindName":"TS","projectRootPath":"c:\\temp\\est"}]}}:

    Debug Failure. False expression: Script should not exist and not be open already

    Error: Debug Failure. False expression: Script should not exist and not be open already
        at ProjectService.applyChangesInOpenFiles (c:\Typescript\built\local\tsserver.js:138090:34)
        at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (c:\Typescript\built\local\tsserver.js:138972:46)
        at c:\Typescript\built\local\tsserver.js:140630:88
        at IOSession.Session.executeWithRequestId (c:\Typescript\built\local\tsserver.js:140621:28)
        at IOSession.Session.executeCommand (c:\Typescript\built\local\tsserver.js:140630:33)
        at IOSession.Session.onMessage (c:\Typescript\built\local\tsserver.js:140653:35)
        at Interface.<anonymous> (c:\Typescript\built\local\tsserver.js:141968:27)
        at Interface.emit (events.js:182:13)
        at Interface._onLine (readline.js:290:10)
        at Interface._normalWrite (readline.js:433:12)
        at Socket.ondata (readline.js:149:10)
        at Socket.emit (events.js:182:13)
        at addChunk (_stream_readable.js:283:12)
        at readableAddChunk (_stream_readable.js:264:11)
        at Socket.Readable.push (_stream_readable.js:219:10)
        at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

@sheetalkamat
Copy link
Member

This issue seems to be more involved than just checking root file names. When reusing program there is another test case that fails which is simple program reuse test:

it("forceConsistentCasingInFileNames works when renaming file with different casing", () => {
            const loggerFile: File = {
                path: `${projectRoot}/logger.ts`,
                content: `export class logger { }`
            };
            const anotherFile: File = {
                path: `${projectRoot}/another.ts`,
                content: `import { logger } from "./logger"; new logger();`
            };
            const tsconfig: File = {
                path: `${projectRoot}/tsconfig.json`,
                content: JSON.stringify({
                    compilerOptions: { forceConsistentCasingInFileNames: true }
                })
            };

            const host = createWatchedSystem([loggerFile, anotherFile, tsconfig, libFile, tsconfig]);
            createWatchOfConfigFile(tsconfig.path, host);
            checkOutputErrorsInitial(host, emptyArray);
            host.writeFile(anotherFile.path, anotherFile.content.replace("./logger", "./Logger"));
            host.runQueuedTimeoutCallbacks();
            checkOutputErrorsIncremental(host, [
                createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, loggerFile.path, `${projectRoot}/Logger.ts`),
            ]); // Currently the errors are not reported in watch mode but will be reported if program is created from scratch.
        });

@SturmB
Copy link

SturmB commented Oct 30, 2019

Yep, I'm having this same issue and none of the previously-stated fixes/workarounds do anything to help.

In my case, the message is:

error TS1149: File name '/mnt/c/Users/<username>/Documents/adobe-scripts/InDesign/Create Downloadable 
(2020a)/Illustrator/2015.3/index.d.ts' differs from already included file name '/mnt/c/Users/<username>/Documents/adobe-scripts/InDesign/Create Downloadable (2020a)/illustrator/2015.3/index.d.ts' only in casing.

@moritz91
Copy link

moritz91 commented May 14, 2020

A restart of the Typescript-Server will suffice. VSCode restart is overkill.

In VSC on OSX: CMD + Shift + P followed by typing TypeScript: Restart TS server.

@jbblt
Copy link

jbblt commented May 15, 2020

With webstorm You need to invalide and clear the cache :
file > invalidate Caches/ restart

@sirajalam049
Copy link

The shortest and best solution I found is.

Just remove that word from that causing casing problems.
e.g.
ListsDrawerOfContent and ListsDrawerofContent

I removed of from the file name. And the compilers compiled it correctly.

Then later I renamed by my desired case ListsDrawerOfContent.
Worked like a charm.

Also, keep in mind the git.

https://stackoverflow.com/questions/17683458/how-do-i-commit-case-sensitive-only-filename-changes-in-git

@andrefbrweb
Copy link

andrefbrweb commented Jun 28, 2020

I had the same problem with import, after a rename a file from "a" to "A", i just restarted the vs code and then it works.

@heavenkiller2018
Copy link

I had the same problem. VSCode restart and setting "forceConsistentCasingInFileNames": false can't help me.

error info:(just differ in disk symbol)
File name 'D:/mycode/devmono2/packages/server-sdk/index.ts' differs from already included file name 'd:/mycode/devmono2/packages/server-sdk/index.ts' only in casing.Vetur(1149)

why?

@luke575
Copy link

luke575 commented Aug 6, 2020

Solved!
Mine was a simple problem.

Everything was fine locally on mac, but i was getting this error on my Jenkins server. The problem was simply that locally the filename was 'quote.ts' but within my remote git repo it was 'Quote.ts'.

How the problem came about
So the filename was originally 'Quote.ts' which i pushed up. I then changed to 'quote.ts', but git did not see this as a change (I believe macs are case insensitive) - and therefore the case change was not reflected in remote repo.

And so when Jenkins pipeline ran, it was pulling down 'Quote.ts' when it was being referenced as '../../quote.ts' - which results in the error.

How i solved it

  1. Drink coffee
  2. Change filename in remote repo manually to be lowercase
  3. git pull locally
  4. Run pipeline

Boom Bam! Hope this helps someone

@ninjavang
Copy link

Had a similar issue that generated around 100 of these errors.

Didn't read them all to closely as they all seemed to have the same root problem. Had recently switched to running node in WSL2 that I took for granted was the cause of the issue. After 2 hours without success I actually went through the whole list and found one example where there was an actual bug.

import { FooInterface } from '../Foo'; // should be '../foo'
import { BarService } from '../Bar'; // should be '../bar'

I changed it to lowercase, reloaded vscode, rebuilt it and all the errors went away.

What I think happend is that ts tried to import the incorrect path ('Foo' instead of 'foo') and then cached the result and tried to use the incorrect cached path when processing the rest of the code.

Hopefully this helps someone out there!

@herzorf
Copy link

herzorf commented Aug 28, 2020

i just restart my ide then the error is gone

@bdshanto
Copy link

just make a same object in component, and start your ng, after running successfully, then remove object and import your link,
then its should be work,
In my project it worked.

@meerkat-citronella
Copy link

this just happened to me, it's an ongoing issue that hasn't been solved. It happens whenever I change the casing of a directory name and try to commit the change. Git doesn't recognize change in casing for a directory name.

@arianseyedi
Copy link

+1......but WHYYYYYYYY

@dipta10
Copy link

dipta10 commented Nov 1, 2020

I just faced the problem. It turned out that when I tried to import it using vscode, VSCode used the previous file name and directory name. So I modified it and after running tsc it didn't show any error in the terminal, but I was still getting that read squiggly line in VSCode. So I restarted the Typescript server in vscode (Typescript: Restart TS Server) and it went away. Hope it helps someone.

@tatianajiselle
Copy link

@ninjavang you helped me! Had the same issue happening with my gitlab ci/cd pipeline. Turns out when i went to the remote branch and checked the file's path, there were two versions of the file, each in their case sensitive version.

I deleted the version unwanted on the remote, copied the file locally, pulled the remote down, refreshed my VS Code, and re-added the file. It worked!

Thanks for the help!

@cyberwombat
Copy link

So tried all the restart etc without success... Turns out the issue is that if another file in the project references the old casing then every other file which attempts to use the new (correct) casing will fail. So ensure that the file's casing has been changed in every file. That is so a bug.

@cybermerlin
Copy link

At version 4.1.3 still reproduced.

@Vadorequest
Copy link

Experienced this yesterday when renaming files and methods. WebStorm got lost and was displaying this even after I had fixed everything. A good old cmd+q and restart of WebStorm fixed it. 🤷

@cybermerlin
Copy link

#42270 (comment)

@Icyrockton
Copy link

webstorm encountered this problem . Restart TS Server not working

@tenadolanter
Copy link

git rm -r --cached . then reboot VSCode, it works~

@ryancraigmartin
Copy link

The following command fixed things up for me:

git clean -fdx

k1tikurisu added a commit to k1tikurisu/is-founding-day-of-wu that referenced this issue Jun 8, 2021
@leecj
Copy link

leecj commented Jul 1, 2021

ctrl+shift+p: restart eslint server

@SchoofsKelvin
Copy link

The mentions of this being Windows-only might be related to the drive letter, as I just had this issue with this message:

Already included file name 'C:/Users/Kelvin/AppData/Local/Microsoft/TypeScript/4.3/node_modules/@types/webpack-dev-server/index.d.ts' differs from file name 'c:/Users/Kelvin/AppData/Local/Microsoft/TypeScript/4.3/node_modules/@types/webpack-dev-server/index.d.ts' only in casing.
  The file is in the program because:
    Imported via 'webpack-dev-server' from file 'c:/Users/Kelvin/Documents/Workspaces/NPM/vscode-sshfs/webview/webpack.config.js' with packageId '@types/webpack-dev-server/index.d.ts@3.11.5'
    Root file specified for compilation
    Root file specified for compilation ts(1261)

For comparsion:
C:/Users/Kelvin/AppData/Local/Microsoft/TypeScript/4.3/node_modules/@types/webpack-dev-server/index.d.ts
c:/Users/Kelvin/AppData/Local/Microsoft/TypeScript/4.3/node_modules/@types/webpack-dev-server/index.d.ts

Weirdly enough, in my case the cause was that I had the mentioned index.d.ts open in VS Code which actually used C:/, while the in-code version (including other dependencies) use c:/ as path. Just a weird IDE issue for me, but perhaps worth mentioning.

@Ellean
Copy link

Ellean commented Aug 18, 2021

Just reload the window.
shift + comman(macOS)/alt (windows) + P
reload window

@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 18, 2021
@RyanCavanaugh
Copy link
Member

This is turning into a support thread but this is not a support forum.

If you have a reproducible specific defect, please file a new issue following the template.

If you have a configuration problem, please use an appropriate support forum such as StackOverflow or Discord.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.