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

Strange build behaviour building TypeScript from VSCode with Node v6 on Windows #6719

Closed
yortus opened this issue May 24, 2016 · 20 comments
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) tasks Task system issues
Milestone

Comments

@yortus
Copy link

yortus commented May 24, 2016

  • VSCode Version: 1.1.1
  • OS Version: Windows 7, Windows 10

Steps to Reproduce:

See https://github.com/yortus/repro-build-bug for full repro details and a cut-down project.

From the README:

Bug Repro

Problem Description

  • Building a project with Shift+Ctrl+B puts some built files in the wrong location

Environment

  • O/S: Windows 7 and Windows 10
  • VSCode: v1.1.1
  • Node.js: v6.2
  • TypeScript: v1.9.0-dev.20160524-1.0

Steps to Reproduce

Project setup
  1. git clone https://github.com/yortus/repro-build-bug.git
  2. cd repro-build-bug
  3. npm install
Baseline build/run (this should work fine)
  1. Open a command prompt
  2. Build from the command prompt using npm run build
    • should be no errors, and /built will contain built .js files
  3. Run from the command prompt using node .
    • should be no errors, outputs "Hello, World!" to console
VSCode build/run (this should repro the bug)
  1. Open the project folder in VSCode
  2. Delete the /built directory created in the previous steps
  3. Build from VSCode by pressing Shift+Ctrl+B
    • should be no errors, but one .js file is output to /built and the other to /src
  4. Run from the command prompt using node .
    • should show an error "cannot find module..." because of the wrong placement of built files

Further Notes

  • Bug could not be reproduced on linux
  • Bug could not be reproduced with node v4 or v5.
  • Bug goes away if "options": {"cwd": "<absolute project path>"} is added to .vscode/tasks.json
@dbaeumer dbaeumer added tasks Task system issues bug Issue identified by VS Code Team member as probable bug labels May 24, 2016
@dbaeumer dbaeumer added this to the June 2016 milestone May 24, 2016
@yortus
Copy link
Author

yortus commented Jun 7, 2016

Update: Executing npm run build using the new integrated terminal in VSCode 1.2 also puts some built files in the wrong location. Seems to be the same odd behaviour as building from tasks.json.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2016

@yortus trying this from the command line results in the following error for me:

error TS5009: Cannot find the common subdirectory path for the input files.

Interestingly I frist tried this under node version 5.10.0 and there it worked in both command line and VS Code.

Do you see the same error in the console ?
bug

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2016

The task frameworks sets cwd to the workspace folder by default if not provided. So I don't understand why setting it explicitly makes it work. Need to investigate.

@yortus
Copy link
Author

yortus commented Jun 7, 2016

@dbaeumer I don't get TS5009, the build runs successfully for me. I had a colleague repeat the repro steps on his machine and he has the same results as I've written up in the OP.

I don't have tsc installed globally, not sure if that makes a difference?

@yortus
Copy link
Author

yortus commented Jun 7, 2016

I've just followed the repro steps on another machine (Windows 10, Node 6.2, VSCode 1.1) and got the same results again. Repros consistently for me so far on three machines now.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2016

I do have tsc installed globally. Will uninstall and try again.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2016

Using the local installed tsc produces the same TS error for me.

P:\mseng\VSCode\Playgrounds\bugs\repro-build-bug>.\node_modules\.bin\tsc.cmd -p src
error TS5009: Cannot find the common subdirectory path for the input files.

No idea what makes the difference here.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2016

When I change tsconfig.json to:

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "outDir": "../built",
        "rootDir": "../src"
    }
}

and compile using

.\node_modules\.bin\tsc.cmd -p src

I get

error TS5009: Cannot find the common subdirectory path for the input files.
error TS6059: File 'C:/Users/dirkb/Projects/mseng/VSCode/Playgrounds/bugs/repro-build-bug/src/other/thing.ts' is not under 'rootDir' 'P:/mseng/VSCode/Playgrounds/bugs/repro-build-bug/src'. 'rootDir' is expected to contain all source files.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 7, 2016

