autocomplete-python / autocomplete-python

Jedi based Python autocomplete for Atom
https://atom.io/packages/autocomplete-python
GNU General Public License v2.0
253 stars 74 forks source link

Uncaught TypeError: crypto.randomBytes is not a function #284

Closed SamaelChen closed 7 years ago

SamaelChen commented 7 years ago

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.13.1 Electron Version: 1.3.13 System: Ubuntu 16.04.1 Thrown From: autocomplete-python package, v1.8.48

Stack Trace

Uncaught TypeError: crypto.randomBytes is not a function

At /home/samael/.atom/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:26

TypeError: crypto.randomBytes is not a function
    at distinctID (/home/samael/.atom/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:26:32)
    at track (/home/samael/.atom/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:35:18)
    at Object.trackEvent (/home/samael/.atom/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:59:5)
    at Object.track (/home/samael/.atom/packages/autocomplete-python/lib/main.coffee:346:21)
    at Object.trackUsedSuggestion (/home/samael/.atom/packages/autocomplete-python/lib/main.coffee:332:12)
    at AutocompleteManager.autocompleteManager.confirm (/home/samael/.atom/packages/autocomplete-python/lib/main.coffee:281:10)
    at /opt/atom/resources/app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:254:16
    at Function.module.exports.Emitter.simpleDispatch (/opt/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/opt/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at SuggestionList.confirm (/opt/atom/resources/app.asar/node_modules/autocomplete-plus/lib/suggestion-list.js:135:27)
    at autocomplete-suggestion-list.confirmSelection (/opt/atom/resources/app.asar/node_modules/autocomplete-plus/lib/suggestion-list-element.js:313:27)
    at Function.module.exports.Emitter.simpleDispatch (/opt/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/opt/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at SuggestionList.confirmSelection (/opt/atom/resources/app.asar/node_modules/autocomplete-plus/lib/suggestion-list.js:140:27)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/opt/atom/resources/app.asar/src/command-registry.js:259:29)
    at /opt/atom/resources/app.asar/src/command-registry.js:3:59
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/opt/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:587:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/opt/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:382:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/opt/atom/resources/app.asar/src/window-event-handler.js:106:36)
    at HTMLDocument.<anonymous> (/opt/atom/resources/app.asar/src/window-event-handler.js:3:59)

Commands

     -4:53 hydrogen:run-and-move-down (input.hidden-input)
     -4:49.7.0 core:backspace (input.hidden-input)
     -4:48.5.0 hydrogen:run-and-move-down (input.hidden-input)
     -4:33.3.0 core:save (input.hidden-input)
     -3:31.3.0 atom-beautify:beautify-editor (input.hidden-input)
  2x -3:18.8.0 core:delete (input.hidden-input)
     -3:16.1.0 atom-beautify:beautify-editor (input.hidden-input)
     -3:12.4.0 editor:newline (input.hidden-input)
  2x -3:04.9.0 hydrogen:run-and-move-down (input.hidden-input)
  4x -1:25.2.0 core:backspace (input.hidden-input)
     -1:03.1.0 hydrogen:run-and-move-down (input.hidden-input)
  2x -0:53.7.0 autocomplete-plus:confirm (input.hidden-input)
  2x -0:35.8.0 core:backspace (input.hidden-input)
  5x -0:18.4.0 core:move-right (input.hidden-input)
     -0:17.1.0 core:backspace (input.hidden-input)
  2x -0:14.8.0 autocomplete-plus:confirm (input.hidden-input)

Config

{
  "core": {
    "disabledPackages": [
      "markdown-preview",
      "language-gfm"
    ],
    "telemetryConsent": "no"
  },
  "autocomplete-python": {
    "extraPaths": "/usr/local/python3.5/site-packages",
    "pythonPaths": "/usr/bin/python3"
  }
}

Installed Packages

