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

.nuget/packages/fable.elmish.browser/0.9.0/fable/prelude.fs" is not in the SourceMap #43

Closed
aolney opened this issue Nov 1, 2017 · 21 comments

Comments

@aolney
Copy link
Contributor

aolney commented Nov 1, 2017

Oddly this template was working ~2 weeks ago, but now fails with this error. I've tried blowing away the .nuget directory, node_modules, npm cache, and downgrading node.

aolney@monkmonk:/z/aolney/repos/awesome/src$ dotnet fable yarn-run start
Fable (1.2.4) daemon started on port 61225
CWD: /z/aolney/repos/awesome
yarn run start
yarn run v1.2.1
$ webpack-dev-server
Bundling for development...
Project is running at http://localhost:8080/
webpack output is served from /
Content not from webpack is served from /z/aolney/repos/awesome/public
Parsing ./awesome.fsproj...
fable: Compiled src/awesome.fsproj
fable: Compiled src/App.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish/0.9.2/fable/program.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.browser/0.9.0/fable/navigation.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.debugger/0.9.0/fable/debugger.fs
fable: Compiled src/Types.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.hmr/1.0.0/fable/hmr.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish/0.9.2/fable/cmd.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.react/0.9.0/fable/react.fs
fable: Compiled src/CounterList/View.fs
fable: Compiled src/Navbar/View.fs
fable: Compiled src/State.fs
fable: Compiled src/Home/View.fs
fable: Compiled src/Counter/View.fs
fable: Compiled src/Info/View.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.react/1.2.1/fable/Fable.Helpers.React.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.browser/0.9.0/fable/parser.fs
fable: Compiled src/Counter/State.fs
fable: Compiled src/Home/State.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.react/0.9.0/fable/common.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.debugger/0.9.0/fable/Fable.Import.RemoteDev.fs
fable: Compiled src/CounterList/State.fs
fable: Compiled src/CounterList/Types.fs
fable: Compiled src/Home/Types.fs
fable: Compiled src/Counter/Types.fs
fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.browser/0.9.0/fable/prelude.fs
/z/aolney/repos/awesome/node_modules/source-map/lib/source-map-consumer.js:704
      throw new Error('"' + aSource + '" is not in the SourceMap.');
      ^

Error: "/home/aolney/.nuget/packages/fable.elmish.browser/0.9.0/fable/prelude.fs" is not in the SourceMap.
    at SourceMapConsumer_sourceContentFor [as sourceContentFor] (/z/aolney/repos/awesome/node_modules/source-map/lib/source-map-consumer.js:704:13)
    at /z/aolney/repos/awesome/node_modules/source-map/lib/source-node.js:139:40
    at Array.forEach (native)
    at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/z/aolney/repos/awesome/node_modules/source-map/lib/source-node.js:138:32)
    at SourceMapSource.node (/z/aolney/repos/awesome/node_modules/webpack-sources/lib/SourceMapSource.js:39:21)
    at ReplaceSource.node (/z/aolney/repos/awesome/node_modules/webpack-sources/lib/ReplaceSource.js:70:30)
    at CachedSource.node (/z/aolney/repos/awesome/node_modules/webpack-sources/lib/CachedSource.js:18:24)
    at /z/aolney/repos/awesome/node_modules/webpack-sources/lib/ConcatSource.js:37:50
    at Array.map (native)
    at ConcatSource.node (/z/aolney/repos/awesome/node_modules/webpack-sources/lib/ConcatSource.js:36:63)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Closing Fable daemon...
aolney@monkmonk:/z/aolney/repos/awesome/src$
@MangelMaxime
Copy link
Member

I can't reproduce it.

Do you still have this error ?

@aolney
Copy link
Contributor Author

aolney commented Nov 28, 2017

It works now. I just upgraded Debian though, so that might have done something. Thanks!

@aolney aolney closed this as completed Nov 28, 2017
@MangelMaxime
Copy link
Member