Using tsc version 1.8.10 works without any problem.

@yortus
Copy link
Author

yortus commented Jun 7, 2016

Yep, TS1.8 works fine for me too. I can only repro the problem with ts@next (it repros with today's nightly build for me).

I can't get a TS5009 however I try, nor would I expect a TS5009 for such a trivial project structure where the two source files clearly share the common root src/.

Could you try expanding out the build script inside package.json to the equivalent long form:

tsc --target es6 --module commonjs --outdir built src/index.ts src/other/thing.ts

That repros the same error for me.

@yortus
Copy link
Author

yortus commented Jun 8, 2016

I've just repro'd this on another different machine (Windows 7). This was a clean machine, I had to install Node, GIT and VSCode. Behaves exactly as described in OP.

Is it possible the TS5009 error you get is somehow related to the bug? The problem is path confusion after all. And clearly the two files src/index.ts and src/other/thing.ts have the common root src/, so the TS5009 is very strange and suspicious.

I mean, how else could you structure a two-file project, with one file nested in a subdirectory, if tsc can't work out the common root? Do you still get TS5009 on your machine if you run tsc index.ts subdir/index.ts in a fresh directory with those files created?

@yortus
Copy link
Author

yortus commented Jun 8, 2016

A clue... in index.ts, if I comment out the import Thing... and let thing... lines, and then build in VSCode with Shift+Ctrl+B, both built files are correctly placed under ../built.

@Seikho
Copy link

Seikho commented Jun 9, 2016

This may be an issue in TypeScript instead. I've tracked the issue down to microsoft/TypeScript@cd1af12
I've narrowed the issue down further in microsoft/TypeScript#8837

@yortus
Copy link
Author

yortus commented Jun 9, 2016

I think @Seikho is onto something in this comment.

If I add "options": {"cwd": "V:/temp/repro-build-bug"} to my tasks.json (that's my project directory), the problem goes away and the build works normally. But if I lower-case the drive letter (so, "options": {"cwd": "v:/temp/repro-build-bug"}), then the build bug reoccurs.

@yortus
Copy link
Author

yortus commented Jun 9, 2016

@dbaeumer are you using symlinks? The commit referenced by @Seikho affects symlink behaviour, and you reported getting an error like:

error TS6059: File 'C:/.../src/other/thing.ts' is not under 'rootDir' 'P:/.../src'. 'rootDir' is expected to contain all source files.

...which looks like a symlink expanded in one place but not in another.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 9, 2016

@yortus @Seikho very good insights.

I am not using symlinks. I use subst to create a new drive letter that points into my C-Drive. E.g. P:\ => 'C:/Users/dirkb/Projects. I should have spotted that in the error message as well.

Regarding setting the cwd as pointed out in comment #6719 (comment): VS Code by default sets the cwd to the workspace folder. However we set the cwd with a lower case drive letter.

@dbaeumer
Copy link
Member

dbaeumer commented Jun 9, 2016

On top of that there seems to be issue with drive letter in node 6.x: See nodejs/node#6624.

@yortus @Seikho any objection to close this issue. IMO there is little VS Code can do here. The fix should be on TS side to deal correctly with drive letter casing. We internally consistently make it lower case when normalizing paths.

@yortus
Copy link
Author

yortus commented Jun 9, 2016

@dbaeumer agreed - will follow up in Microsoft/TypeScript#8837.

@Seikho
Copy link

Seikho commented Jun 9, 2016

I was just writing a post that came to the same conclusion. Thanks @dbaeumer

@dbaeumer
Copy link
Member

dbaeumer commented Jun 9, 2016

Closing in favour of microsoft/TypeScript#8837

@dbaeumer dbaeumer closed this as completed Jun 9, 2016
@bpasero bpasero added *duplicate Issue identified as a duplicate of another issue(s) and removed bug Issue identified by VS Code Team member as probable bug labels Sep 2, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) tasks Task system issues
Projects
None yet
Development

No branches or pull requests

4 participants