# User
activate-power-mode, v1.2.0 (active)
atom-beautify, v0.29.17 (active)
autocomplete-python, v1.8.48 (active)
Hydrogen, v1.5.5 (active)
ink, v0.6.2 (active)
julia-client, v0.5.11 (active)
language-cypher, v0.3.0 (active)
language-julia, v0.10.0 (active)
language-latex, v1.0.0 (active)
language-markdown, v0.19.1 (active)
language-matlab, v0.2.1 (active)
language-r, v0.4.1 (active)
latex, v0.42.3 (inactive)
linter, v1.11.21 (active)
linter-flake8, v2.1.4 (active)
linter-write-good, v0.8.0 (active)
markdown-mindmap, v0.3.2 (active)
markdown-preview-enhanced, v0.9.7 (active)
project-manager, v3.3.3 (active)
python-tools, v0.6.9 (active)
script, v3.14.1 (inactive)
atom-dark-syntax, v0.28.0 (inactive)
atom-dark-ui, v0.53.0 (inactive)
atom-light-syntax, v0.29.0 (inactive)
atom-light-ui, v0.46.0 (inactive)
base16-tomorrow-dark-theme, v1.4.0 (inactive)
base16-tomorrow-light-theme, v1.4.0 (inactive)
one-dark-ui, v1.8.2 (active)
one-light-ui, v1.8.2 (inactive)
one-dark-syntax, v1.6.0 (active)
one-light-syntax, v1.6.0 (inactive)
solarized-dark-syntax, v1.1.1 (inactive)
solarized-light-syntax, v1.1.1 (inactive)
about, v1.7.2 (active)
archive-view, v0.62.0 (active)
autocomplete-atom-api, v0.10.0 (active)
autocomplete-css, v0.14.1 (active)
autocomplete-html, v0.7.2 (active)
autocomplete-plus, v2.33.1 (active)
autocomplete-snippets, v1.11.0 (active)
autoflow, v0.29.0 (inactive)
autosave, v0.23.2 (active)
background-tips, v0.26.1 (active)
bookmarks, v0.43.2 (active)
bracket-matcher, v0.85.1 (active)
command-palette, v0.39.1 (inactive)
deprecation-cop, v0.55.1 (active)
dev-live-reload, v0.47.0 (active)
encoding-selector, v0.22.0 (active)
find-and-replace, v0.204.5 (inactive)
fuzzy-finder, v1.4.0 (active)
git-diff, v1.2.0 (active)
go-to-line, v0.31.2 (inactive)
grammar-selector, v0.48.2 (active)
image-view, v0.60.0 (active)
incompatible-packages, v0.26.1 (active)
keybinding-resolver, v0.35.0 (active)
line-ending-selector, v0.5.1 (active)
link, v0.31.2 (inactive)
markdown-preview, v0.159.3 (inactive)
notifications, v0.65.1 (active)
open-on-github, v1.2.1 (inactive)
package-generator, v1.0.2 (inactive)
settings-view, v0.244.0 (active)
snippets, v1.0.4 (active)
spell-check, v0.68.5 (active)
status-bar, v1.6.0 (active)
styleguide, v0.48.0 (active)
symbols-view, v0.113.1 (inactive)
tabs, v0.103.1 (active)
timecop, v0.33.2 (active)
tree-view, v0.211.1 (active)
update-package-dependencies, v0.10.0 (active)
welcome, v0.35.1 (active)
whitespace, v0.35.0 (active)
wrap-guide, v0.39.0 (active)
language-c, v0.54.0 (active)
language-clojure, v0.22.1 (active)
language-coffee-script, v0.48.1 (active)
language-csharp, v0.13.0 (active)
language-css, v0.40.1 (active)
language-gfm, v0.88.0 (inactive)
language-git, v0.15.0 (active)
language-go, v0.43.0 (active)
language-html, v0.47.1 (active)
language-hyperlink, v0.16.1 (active)
language-java, v0.24.0 (active)
language-javascript, v0.122.0 (active)
language-json, v0.18.3 (active)
language-less, v0.29.6 (active)
language-make, v0.22.2 (active)
language-mustache, v0.13.0 (active)
language-objective-c, v0.15.1 (active)
language-perl, v0.37.0 (active)
language-php, v0.37.3 (active)
language-property-list, v0.8.0 (active)
language-python, v0.45.1 (active)
language-ruby, v0.70.2 (active)
language-ruby-on-rails, v0.25.1 (active)
language-sass, v0.57.0 (active)
language-shellscript, v0.23.0 (active)
language-source, v0.9.0 (active)
language-sql, v0.25.0 (active)
language-text, v0.7.1 (active)
language-todo, v0.29.1 (active)
language-toml, v0.18.1 (active)
language-xml, v0.34.12 (active)
language-yaml, v0.27.1 (active)