I also updated the templates today so perhaps this helps too. Don't know

Happy to it solve 😊

@aolney
Copy link
Contributor Author

aolney commented Feb 17, 2018

I believe I figured out the problem. In my original post, you'll see the repo was located on my local drive at /z/aolney/repos/awesome. That folder is on a different filesystem than /home/aolney/.nuget. In other words, I have my root filesystem / on a partition, z on another partition, and then in my fstab I mount z onto / to get /z.

When I follow the install/build instructions for yarn AND I'm in my /home directory, it works as expected.

However, when I'm in /z/aolney/repos, then I receive the original reported error. It appears that somewhere in the build process the absolute filepath /home/aolney gets prepended with ../../../.. which is actually one level off.

So there are two apparent ways to solve this:

  1. Force compilation to use the absolute path, e.g. fable: Compiled ../../../../home/aolney/... becomes fable: Compiled /home/aolney/...

  2. Correct the relative path used in compilation (in my case adding an extra parent), e.g. fable: Compiled ../../../../home/aolney/... becomes fable: Compiled ../../../../../home/aolney/...

I'm happy to submit a PR for this, but I don't know where to start. A quick search around the repo doesn't clear this up, and I've used base fable templates in /z and not had this problem, so I don't think it is an issue with fable.

@aolney aolney reopened this Feb 17, 2018
@MangelMaxime
Copy link
Member

Are the others fable templates you used using storage: none setting for paket ?
https://github.com/fable-elmish/templates/blob/master/src/react/Content/paket.dependencies#L3

@alfonsogarciacaro
Copy link
Contributor

Just to let you know, today I was actually thinking about a similar issue and for Fable 2 I'm planning to copy the sources of referenced Fable libraries (as well as fable-core JS files) to a .fable folder within the project directory to prevent this and other related problems.

@aolney
Copy link
Contributor Author

aolney commented Feb 18, 2018

@alfonsogarciacaro Thanks that sounds like it would help 👍

@MangelMaxime Yes other templates I'm using successfully have storage:none. I tried commenting out storage:none in the elmish project, rerunning mono .paket/paket.exe install, and then building, but I get the same error with relative paths like this:

fable: Compiled ../../../../home/aolney/.nuget/packages/fable.elmish.browser/1.0.0/fable/parser.fs

It doesn't seem like storage: none is affecting this behavior. Is there another setting that would?

@MangelMaxime
Copy link
Member

MangelMaxime commented Feb 18, 2018

I really don't know...

@alfonsogarciacaro Is it Fable or webpack who resolves the path of the files to parse ?

@alfonsogarciacaro
Copy link
Contributor

The issue with the new fsproj format is it doesn't matter whether you let Paket download packages locally, MSBuild is going to always reference the assemblies in the .nuget global cache. Fable uses Dotnet.ProjInfo which calls MSBuild and gets the paths for the packages in the .nuget cache. These are the paths that are passed to Webpack.

Hopefully copying the content of the fable folder of Fable packages to a local folder will fix these issues, as Webpack and other tools usually expect paths within the project directory.

@MangelMaxime
Copy link
Member

Thanks @alfonsogarciacaro for the explanations, so we will probably wait for Fable 2 and see if this solved the problems.

@aolney
Copy link
Contributor Author

aolney commented Feb 19, 2018

@alfonsogarciacaro Thanks for those insights. What's weird here is that the simple template works but the fable-elmish template does not. This makes me think there is some kind of configuration change that could be made to fable-elmish to get it to work. Unless perhaps you think that a change in dotnet-fable or related projects changed the behavior from 1.2.4 (what simple uses) to 1.3.3 (what fable-elmish uses)?

@alfonsogarciacaro
Copy link
Contributor

@aolney TBH, I don't know 😕 Can you use the workaround for now until Fable 2 is ready? (hopefully in a few weeks)

@aolney
Copy link
Contributor Author

aolney commented Feb 20, 2018

No problem, thanks to you and @MangelMaxime for everything you do

@dustinlacewell-wk
Copy link

I just ran into this issue trying to build SAFE-Chat project inside of a Docker Image https://hub.docker.com/r/dcurylo/paket/ with the following Dockerfile:

from dcurylo/paket

run curl -sL https://deb.nodesource.com/setup_6.x | bash -

run apt-get update && apt-get -y install build-essential libssl-dev nodejs

run npm i yarn npm5 -g

copy . /app

workdir /app

run yarn install

workdir /app/src/Client

run dotnet restore
run dotnet fable webpack -p

With the resulting error:

docker run -it --rm safe-chat
root@08848d65c1e7:/app/src/Client# dotnet fable webpack -p
Fable (1.3.4) daemon started on port 61225
CWD: /app/src/Client
node "/app/node_modules/webpack/bin/webpack.js"
Bundling for development...
Parsing ./client.fsproj...
fable: Compiled client.fsproj
fable: Compiled App.fs
fable: Compiled State.fs
fable: Compiled ../../../root/.nuget/packages/fable.websockets.elmish/0.1.1/fable/src/Elmish.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.debugger/1.0.1/fable/debugger.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish/1.0.1/fable/program.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.browser/1.0.0/fable/navigation.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.hmr/1.0.0/fable/hmr.fs
fable: Compiled NavMenu/View.fs
fable: Compiled Channel/View.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.react/1.0.0/fable/react.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish/1.0.1/fable/cmd.fs
fable: Compiled Chat/Types.fs
fable: Compiled Router.fs
fable: Compiled Types.fs
fable: Compiled Info/View.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.browser/1.0.0/fable/parser.fs
fable: Compiled Chat/State.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.react/1.0.0/fable/common.fs
fable: Compiled Channel/Types.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.debugger/1.0.1/fable/Fable.Import.RemoteDev.fs
fable: Compiled ../Shared/ChatProtocol.fs
fable: Compiled UserAvatar/View.fs
fable: Compiled ../../../root/.nuget/packages/fable.websockets.client/0.1.1/fable/src/Client.fs
fable: Compiled ../../../root/.nuget/packages/fable.websockets.client/0.1.1/Shared/Protocol.fs
fable: Compiled ../../../root/.nuget/packages/fable.websockets.client/0.1.1/Shared/Observables.fs
fable: Compiled ../../../root/.nuget/packages/fable.react/1.2.2/fable/Fable.Helpers.React.fs
fable: Compiled ../../../root/.nuget/packages/fable.elmish.browser/1.0.0/fable/prelude.fs
fable: Compiled Channel/State.fs
/app/node_modules/source-map/lib/source-map-consumer.js:704
      throw new Error('"' + aSource + '" is not in the SourceMap.');
      ^

Error: "/root/.nuget/packages/fable.elmish.browser/1.0.0/fable/prelude.fs" is not in the SourceMap.
    at SourceMapConsumer_sourceContentFor [as sourceContentFor] (/app/node_modules/source-map/lib/source-map-consumer.js:704:13)
    at /app/node_modules/source-map/lib/source-node.js:139:40
    at Array.forEach (native)
    at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/app/node_modules/source-map/lib/source-node.js:138:32)
    at SourceMapSource.node (/app/node_modules/webpack-sources/lib/SourceMapSource.js:39:21)
    at ReplaceSource.node (/app/node_modules/webpack-sources/lib/ReplaceSource.js:70:30)
    at CachedSource.node (/app/node_modules/webpack-sources/lib/CachedSource.js:18:24)
    at /app/node_modules/webpack-sources/lib/ConcatSource.js:37:50
    at Array.map (native)
    at ConcatSource.node (/app/node_modules/webpack-sources/lib/ConcatSource.js:36:63)
    at /app/node_modules/webpack-sources/lib/ConcatSource.js:37:50
    at Array.map (native)
    at ConcatSource.node (/app/node_modules/webpack-sources/lib/ConcatSource.js:36:63)
    at /app/node_modules/webpack-sources/lib/ConcatSource.js:37:50
    at Array.map (native)
    at ConcatSource.node (/app/node_modules/webpack-sources/lib/ConcatSource.js:36:63)
    at /app/node_modules/webpack-sources/lib/ConcatSource.js:37:50
    at Array.map (native)
    at ConcatSource.node (/app/node_modules/webpack-sources/lib/ConcatSource.js:36:63)
    at ConcatSource.proto.sourceAndMap (/app/node_modules/webpack-sources/lib/SourceAndMapMixin.js:30:18)
    at CachedSource.sourceAndMap (/app/node_modules/webpack-sources/lib/CachedSource.js:56:31)
    at getTaskForFile (/app/node_modules/webpack/lib/SourceMapDevToolPlugin.js:33:30)
    at chunk.files.forEach.file (/app/node_modules/webpack/lib/SourceMapDevToolPlugin.js:91:21)
    at Array.forEach (native)
    at /app/node_modules/webpack/lib/SourceMapDevToolPlugin.js:89:18
    at Array.forEach (native)
    at Compilation.<anonymous> (/app/node_modules/webpack/lib/SourceMapDevToolPlugin.js:88:12)
    at Compilation.applyPlugins1 (/app/node_modules/tapable/lib/Tapable.js:75:14)
    at self.applyPluginsAsync.err (/app/node_modules/webpack/lib/Compilation.js:670:11)
    at Compilation.applyPluginsAsyncSeries (/app/node_modules/tapable/lib/Tapable.js:195:46)
Closing Fable daemon...

@aolney
Copy link
Contributor Author

aolney commented Mar 5, 2018

@dustinlacewell-wk is /app/src/Client under /root? The workaround worked for me when my project folder was under /home/$USER

@dustinlacewell-wk
Copy link

OK this indeed worked.

@aolney
Copy link
Contributor Author

aolney commented Nov 22, 2018

This bit me again today 😜

@alfonsogarciacaro
Copy link
Contributor

Maybe resolve: { symlinks: false } needs to be added to the Webpack config? fable-compiler/Fable#1490 (comment)

@aolney
Copy link
Contributor Author

aolney commented Nov 23, 2018

Thanks for that suggestion - it doesn't seem to help, but it did lead me to something else! I think I've figured out how to reproduce and repair the problem (but not the underlying cause).

Basically the problem seems to be created by passing in a hyphenated project name when using the template, e.g. awesome-test in:

dotnet new fable-elmish-react -n awesome-test -lang f#

Compiling in VsCode with dotnet fable npm-start will then yield the known error (#7):

ERROR in multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/awesome_test.fsproj
Module not found: Error: Can't resolve '/z/temp-junk/awesome-test/src/awesome_test.fsproj' in '/z/temp-junk/awesome-test'
 @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/awesome_test.fsproj

because the fsproj name has been made with an underscore instead of a hyphen. Fixing then by renaming awesome-test.fsproj to awesome_test.fsproj in VsCode, followed by a dotnet restore reproduces the throw new Error('"' + aSource + '" is not in the SourceMap.'); error.

I can "repair" the project by renaming all hypenated names and underscore names in all files to a variant with neither, e.g. awesome-test to awesometest, removing node_modules and src/obj, and then reinitializing everything.

The bug seems to possibly be a new variant of dotnet/templating#402 and not a bug in Elmish.

@aolney aolney closed this as completed Nov 23, 2018
@alfonsogarciacaro
Copy link
Contributor

Ah, yeah, it seems there's a note about that in the README but it's easy to miss. Quite annoying behavior of dotnet templates, they should fail instead of replacing characters silently :/

@aolney
Copy link
Contributor Author

aolney commented Nov 23, 2018

Agreed 👍 I saw that note in the README but thought just renaming the fsproj would repair. It's quite sneaky that it only repairs when you are on /home and that more drastic measures are needed when you are on another drive.

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

No branches or pull requests

4 participants