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

Wrong behavior if --outDir is a prefix of project dir #3274

Closed
njlr opened this issue Nov 16, 2022 · 3 comments · Fixed by #3279
Closed

Wrong behavior if --outDir is a prefix of project dir #3274

njlr opened this issue Nov 16, 2022 · 3 comments · Fixed by #3279

Comments

@njlr
Copy link
Contributor

njlr commented Nov 16, 2022

Description

A simple project layout like so:

./fable_src
├── fable.fsproj
└── Program.fs

When compiling like this:

dotnet fable fable_src/fable.fsproj --verbose --outDir fable --extension .fs.js --noRestore --noCache

The transpiled file Program.fs.js appears in fable_src instead of fable.

Repro code

Please see this repo: https://github.com/njlr/fable-out-dir-repro

The GitHub Action demonstrates the issue.

Expected and actual results

I would expect the transpiled file to be in the --outDir, so fable/Program.fs.js

Instead it appears under the source directory at fable_src/Program.fs.js

The _ in fable_src may be a significant factor.

Related information

  • Fable version: 3.7.20
  • Operating system: Ubuntu 22.04
@alfonsogarciacaro
Copy link
Member

Oh, thanks a lot for providing the code, I can indeed reproduce. Still unsure why, but it seems the problem is using fable exactly as --outDir. If you pass something like fable_build or build/fable instead it will work.

I will try to find what's causing the problem exactly. I remember we had a similar issue in the past and had to "ban" some outDirs like "bin", maybe we need to add "fable" to the list 😅

@njlr
Copy link
Contributor Author

njlr commented Nov 19, 2022

I think it might be when the output directory is a prefix of the source directory - in this case "fable"

@alfonsogarciacaro
Copy link
Member

You're right! 👀 The problem also happens when using fable_s as outDir. Probably this means we need to fix the algorithm to find the common base dir 👍

@alfonsogarciacaro alfonsogarciacaro changed the title Problem with --outDir Wrong behavior if --outDir is a prefix of project dir Nov 20, 2022
alfonsogarciacaro added a commit that referenced this issue Nov 20, 2022
alfonsogarciacaro added a commit that referenced this issue Nov 23, 2022
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

Successfully merging a pull request may close this issue.

2 participants