-
Notifications
You must be signed in to change notification settings - Fork 56
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
Elm-analyse fails with Cannot find module
error.
#218
Comments
It looks like it is failing in the |
Yes
And here is list of all files I have in my project:
|
I'm having the same problem. Fresh install, basic project made from the tutorial. I'm on Windows 10. Where/why/how is it expecting to get these files? elm-stuff/packages/elm/core/1.0.4/elm.json Is it trying to download? Does it need proxy setup? |
It looks like... In elm-analyse\dist\app\util\file-gatherer.js function getDependencyFiles(directory, dep) {
var depPath = directory + "/elm-stuff/packages/" + dep.name + "/" + dep.version;
var depPackageFile = require(depPath + '/elm.json');
var unfilteredTargetFiles = targetFilesForPathAndPackage(directory, depPath, depPackageFile);
var exposedModules = depPackageFile['exposed-modules'].map(function (x) {
return _path.normalize('/' + x.replace(new RegExp('\\.', 'g'), '/') + '.elm');
});
return unfilteredTargetFiles.filter(function (x) {
return exposedModules.filter(function (e) { return lodash_1.default.endsWith(x, e); })[0];
});
} Instead of grabbing from I'll try overriding this. |
So now with a shimmy: function getDependencyFiles(directory, dep) {
var elm_version = "0.19.1"; // <-- this is really bad
var depPath = process.env.APPDATA + "/elm/"+elm_version+"/packages/" + dep.name + "/" + dep.version; // directory var useless
var depPackageFile = require(depPath + '/elm.json');
var unfilteredTargetFiles = targetFilesForPathAndPackage(directory, depPath, depPackageFile);
var exposedModules = depPackageFile['exposed-modules'].map(function (x) {
return _path.normalize('/' + x.replace(new RegExp('\\.', 'g'), '/') + '.elm');
});
return unfilteredTargetFiles.filter(function (x) {
return exposedModules.filter(function (e) { return lodash_1.default.endsWith(x, e); })[0];
});
} I get: Which makes sense, because you can't use "exposed-modules": {
"Primitives": [
"Basics",
"String",
"Char",
"Bitwise",
"Tuple"
],
"Collections": [
"List",
"Dict",
"Set",
"Array"
],
"Error Handling": [
"Maybe",
"Result"
],
"Debug": [
"Debug"
],
"Effects": [
"Platform.Cmd",
"Platform.Sub",
"Platform",
"Process",
"Task"
]
} Is elm-analyse far too outdated for elm 0.19? It's expecting an array where an object lives now. |
Anyone have a repo that reproduces this issue? Elm Analyse does work with 0.19, we use 0.19.1 in the project at work and it is working in there. |
On my home machine now. Works just fine there. Of note, getDependencyFiles doesn't even appear to ever be called on this setup. So a hunt for what logic calls gDF might help us track it down. |
More accurately, seems to be something to do with |
https://github.com/akhilman/elm-counter - repository that causes error for me. |
I don't even need a Main.elm @akhilman Are you behind a proxy? Looking at this... (src/Analyser/Files/DependencyLoader.elm) : OnOnlineDocs result ->
case result of
Nothing ->
( model, Cmd.none )
Just (Err _) ->
( { model | state = RawDiskLoading }
, DependencyHandler.loadDependencyFiles model.dependency
)
Just (Ok decodedDependency) ->
( { model | state = Done decodedDependency }
, Cmd.batch
[ DependencyHandler.storeToDisk decodedDependency
, Logger.info ("Loaded " ++ model.dependency.name ++ " from package.elm-lang.org")
]
) Here's my guess... When Looks like the idea is, "If we can't get the docs online, grab them offline from the ones we already got." Seems to miss the case where you can't grab docs online BEFORE you could ever get them in the first place, resulting in our exception. What causes OnOnlineDocs to have a failure? I'm going to guess it might be trying to download something, as I first theorized, and for my machine behind an incredibly finnicky proxy at least, that may be causing it to fail. I'll keep looking. Slowly. I am trying to learn Elm and got snagged here while doing the tutorial. Guess this is a crash course.. :) |
No. I'm not. But here in Russia we have a lot of IP banned and elm may hit some of them. |
but I can't get much further here. I don't understand what occurs in what order: -- This.. (loadOnlineDocumentation)?
Failed ->
( { model | state = LoadingOnlineDocs }
, DependencyHandler.loadOnlineDocumentation model.dependency
)
-- Or this (onOnlineDocumentation)?
LoadingOnlineDocs ->
DependencyHandler.onOnlineDocumentation model.dependency
|> Sub.map OnOnlineDocs I presume once the state is changed, the latter piece is fired. But why does it seem to be doing the same work as the former? Or is the latter only called on init..?? The latter is what causes our error, presumably, so why is it favored over the former? Or what's the purpose of the former? Very confusing. Or is the former what loads the docs, which then triggers onOnlineDocumentation, which then triggers Sub.map OnlineDocs...? I can't tell. Don't know the lang well enough. @akhilman our best lead is that it has something to do with a network problem, then. @antew could you help me understand this code when you have some time? I'll try to see if I can replicate this in a docker container after routing online docs to localhost or something. |
CONFIRMED.
apt update -y && apt install curl npm -y
npm install -g npm
cd ~/ && curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
gzip -d elm.gz
chmod +x elm
mv elm /usr/local/bin/
mkdir elmproj && cd elmproj/
elm init
npm install -g elm-analyse
echo "172.0.0.1 package.elm-lang.org elm-lang.org" >> /etc/hosts
elm-analyse Replicates the exception on a 'normal' system. See:
I cause an error with a timeout here. I think on my work computer, it's an SSL or proxy error. You match Err _ so it takes 'em all. Also worth noting is that you get no info about the package info failing to fetch. |
Also found aliases in my shell settings that was added when package.elm-lang.org was blacklisted: Today package.elm-lang.org can be accessed without proxy. |
I can get it to perform correctly at work if I set Now getting VSCode to do that for the tooling is a different matter altogether..... Looks like my workaround for now will be to run |
At the very least, I would suggest that OnOnlineDocs result ->
case result of
Nothing ->
( model, Cmd.none )
Just (Err _) ->
( { model | state = RawDiskLoading }
, DependencyHandler.loadDependencyFiles model.dependency
) Be changed such that the network error underlying it all is logged to the console. |
I have a project with the code from Elm’s tutorial.
Code itself compiles and works great, elm-format also works well. But elm-language-server and elm-analyse fails with same error:
As I figured out all modules located in local cache inside ~/elm directory. How I can make elm-analyse load modules form local cache?
Environment:
installed globally with yarn
[email protected]
@elm-tooling/[email protected]
[email protected]
[email protected]
installed with system package manager
node v10.16.3
The text was updated successfully, but these errors were encountered: