santinic / how2

AI for the Command Line
https://how2terminal.com
MIT License
5.71k stars 156 forks source link

Problem in Using! #86

Closed QuestionPython closed 5 years ago

QuestionPython commented 6 years ago

$ how2 -l python hello world

|(node:20024) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.
//usr/local/lib/node_modules/how2/lib/utils.js:32
    if(link.indexOf('stackoverflow.com') !== -1) {
           ^

TypeError: Cannot read property 'indexOf' of null
    at parseStackoverflowQuestionId (/usr/local/lib/node_modules/how2/lib/utils.js:32:12)
    at isValidGoogleLink (/usr/local/lib/node_modules/how2/lib/utils.js:56:12)
    at Array.filter (native)
    at /usr/local/lib/node_modules/how2/lib/how2.js:95:10
    at Request._callback (/usr/local/lib/node_modules/how2/node_modules/google/lib/google.js:85:7)
    at Request.self.callback (/usr/local/lib/node_modules/how2/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)

$ how2 hello world

|(node:20045) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.
system calls - Strace Hello World program

This is all perfectly normal. You aren't supposed to prevent the failing library lookups from happening.

   execve("./hello", ["./hello"], [/* 62 vars */]) = 0

This is your program starting. Since it is dynamically linked, the first code to execute is from the dynamic loader (http://linux.die.net/man/8/ld.so).

   brk(0)                                  = 0x85a5000
   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb774f000

The dynamic loader is allocating some heap space.

   access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)

The dynamic loader checks whether there are dynamic libraries to preload. There aren't any.

   open("/home/miguel/GNUstep/Library/Libraries/tls/i686/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/tls/i686/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/tls/i686/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/tls/i686", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/tls/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/tls/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/tls", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/i686/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/i686/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/i686/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/i686", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/home/miguel/GNUstep/Library/Libraries/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/home/miguel/GNUstep/Library/Libraries", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/usr/lib/tls/i686/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/tls/i686/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/usr/lib/tls/i686/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/tls/i686", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/usr/lib/tls/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/tls/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/usr/lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/tls", 0xbf8df160)      = -1 ENOENT (No such file or directory)
   open("/usr/lib/i686/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/i686/sse2", 0xbf8df160) = -1 ENOENT (No such file or directory)
   open("/usr/lib/i686/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/i686", 0xbf8df160)     = -1 ENOENT (No such file or directory)
   open("/usr/lib/sse2/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
   stat64("/usr/lib/sse2", 0xbf8df160)     = -1 ENOENT (No such file or directory)
   open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

The dynamic loader is looking for libc6, which is the standard library. It looks in several directories: first in the directories specified in the LD_LIBRARY_PATH, then in the directories listed in /etc/ld.so.conf. (See the manual for the full story.). In each directory, the loader checks several subdirectories first: it determines which hardware features are present (P6 instructions (http://en.wikipedia.org/wiki/P6_(microarchitecture)), SSE2 (http://en.wikipedia.org/wiki/SSE2)), and looks for a version of the library binary which may use these extra features to run more efficiently; when it fails to find one that may use all the features, it looks for a more generic one. In the end, the library is found in a standard system directory, in a non-specialized version.

   read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300\177\1\0004\0\0\0"..., 512) = 512
   fstat64(3, {st_mode=S_IFREG|0755, st_size=2035943, ...}) = 0
   mmap2(NULL, 1801892, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7573000
   mmap2(0xb7724000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b0000) = 0xb7724000
   mmap2(0xb7729000, 7844, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7729000
   close(3)                                = 0
   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7572000
   set_thread_area({entry_number:-1, base_addr:0xb7572700, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 (entry_number:6)
   mprotect(0xb7724000, 12288, PROT_READ)  = 0
   mprotect(0xb7750000, 4096, PROT_READ)   = 0

The standard library is loaded, then its initialization code runs.

   fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7571000

This is the result of executing the printf call.

   write(1, "Hello World!\n", 13)          = 13
   exit_group(0)                           = ?

This is your program exiting, which includes flushing the stdout buffer.

Press SPACE for more choices, any other key to quit.

why show many log and message in console?!

but after press Space , its show list.(correct).


also when press B button for open in browser... its close and show :

Press SPACE for more choices, any other key to quit.
TypeError: Cannot read property 'link' of undefined
    at ScrollableBox.<anonymous> (/usr/local/lib/node_modules/how2/lib/ui.js:161:39)
    at ScrollableBox.EventEmitter._emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:94:20)
    at ScrollableBox.EventEmitter.emit (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/events.js:117:12)
    at Program.<anonymous> (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/widgets/screen.js:603:15)
    at emitTwo (events.js:106:13)
    at Program.emit (events.js:191:7)
    at /usr/local/lib/node_modules/how2/node_modules/blessed/lib/program.js:410:15
    at Array.forEach (native)
    at ReadStream.input.on.input._keypressHandler (/usr/local/lib/node_modules/how2/node_modules/blessed/lib/program.js:408:23)
    at emitTwo (events.js:106:13)
jamesalbert commented 6 years ago

I am also getting the TypeError: Cannot read property 'indexOf' of null error with how2 cat

complete trace:

if(link.indexOf('stackoverflow.com') !== -1) {
            ^

TypeError: Cannot read property 'indexOf' of null
    at parseStackoverflowQuestionId (/Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/lib/utils.js:32:13)
    at isValidGoogleLink (/Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/lib/utils.js:56:12)
    at Array.filter (<anonymous>)
    at /Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/lib/how2.js:95:10
    at Request._callback (/Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/node_modules/google/lib/google.js:85:7)
    at Request.self.callback (/Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/node_modules/request/request.js:186:22)
    at Request.emit (events.js:180:13)
    at Request.<anonymous> (/Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/node_modules/request/request.js:1163:10)
    at Request.emit (events.js:180:13)
    at IncomingMessage.<anonymous> (/Users/jamesalbert/.nodenv/versions/9.10.1/lib/node_modules/how-2/node_modules/request/request.js:1085:12)