# Dev
No dev packages
nick5435 commented 7 years ago

+1 for Windows 10 x64 running atom 1.14.1x64

stefanw commented 7 years ago

I'm quite shocked because it looks like my autocompletion sends some kind of metrics somewhere about what I autocomplete(?). Even when I disable the "cloud powered autocomplete engine" the code path to telemetry/metrics.js is hit. I have atom telemetry collection disabled in my core settings and I would expect this package to respect that setting.

Pyrestone commented 7 years ago

Had similar problem since last 2 updates on Linux steps to reproduce:

  1. type something that is auto-completable (for instance "xra" or the start of a variable name)
  2. suggestion appears (xrange(), var name, etc.)
  3. press enter
  4. Bug message appears Steps 3 and 4 can be repeated for same result every time.

Atom: 1.14.1 x64 Electron: 1.3.13 OS: Linux Mint Thrown From: autocomplete-python package 1.8.50

Stack Trace

Uncaught TypeError: crypto.randomBytes is not a function

At /home/marc/.atom/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:26

TypeError: crypto.randomBytes is not a function
    at distinctID (/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:26:32)
    at track (/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:35:18)
    at Object.trackEvent (/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:59:5)
    at Object.track (/packages/autocomplete-python/lib/main.coffee:371:21)
    at Object.trackUsedSuggestion (/packages/autocomplete-python/lib/main.coffee:361:12)
    at AutocompleteManager.autocompleteManager.confirm (/packages/autocomplete-python/lib/main.coffee:286:10)
    at /app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:254:16
    at Function.module.exports.Emitter.simpleDispatch (/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at SuggestionList.confirm (/app.asar/node_modules/autocomplete-plus/lib/suggestion-list.js:135:27)
    at /app.asar/node_modules/autocomplete-plus/lib/suggestion-list-element.js:326:27)
    at Function.module.exports.Emitter.simpleDispatch (/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at SuggestionList.confirmSelection (/app.asar/node_modules/autocomplete-plus/lib/suggestion-list.js:140:27)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
    at /app.asar/src/command-registry.js:3:59
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
    at /app.asar/src/window-event-handler.js:3:59)

Commands

  2x -3:06.6.0 autocomplete-plus:confirm (input.hidden-input)
     -2:09.1.0 settings-view:uninstall-packages (a.)
     -0:07.4.0 autocomplete-plus:activate (input.hidden-input)
     -0:05.9.0 autocomplete-plus:confirm (input.hidden-input)

Non-Core Packages

autocomplete-python 1.8.50 
formatter 2.12.3 
hyperclick 0.0.40 
letops commented 7 years ago

[Enter steps to reproduce:]

Exactly as Pyrestone commented above

Atom: 1.14.1 x64 Electron: 1.3.13 OS: elementary OS (Ubuntu 16.04) Thrown From: autocomplete-python package 1.8.50

Stack Trace

Uncaught TypeError: crypto.randomBytes is not a function

At /home/daniel/.atom/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:26

