Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Failed to load the line-diff-details package #45

Open
mattdiamond opened this issue Oct 9, 2017 · 14 comments
Open

Failed to load the line-diff-details package #45

mattdiamond opened this issue Oct 9, 2017 · 14 comments

Comments

@mattdiamond
Copy link

Atom: 1.21.0 x64
Electron: 1.6.9
OS: Mac OS X 10.12.6
Thrown From: line-diff-details package 1.9.0

Stack Trace

Failed to load the line-diff-details package

At ENOENT, node_modules/typescript/bin/lib.d.ts not found in /Applications/Atom.app/Contents/Resources/app.asar

Error: ENOENT, node_modules/typescript/bin/lib.d.ts not found in /Applications/Atom.app/Contents/Resources/app.asar
    at notFoundError (ELECTRON_ASAR.js:115:19)
    at Object.fs.readFileSync (ELECTRON_ASAR.js:514:9)
    at TypeScriptSimple.createService (/Applications/Atom.app/Contents/Resources/app/node_modules/typescript-simple/index.js:71:73)
    at TypeScriptSimple.compile (/Applications/Atom.app/Contents/Resources/app/node_modules/typescript-simple/index.js:60:43)
    at Object.exports.compile (/Applications/Atom.app/Contents/Resources/app/src/typescript.js:54:53)
    at Object.compile (/Applications/Atom.app/Contents/Resources/app/src/package-transpilation-registry.js:79:33)
    at compileFileAtPath (/Applications/Atom.app/Contents/Resources/app/src/compile-cache.js:97:37)
    at Object.value [as .ts] (/Applications/Atom.app/Contents/Resources/app/src/compile-cache.js:238:26)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (/app.asar/static/index.js:47:45)
    at require (internal/module.js:20:19)
    at customRequire (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:96:26)
    at Package.module.exports.Package.requireMainModule (/Applications/Atom.app/Contents/Resources/app/src/package.js:903:35)
    at /Applications/Atom.app/Contents/Resources/app/src/package.js:158:34
    at Package.module.exports.Package.measure (/Applications/Atom.app/Contents/Resources/app/src/package.js:99:21)
    at Package.module.exports.Package.load (/Applications/Atom.app/Contents/Resources/app/src/package.js:144:18)
    at PackageManager.loadAvailablePackage (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:617:16)
    at config.transact (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:530:20)
    at Config.module.exports.Config.transact (/Applications/Atom.app/Contents/Resources/app/src/config.js:342:22)
    at PackageManager.loadPackages (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:528:23)
    at /Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:821:34

Commands

  8x -0:11.3.0 core:copy (atom-notification.fatal.icon.icon-bug.native-key-bindings.has-detail.has-close.has-stack)

Non-Core Packages

line-diff-details 1.9.0 
@mattdiamond
Copy link
Author

Seeing something similar here:

smhxx/atom-ts-transpiler#8 (comment)

@smhxx
Copy link

smhxx commented Oct 12, 2017

I'm able to repro this on 1.21.0 as well. Haven't checked on previous versions, but from what we've deduced, this has to do with the built-in TypeScript support that Atom has, which utilizes typescript-simple =1.0.0, which in turn depends on typescript ~1.4.1. The location of the core library definitions was moved from bin/ to lib/ somewhere between TypeScript 1.4 and 1.5, which means that typescript-simple is unable to find the core library defs (lib.d.ts) when installed with the most recent version of TypeScript matching ~1.4.1. In other words, Atom's built-in TypeScript support is essentially broken, and when it sees lib/line-diff-details.ts, it tries to transpile it, but the definitions it needs aren't where it expects them, and boom, error.

There are probably a few equally-valid ways of fixing this:

  • Switch lib/line-diff-details.ts from TypeScript to JavaScript, optionally with a "use babel"; directive to enable newer JavaScript features
  • Compile the TypeScript prior to publishing with apm, and set the "main" file in package.json to the compiled JavaScript output
  • Continue to publish the package in TypeScript, but specify a custom transpiler to handle the TS->JS conversion on install/first run by the user (full disclosure: The only one of these that currently exists for TypeScript is the one I wrote, which @mattdiamond linked above, available as atom-ts-transpiler on npm.)

