avh4 / elm-upgrade

Upgrade Elm projects

Home Page:https://www.npmjs.com/package/elm-upgrade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

erroneous message: cannot connect to package.elm-lang.org (and ENOENT: no such file or directory)

jarcane opened this issue · comments

Trying to upgrade a small elm project on Windows 10 and it's failing, seemingly because it fails to connect to the package server. I can ping the URL and visit it just fine, so I'm not sure this is actually a problem on the server end. It also seems to have an issue writing logs.

Stacktrace:

INFO: Found elm at C:\Users\jarca\scoop\apps\nodejs\current\bin\elm.CMD
{ Error: ENOENT: no such file or directory, open 'C:\projects\elm-dice\elm-upgrade-2018-09-03T08:32:00.589Z.log'
    at Object.fs.openSync (fs.js:660:18)
    at logFile (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:62:20)
    at logMessage (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:69:3)
    at logInfo (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:78:3)
    at findBinary (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:154:3)
    at main (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:203:13)
    at C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:511:7
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\projects\\elm-dice\\elm-upgrade-2018-09-03T08:32:00.589Z.log' }
ERROR: Unable to connect to https://package.elm-lang.org.  Please try again later.
(node:288684) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\projects\elm-dice\elm-upgrade-2018-09-03T08:32:00.593Z.log'
    at Object.fs.openSync (fs.js:660:18)
    at logFile (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:62:20)
    at logErrorMessage (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:74:3)
    at logError (C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:86:3)
    at C:\Users\jarca\scoop\persist\nodejs\bin\node_modules\elm-upgrade\upgrade.js:515:7
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
(node:288684) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:288684) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Ah, it looks like this is a mistake in the error handling -- I think there's actually no problem connecting to package.elm-lang.org, but there is another error being thrown, and that message is mistakenly printed.

It looks like the real error here is that it can't open the log file it's trying to write: ENOENT: no such file or directory, open 'C:\projects\elm-dice\elm-upgrade-2018-09-03T08:32:00.589Z.log'

I assume you have write access to that folder?, so something must be wrong with the code for opening files on Windows.

Can someone try the following in nodejs in Windows and see if it fails? (And if it does, can you figure out how to make it work?)

// First delete `test.log` if it exists in the current directory
// Then run the following in `node`:
var fs = require('fs');
var fd = fs.openSync("test.log", "ax");
fs.writeSync(fd, "hello");
fs.closeSync(fd);

@avh4 I actually tried running it in Administrator mode even just to rule out rights issues, but I get the same error.

Running your snippet in node I get the expected file output with no errors.

Ah, I'm guessing it's the : characters in the log file's name. Does this fail on Windows?

var fs = require('fs');
var fd = fs.openSync("test-00:00.log", "ax");
fs.writeSync(fd, "hello");
fs.closeSync(fd);

If that indeed was the root cause, then it's fixed in elm-upgrade@0.19.4

@avh4 The snippet runs without error, but the resulting filename truncates after the :, so it just outputs test-00.

However I'm unable to install the update now. On both Win and WSL/Ubuntu I get an error: ENOENT: no such file or directory, chmod '/usr/lib/node_modules/elm-upgrade/upgrade.js'

I've made a gist of the full logs: https://gist.github.com/jarcane/cd197f272c287a5f024ab7a301362bb3

@jarcane the new problem you ran into was fixed in #63 with elm-upgrade@0.19.6