TypeError: crypto.randomBytes is not a function
    at distinctID (/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:26:32)
    at track (/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:35:18)
    at Object.trackEvent (/packages/autocomplete-python/node_modules/kite-installer/ext/telemetry/metrics.js:59:5)
    at Object.track (/packages/autocomplete-python/lib/main.coffee:371:21)
    at Object.trackUsedSuggestion (/packages/autocomplete-python/lib/main.coffee:361:12)
    at AutocompleteManager.autocompleteManager.confirm (/packages/autocomplete-python/lib/main.coffee:286:10)
    at /app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:254:16
    at Function.module.exports.Emitter.simpleDispatch (/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at SuggestionList.confirm (/app.asar/node_modules/autocomplete-plus/lib/suggestion-list.js:135:27)
    at /app.asar/node_modules/autocomplete-plus/lib/suggestion-list-element.js:326:27)
    at Function.module.exports.Emitter.simpleDispatch (/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
    at Emitter.module.exports.Emitter.emit (/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
    at SuggestionList.confirmSelection (/app.asar/node_modules/autocomplete-plus/lib/suggestion-list.js:140:27)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
    at /app.asar/src/command-registry.js:3:59
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
    at /app.asar/src/window-event-handler.js:3:59)

Commands

     -2:23.7.0 core:move-right (input.hidden-input)
  4x -2:21.6.0 editor:move-to-beginning-of-word (input.hidden-input)
     -2:18.3.0 editor:select-to-beginning-of-word (input.hidden-input)
     -2:16.4.0 editor:move-to-end-of-word (input.hidden-input)
     -2:15.8.0 editor:select-to-end-of-word (input.hidden-input)
     -2:14.1.0 editor:move-to-end-of-word (input.hidden-input)
  3x -2:13.7.0 core:move-right (input.hidden-input)
     -2:12.2.0 editor:newline (input.hidden-input)
  2x -2:03.8.0 core:move-right (input.hidden-input)
     -2:00.0 core:save (input.hidden-input)
     -1:43.8.0 core:move-right (input.hidden-input)
  2x -1:43.4.0 core:select-left (input.hidden-input)
     -1:39.2.0 autocomplete-plus:confirm (input.hidden-input)
     -1:37.4.0 core:backspace (input.hidden-input)
  3x -1:26.7.0 core:move-down (input.hidden-input)
     -1:25.7.0 autocomplete-plus:confirm (input.hidden-input)

Non-Core Packages

api-docs 0.0.6 
atom-beautify 0.29.17 
atom-clock 0.1.3 
atom-django 0.3.2 
atom-elixir 0.2.2 
atom-jinja2 0.6.0 
atom-material-syntax 1.0.2 
atom-material-ui 1.3.9 
autocomplete-elixir 1.5.14 
autocomplete-python 1.8.50 
browser-plus 0.0.87 
file-icons 2.0.15 
hyperclick 0.0.40 
language-babel 2.54.1 
language-elixir 0.17.0 
linter 1.11.21 
linter-csslint 1.3.3 
linter-elixirc 1.1.11 
linter-erlc 0.3.0 
linter-htmlhint 1.3.1 
linter-js-yaml 1.2.6 
linter-jscs 4.1.1 
linter-markdown 3.1.0 
linter-pycodestyle 2.0.0 
linter-scss-lint 3.0.4 
linter-write-good 0.8.0 
linter-xmllint 1.4.0 
merge-conflicts 1.4.4 
minimap 4.26.8 
minimap-linter 1.6.0 
minimap-pigments 0.2.2 
minimap-split-diff 0.3.3 
nucleus-dark-ui 0.10.22 
pigments 0.39.0 
script 3.14.1 
split-diff 1.1.2 
svg-preview 0.11.0 
himiranov commented 7 years ago

Add in you metrics.js file this line: var crypto = require('crypto');

Worked for me.

sadovnychyi commented 7 years ago

Should be fixed in v1.8.51. Very sorry about this.

asakaplan commented 7 years ago

I still had this issue on 1.8.63. I solved it by changing the metrics.js line

const crypto = require('crypto'); to var crypto = require('crypto');

as above.