Just as a fore-warning if you decide to go with the third approach, atom-ts-transpiler is theoretically stable, but still very new, and I'm currently working on getting it field-tested with the help of a few collaborators. As I've dealt with this problem before, (hence writing a package to work around the issue,) I'm around to help out if you need any assistance. 😃

@smhxx
Copy link

smhxx commented Oct 13, 2017

(btw, I've just checked and confirmed that line-diff-details does load and run with no issues using atom-ts-transpiler 1.2.0 and typescript 2.5.3, if that's a route you end up wanting to go) 👍 It's probably overkill for such a small package, and could be easier resolved by just switching the main file from .ts to .js or .coffee, but like I said, it's one of several options.

@robiXxu
Copy link

robiXxu commented Oct 13, 2017

Also in Windows 10.

@exside
Copy link

exside commented Oct 16, 2017

+1

@mattdiamond
Copy link
Author

In other words, Atom's built-in TypeScript support is essentially broken

Is there an open issue or pull request to resolve this?

@smhxx
Copy link

smhxx commented Oct 16, 2017

I'm not aware of one, but I haven't checked. It's a pretty simple fix since the bug is just due to a backwards-incompatible change being pushed out in a patch version instead of a major version (although I don't think the TypeScript maintainers realized that typescript-simple was relying directly on the lib.d.ts file, so they wouldn't have known moving it would break anything.)

I think it should just require bumping Atom's dependency on typescript-simple from 1.0.0 (which is now broken) to any version that uses TypeScript 1.5 or later. It should probably not be 2.x, though, since that has the potential to leave some packages already using TS just as broken as they were before.

@mberrueta
Copy link

+1

  • Atom: 1.22.1
  • Atom-Shell:
  • OS: Mac OS X 10.13.1
  • Misc
    • apm 1.18.8
    • npm 3.10.10
    • node 6.9.5 x64
    • python 2.7.10
    • git 2.13.6

@smhxx
Copy link

smhxx commented Nov 30, 2017

Since this problem appears to be ongoing, I suppose it's worth mentioning the official response from one of the Atom devs at atom/atom#15909 (thanks to @mattdiamond for opening that issue)

@capaj
Copy link

capaj commented Feb 2, 2018

@smhxx I just ran into this bug this morning. It sure would be nice to get this fixed.

I am on ubuntu 17.10 atom 1.23.3 x64

@cdbattags
Copy link

This still ain't fixed? 😜

What can I do to help? Are we waiting on another repo to get updated? Can we enact a temp fix and repair back to the proper Atom way when the dep lib gets patched?

@grizzlydotweb
Copy link

hoping for some good news soon. Exactly the package i was lookng for, but during install I end up here. 🙈

@smhxx
Copy link

smhxx commented Mar 20, 2018

There is a PR open which fixes this bug (#46) but it has changes requested and the author has not updated it yet. If needed, I can open a separate PR so that we can get this package working again, as it's been quite a while and it seems that several people are waiting for it to be fixed.

smhxx added a commit to smhxx/line-diff-details that referenced this issue Mar 20, 2018
This patch adds atom-ts-transpiler and TypeScript as dependenies,
circumventing the issues that have been occuring in recent versions
of Atom where TypeScript source files would fail to be loaded.

Closes jakesankey#45, jakesankey#46.
smhxx added a commit to smhxx/line-diff-details that referenced this issue Mar 20, 2018
This patch adds atom-ts-transpiler and TypeScript as dependenies,
circumventing the issues that have been occuring in recent versions
of Atom where TypeScript source files would fail to be loaded.

Closes jakesankey#45, jakesankey#46.
@emanuelegissi
Copy link

Replacing line-diff-details with line-diff-details-plus solves the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants