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

Fix some package detections #100

Merged
merged 8 commits into from
Nov 18, 2015
Merged

Fix some package detections #100

merged 8 commits into from
Nov 18, 2015

Conversation

50Wliu
Copy link
Contributor

@50Wliu 50Wliu commented Nov 3, 2015

⚠️ Sorta-kinda depends on atom/atom#9440, which has not been released yet ⚠️

This fixes the following scenarios:

  • A package fails to load and throws a "Failed to load the package" error
  • A package fails to activate and throws a "Failed to activate the package" error
  • A grammar fails to load and throws a "Failed to load a package grammar" error
  • A package that has been apm linked on a Windows machine throws an error

All of those would previously fail to find the correct package to report the issue to and so they were all dumped to atom/atom.

Refs #66
Fixes #98

@50Wliu
Copy link
Contributor Author

50Wliu commented Nov 3, 2015

Hmm. The linked package test was passing locally (also took me the longest to get working), but that was on Windows. I'll try to debug tomorrow on Linux unless someone figures out what I'm doing wrong before that ;).


packagePaths = @getPackagePathsByPackageName()
for packageName, packagePath of packagePaths
if packagePath.indexOf('.atom/dev/packages') > -1 or packagePath.indexOf('.atom/packages') > -1
if packagePath.indexOf(path.join('.atom', 'dev', 'packages')) > -1 or packagePath.indexOf(path.join('.atom', 'packages')) > -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh man. Cant believe this has been in there so long.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this still might be incorrect...@kevinsawicki if someone sets their ATOM_HOME to something like /Users/user/ATOM, then will this check fail? If so, how would I fix that? By reading process.env.ATOM_HOME and then regexing it to capture the last folder path?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle bump @kevinsawicki

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of this line is to check if the package is bundled or not right?

There is atom.packages.isBundledPackage and atom.packages.isBundledPackagePath that might be useful to use instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's actually to check if a package is symlinked or not, and then to get its true path since that's where the error will have been thrown from.

Eg if I have notifications linked to .atom\packages\notifications from C:\Users\user\Documents\Github\notifications and notifications throws an error, then this piece of code will correctly match the two.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I'd say maybe just call fs.realpath in all cases then if we want to ensure the stack paths match the package paths.

@izuzak
Copy link
Contributor

izuzak commented Nov 4, 2015

👏 @50Wliu

Going to cc @kevinsawicki for more 👀 since he worked on some improvement to this package and error detection, if I remember correctly.

@@ -190,6 +191,9 @@ class NotificationIssue
return packName unless /^\.\./.test(relativePath)
@getPackageNameFromFilePath(filePath)

packageName = /Failed to (load|activate) (the|a) (.*) package/.exec(message)?[3]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should pass in the packageName as metadata to the notification instead of having to regex the message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would probably be better. Any pointers on how to do that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wonder if putting it in this payload would be sufficient, https://github.com/atom/atom/blob/666bb344647d1f96df93c875e404e32bd6c1d419/src/package.coffee#L637

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@50Wliu
Copy link
Contributor Author

50Wliu commented Nov 4, 2015

Unfortunately I can't reproduce the failing spec, even on Ubuntu 😞.

@50Wliu
Copy link
Contributor Author

50Wliu commented Nov 4, 2015

Wow ok so I totally forgot that package specs run on Mac and not Linux. Can anyone repro the failing spec on Mac then?

@50Wliu
Copy link
Contributor Author

50Wliu commented Nov 4, 2015

Also, should we switch to actually building and then loading a package (similar to how spec/package-manager-spec.coffee does it) instead of manually creating the notification ourselves?

@@ -190,6 +190,8 @@ class NotificationIssue
return packName unless /^\.\./.test(relativePath)
@getPackageNameFromFilePath(filePath)

return options.packageName if options.packageName?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this could be returned at the top of this method? Like line 178?

50Wliu and others added 2 commits November 6, 2015 11:36
Node stack traces seem to always contain real-paths, even if the
file was required via a symlink path
@maxbrunsfeld
Copy link
Contributor

🚢

@50Wliu
Copy link
Contributor Author

50Wliu commented Nov 18, 2015

🚢

Whoops, missed that...

50Wliu added a commit that referenced this pull request Nov 18, 2015
@50Wliu 50Wliu merged commit d44638f into master Nov 18, 2015
@50Wliu 50Wliu deleted the wl-fix-package-detections branch November 18, 2015 20:43
@as-cii
Copy link
Contributor

as-cii commented Nov 18, 2015

Thanks, @50Wliu!

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

Successfully merging this pull request may close these issues.

Failed to load/activate package bug should be filed on package not Atom?
6 participants