onepub-dev / dcli

An extensive library and tooling for building console/cli applications and scripts using the Dart programming language.
246 stars 27 forks source link

Error when compiling a dshell script #50

Closed ram535 closed 4 years ago

ram535 commented 4 years ago

Describe the bug When running:

dshell compile <a dshell script>

It throws this error:

Unexpected object (Class with illegal cid, full-aot): 0x7f7e7401db01 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!

Run dshell doctor:

Dshell doctor version    : 1.1.0-dev.3

OS                       : linux
OS Version               : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017
Path separator           : /

dart version             : 2.7.1
dart exe path            : ~/bin/dart-sdk/bin/dart
dart path                : ~/bin/dart-sdk/bin/dart : ~/bin/dart-sdk/bin/dart
dart2Native path         : ~/bin/dart-sdk/bin/dart2native : ~/bin/dart-sdk/bin/dart2native

pub get path             : ~/bin/dart-sdk/bin/pub : ~/bin/dart-sdk/bin/pub
.pub-cache               : ~/.pub-cache
Package Config           : Not Passed

PATH
    ~/bin/emacs/src
    ~/bin/vifm/bin
    ~/bin/flutter/bin
    ~/bin/dart-sdk/bin
    ~/.pub-cache/bin
    /snap/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin

$SHELL                   : /bin/zsh
True SHELL               : zsh
Shell Start Script       : ~/.zshrc

Dart location(s)
                         : /home/last/bin/dart-sdk/bin/dart

Permissions
dshell: Exception occured: Invalid argument(s) (pattern): Must not be null of type ArgumentError
dshell: Stacktrace: string_patch.dart : _StringBase.replaceAll : 633
doctor.dart : DoctorCommand.showPermissions : 122
doctor.dart : DoctorCommand.run : 73
command_line_runner.dart : CommandLineRunner.process : 81
entry_point.dart : EntryPoint._parseCmdLine : 37
entry_point.dart : EntryPoint.process : 31
dshell.dart : DShell.run : 9
dshell.dart : main : 4
isolate_patch.dart : _startIsolate.<anonymous closure> : 305
isolate_patch.dart : _RawReceivePortImpl._handleMessage : 174
bsutton commented 4 years ago

Can you post the script you were compiling

On Sat, 1 Feb 2020, 12:09 pm Ramses, notifications@github.com wrote:

Describe the bug When running:

dshell compile

It throws this error:

Unexpected object (Class with illegal cid, full-aot): 0x7f7e7401db01 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files: Generating AOT snapshot failed!

Run dshell doctor:

Dshell doctor version : 1.1.0-dev.3

OS : linux OS Version : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 Path separator : /

dart version : 2.7.1 dart exe path : ~/bin/dart-sdk/bin/dart dart path : ~/bin/dart-sdk/bin/dart : ~/bin/dart-sdk/bin/dart dart2Native path : ~/bin/dart-sdk/bin/dart2native : ~/bin/dart-sdk/bin/dart2native

pub get path : ~/bin/dart-sdk/bin/pub : ~/bin/dart-sdk/bin/pub .pub-cache : ~/.pub-cache Package Config : Not Passed

PATH ~/bin/emacs/src ~/bin/vifm/bin ~/bin/flutter/bin ~/bin/dart-sdk/bin ~/.pub-cache/bin /snap/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin

$SHELL : /bin/zsh True SHELL : zsh Shell Start Script : ~/.zshrc

Dart location(s) : /home/last/bin/dart-sdk/bin/dart

Permissions dshell: Exception occured: Invalid argument(s) (pattern): Must not be null of type ArgumentError dshell: Stacktrace: string_patch.dart : _StringBase.replaceAll : 633 doctor.dart : DoctorCommand.showPermissions : 122 doctor.dart : DoctorCommand.run : 73 command_line_runner.dart : CommandLineRunner.process : 81 entry_point.dart : EntryPoint._parseCmdLine : 37 entry_point.dart : EntryPoint.process : 31 dshell.dart : DShell.run : 9 dshell.dart : main : 4 isolate_patch.dart : _startIsolate. : 305 isolate_patch.dart : _RawReceivePortImpl._handleMessage : 174

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/50?email_source=notifications&email_token=AAG32OB3QLFWA2LSTBF64FLRATDUJA5CNFSM4KOPZ5UKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IKJJV2A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OAGZSY3MKHRA57CR33RATDUJANCNFSM4KOPZ5UA .

bsutton commented 4 years ago

It looks to me like a bug in the dart2native compiler.

It may relate to this issue: https://github.com/flutter/flutter/issues/36155

Can you run

dshell -v compile

It should output the dart2native call.

Can you try running dart2native using the command line output via the above verbose option, adding the target option mentioned in the issue.

On Sat, 1 Feb 2020, 12:09 pm Ramses, notifications@github.com wrote:

Describe the bug When running:

dshell compile

It throws this error:

Unexpected object (Class with illegal cid, full-aot): 0x7f7e7401db01 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files: Generating AOT snapshot failed!

Run dshell doctor:

Dshell doctor version : 1.1.0-dev.3

OS : linux OS Version : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 Path separator : /

dart version : 2.7.1 dart exe path : ~/bin/dart-sdk/bin/dart dart path : ~/bin/dart-sdk/bin/dart : ~/bin/dart-sdk/bin/dart dart2Native path : ~/bin/dart-sdk/bin/dart2native : ~/bin/dart-sdk/bin/dart2native

pub get path : ~/bin/dart-sdk/bin/pub : ~/bin/dart-sdk/bin/pub .pub-cache : ~/.pub-cache Package Config : Not Passed

PATH ~/bin/emacs/src ~/bin/vifm/bin ~/bin/flutter/bin ~/bin/dart-sdk/bin ~/.pub-cache/bin /snap/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin

$SHELL : /bin/zsh True SHELL : zsh Shell Start Script : ~/.zshrc

Dart location(s) : /home/last/bin/dart-sdk/bin/dart

Permissions dshell: Exception occured: Invalid argument(s) (pattern): Must not be null of type ArgumentError dshell: Stacktrace: string_patch.dart : _StringBase.replaceAll : 633 doctor.dart : DoctorCommand.showPermissions : 122 doctor.dart : DoctorCommand.run : 73 command_line_runner.dart : CommandLineRunner.process : 81 entry_point.dart : EntryPoint._parseCmdLine : 37 entry_point.dart : EntryPoint.process : 31 dshell.dart : DShell.run : 9 dshell.dart : main : 4 isolate_patch.dart : _startIsolate. : 305 isolate_patch.dart : _RawReceivePortImpl._handleMessage : 174

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/50?email_source=notifications&email_token=AAG32OB3QLFWA2LSTBF64FLRATDUJA5CNFSM4KOPZ5UKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IKJJV2A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OAGZSY3MKHRA57CR33RATDUJANCNFSM4KOPZ5UA .

bsutton commented 4 years ago

I've just published an update 1.1.2-dev.1

It has a fix for the dshell doctor error. I don't have access to a mac for testing so I'm having to google and guess the typical setup.

I was wrong when I said that running dshell -v would output the command line I use to compile. The above noted version now includes this feature.

Looks like dart2native no longer has a --target switch.

So I think we need to: Install the above version run dshell -v compile as noted above and note the command line used to run dart2native. Then run the dart2native command directly from the cli.

Assuming the error still occurs I think we will need to submit an issue with google as this feels like a bug in dart2native.

If you are interested in helping with the larger dshell project it would be really helpful to have someone who could run the suite of unit tests on a mac. If your interested let me know and I will send you the instructions on how to run it.

Brett.

On Sat, 1 Feb 2020 at 12:09, Ramses notifications@github.com wrote:

Describe the bug When running:

dshell compile

It throws this error:

Unexpected object (Class with illegal cid, full-aot): 0x7f7e7401db01 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files: Generating AOT snapshot failed!

Run dshell doctor:

Dshell doctor version : 1.1.0-dev.3

OS : linux OS Version : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 Path separator : /

dart version : 2.7.1 dart exe path : ~/bin/dart-sdk/bin/dart dart path : ~/bin/dart-sdk/bin/dart : ~/bin/dart-sdk/bin/dart dart2Native path : ~/bin/dart-sdk/bin/dart2native : ~/bin/dart-sdk/bin/dart2native

pub get path : ~/bin/dart-sdk/bin/pub : ~/bin/dart-sdk/bin/pub .pub-cache : ~/.pub-cache Package Config : Not Passed

PATH ~/bin/emacs/src ~/bin/vifm/bin ~/bin/flutter/bin ~/bin/dart-sdk/bin ~/.pub-cache/bin /snap/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin

$SHELL : /bin/zsh True SHELL : zsh Shell Start Script : ~/.zshrc

Dart location(s) : /home/last/bin/dart-sdk/bin/dart

Permissions dshell: Exception occured: Invalid argument(s) (pattern): Must not be null of type ArgumentError dshell: Stacktrace: string_patch.dart : _StringBase.replaceAll : 633 doctor.dart : DoctorCommand.showPermissions : 122 doctor.dart : DoctorCommand.run : 73 command_line_runner.dart : CommandLineRunner.process : 81 entry_point.dart : EntryPoint._parseCmdLine : 37 entry_point.dart : EntryPoint.process : 31 dshell.dart : DShell.run : 9 dshell.dart : main : 4 isolate_patch.dart : _startIsolate. : 305 isolate_patch.dart : _RawReceivePortImpl._handleMessage : 174

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/50?email_source=notifications&email_token=AAG32OB3QLFWA2LSTBF64FLRATDUJA5CNFSM4KOPZ5UKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IKJJV2A, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OAGZSY3MKHRA57CR33RATDUJANCNFSM4KOPZ5UA .

ram535 commented 4 years ago

I am happy to help you with whatever I can apport to this project. I am using Linux Mint in a seven year old Asus laptop. I do not have a Mac. After updating to 1.1.2-dev.1 with:

pub global activate --overwrite dshell 1.1.2-dev.1
dshell install

complete -C 'dshell_complete' dshell was added to my .zshrc. Then when I open a terminal I get this message.

.zshrc:67: command not found: complete

Refefing that is cannot find complete -C 'dshell_complete' dshell command.

This is the script I am trying to compile. It just creates a custom menu for the rofi program and it runs the selected item.

#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';

void main() {
  final scripts = {
    'apps': 'rofi -show run',
    'books': '$HOME/bin/scripts/books.dart',
    'emacs': '$HOME/bin/emacs/src/emacs',
    'google-chrome': 'google-chrome',
    'projects': '$HOME/bin/scripts/projects.dart',
    'thunar': 'thunar'
  };

  final menu = '${scripts.keys.join('\n')}';
  final rofi = 'rofi -dmenu -i';
  final echo = 'echo $menu';

  (echo | rofi).forEach((item) => '${scripts[item]}'.run);
}

I had to add a pubspec.yaml because it seems dshell is trying to use the 1.1.1 version.

name: tools
version: 1.0.0
environment:
  sdk: '>=2.6.0 <3.0.0'
dependencies:
  dshell: ^1.1.2-dev.1
  args: ^1.5.2
  path: ^1.6.4

Then I run:

dshell -v compile rofi_bangs.dart

I got this error:

Setting flag: verbose
DShell Version: 1.1.2-dev.1
Found command Instance of 'CompileCommand'
Created Virtual Project at /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project
Running pub get...
Dart SDK Version  2.7.1, path: /home/last/bin/dart-sdk
Starting(runInShell: false workingDir: /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project mode: normal)
CommandLine: /home/last/bin/dart-sdk/bin/pub get
Resolving dependencies...
+ args 1.5.2
+ charcode 1.1.2
+ collection 1.14.12
+ dshell 1.1.2-dev.1
+ equatable 1.0.3
+ file 5.1.0
+ file_utils 0.1.4
+ globbing 0.3.0
+ intl 0.16.1
+ io 0.3.3
+ logger 0.8.3
+ matcher 0.12.6
+ meta 1.1.8
+ money2 1.3.0
+ path 1.6.4
+ pub_semver 1.4.2
+ pubspec 0.1.3
+ quiver 2.1.2+1
+ recase 3.0.0
+ source_span 1.6.0
+ stack_trace 1.9.3
+ string_scanner 1.0.5
+ term_glyph 1.1.0
+ uri 0.11.3+1
+ utf 0.9.0+5
+ yaml 2.2.0
Changed 26 dependencies!
Precompiling executables...
Precompiled dshell:dshell.
Precompiled dshell:dshell_complete.

Compiling with pubspec.yaml:
name: tools
version: 1.0.0
environment: 
  sdk: '>=2.6.0 <3.0.0'
dependencies: 
  dshell: ^1.1.2-dev.1
  args: ^1.5.2
  path: ^1.6.4

Starting(runInShell: false workingDir: /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project mode: normal)
CommandLine: /home/last/bin/dart-sdk/bin/dart2native /home/last/bin/scripts/rofi_bangs.dart --output=/home/last/bin/scripts/rofi_bangs

Unexpected object (Class with illegal cid, full-aot): 0x7ff5f7822ad1 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!
dshell: Exiting with code 1

Dshell doctor:

Dshell doctor version    : 1.1.2-dev.1

OS                       : linux
OS Version               : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017
Path separator           : /

dart version             : 2.7.1
dart exe path            : ~/bin/dart-sdk/bin/dart
dart path                : ~/bin/dart-sdk/bin/dart : ~/bin/dart-sdk/bin/dart
dart2Native path         : ~/bin/dart-sdk/bin/dart2native : ~/bin/dart-sdk/bin/dart2native

pub get path             : ~/bin/dart-sdk/bin/pub : ~/bin/dart-sdk/bin/pub
.pub-cache               : ~/.pub-cache
Package Config           : Not Passed

PATH
    ~/bin/emacs/src
    ~/bin/vifm/bin
    ~/bin/dart-sdk/bin
    ~/.pub-cache/bin
    /snap/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin
    /usr/local/go/bin
    ~/bin/go/bin
$SHELL                   : /bin/zsh
True SHELL               : zsh
Shell Start Script       : ~/.zshrc

Dart location(s)
                         : /home/last/bin/dart-sdk/bin/dart

Permissions
bsutton commented 4 years ago

So looks like I wrongly assumed that zsh uses the same auto completion as bash. For the moment I've removed the auto completion install logic when zsh is installed.

For the moment just remove the offending line from your .zshrc.

I'm not certain why your install isnt' picking up the dev version of dshell. I will do some reading and get back to you.

For the moment can you run the following from the cli: /home/last/bin/dart-sdk/bin/dart2native /home/last/bin/scripts/rofi_bangs.dart --output=/home/last/bin/scripts/rofi_bangs

If you get the same error then that will confirm that the problem is a dart2native bug.

I've just managed to compile your script so it looks like it might be something specific to your configuration.

We will need to raise an issue on the dart github site.

If you want to try and narrow down the cause of the problem you could try to remove some of your code until the problem disappears.

Hopefully you can identify the piece of code that the compiler doesn't like.

As to contributing you can see the guidelines here:

https://github.com/bsutton/dshell/wiki

Check out the section on running unit test with the dshell script tool/run_unit_tests.dart

On Sat, 1 Feb 2020 at 17:18, Ramses notifications@github.com wrote:

I am happy to help you with whatever I can apport to this project. I am using Linux Mint in a seven year old Asus laptop. After updating to 1.1.2-dev.1 with:

pub global activate --overwrite dshell 1.1.2-dev.1 dshell install

complete -C 'dshell_complete' dshell was added to my .zshrc. Then when I open a terminal I get this message.

.zshrc:67: command not found: complete

Refefing that is cannot find complete -C 'dshell_complete' dshell command.

This is the script I am trying to compile. It just creates a custom menu for the rofi program.

! /usr/bin/env dshell

import 'package:dshell/dshell.dart';

void main() { final scripts = { 'apps': 'rofi -show run', 'books': '$HOME/bin/scripts/books.dart', 'emacs': '$HOME/bin/emacs/src/emacs', 'google-chrome': 'google-chrome', // 'jd': '$HOME/bin/jd2/JDownloader2', // 'popcorn': '$HOME/bin/popcorn/Popcorn-Time', 'projects': '$HOME/bin/scripts/projects.dart', 'thunar': 'thunar' };

final menu = '${scripts.keys.join('\n')}'; final rofi = 'rofi -dmenu -i'; final echo = 'echo $menu';

(echo | rofi).forEach((item) => '${scripts[item]}'.run); }

I had to add a pubspec.yaml because it seems dshell is trying to use the 1.1.1 version.

name: tools version: 1.0.0 environment: sdk: '>=2.6.0 <3.0.0' dependencies: dshell: ^1.1.2-dev.1 args: ^1.5.2 path: ^1.6.4

Then I run:

dshell -v compile rofi_bangs.dart

I got this error:

Setting flag: verbose DShell Version: 1.1.2-dev.1 Found command Instance of 'CompileCommand' Created Virtual Project at /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project Running pub get... Dart SDK Version 2.7.1, path: /home/last/bin/dart-sdk Starting(runInShell: false workingDir: /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project mode: normal) CommandLine: /home/last/bin/dart-sdk/bin/pub get Resolving dependencies...

  • args 1.5.2
  • charcode 1.1.2
  • collection 1.14.12
  • dshell 1.1.2-dev.1
  • equatable 1.0.3
  • file 5.1.0
  • file_utils 0.1.4
  • globbing 0.3.0
  • intl 0.16.1
  • io 0.3.3
  • logger 0.8.3
  • matcher 0.12.6
  • meta 1.1.8
  • money2 1.3.0
  • path 1.6.4
  • pub_semver 1.4.2
  • pubspec 0.1.3
  • quiver 2.1.2+1
  • recase 3.0.0
  • source_span 1.6.0
  • stack_trace 1.9.3
  • string_scanner 1.0.5
  • term_glyph 1.1.0
  • uri 0.11.3+1
  • utf 0.9.0+5
  • yaml 2.2.0 Changed 26 dependencies! Precompiling executables... Precompiled dshell:dshell. Precompiled dshell:dshell_complete.

Compiling with pubspec.yaml: name: tools version: 1.0.0 environment: sdk: '>=2.6.0 <3.0.0' dependencies: dshell: ^1.1.2-dev.1 args: ^1.5.2 path: ^1.6.4

Starting(runInShell: false workingDir: /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project mode: normal) CommandLine: /home/last/bin/dart-sdk/bin/dart2native /home/last/bin/scripts/rofi_bangs.dart --output=/home/last/bin/scripts/rofi_bangs

Unexpected object (Class with illegal cid, full-aot): 0x7ff5f7822ad1 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files: Generating AOT snapshot failed! dshell: Exiting with code 1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/50?email_source=notifications&email_token=AAG32OAUANVXJ6GFXEZ66NDRAUHZRA5CNFSM4KOPZ5UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKQVQIA#issuecomment-580999200, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OHF2IZB5EQANJYO733RAUHZRANCNFSM4KOPZ5UA .

ram535 commented 4 years ago

I run:

/home/last/bin/dart-sdk/bin/dart2native /home/last/bin/scripts/rofi_bangs.dart --output=/home/last/bin/scripts/rofi_bangs

I get this error:

Unexpected object (Class with illegal cid, full-aot): 0x7fb5e87136d1 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!

Then like you suggested, I removed code to see if something in particular in the code was causing the problem. I removed import 'package:dshell/dshell.dart'; and everything that depends on it. After that dart2native run without problems.

bsutton commented 4 years ago

So lets assume that your pub cache is corrupt.

Can you run:

pub cache repair

Run dshell doctor again and send me the result.

Then try the compile again. Given that the problem is reproducible via the direct native call you can just use dshell compile for all testing.

If that doesn't solve the problem add in the dshell.dart import but no other code. Does it compile? Add one line back in that uses dshell, does it compile? Try a few dshell global functions (one at a time) can you get it to compile with any of them.

Can you run dshell doctor again and send me the result.

On Sun, 2 Feb 2020 at 04:49, Ramses notifications@github.com wrote:

I run:

/home/last/bin/dart-sdk/bin/dart2native /home/last/bin/scripts/rofi_bangs.dart --output=/home/last/bin/scripts/rofi_bangs

I get this error:

Unexpected object (Class with illegal cid, full-aot): 0x7fb5e87136d1 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files: Generating AOT snapshot failed!

Then like you suggested, I remove code to see if something in particular in the code was causing the problem. I removed import 'package:dshell/dshell.dart'; and everything that depends on it. After that dart2native run without problems.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/50?email_source=notifications&email_token=AAG32OCLCDSVVN2TPGY7OBDRAWYZ5A5CNFSM4KOPZ5UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKRCU6I#issuecomment-581053049, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OAWAQ52SOEKMVBDKDLRAWYZ5ANCNFSM4KOPZ5UA .

ram535 commented 4 years ago

dshell doctor after pub cache repair.

Dshell doctor version    : 1.1.2-dev.1

OS                       : linux
OS Version               : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017
Path separator           : /

dart version             : 2.7.1
dart exe path            : ~/bin/dart-sdk/bin/dart
dart path                : ~/bin/dart-sdk/bin/dart : ~/bin/dart-sdk/bin/dart
dart2Native path         : ~/bin/dart-sdk/bin/dart2native : ~/bin/dart-sdk/bin/dart2native

pub get path             : ~/bin/dart-sdk/bin/pub : ~/bin/dart-sdk/bin/pub
.pub-cache               : ~/.pub-cache
Package Config           : Not Passed

PATH    
    ~/bin/emacs/src
    ~/bin/flutter/bin
    ~/bin/dart-sdk/bin
    ~/.pub-cache/bin
    ~/bin
    /snap/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin

$SHELL                   : /bin/zsh
True SHELL               : zsh
Shell Start Script       : ~/.zshrc

Dart location(s)
                         : /home/last/bin/dart-sdk/bin/dart

Permissions

So dshell compile behaves exactly like dart2native. I tried a simple script:

#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';

void main() {
  print('$HOME');
}

Keeps throwing this error.

Created Virtual Project at /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project
Running pub get...
Resolving dependencies...
+ args 1.5.2
+ charcode 1.1.2
+ collection 1.14.12
+ dshell 1.1.2-dev.1
+ equatable 1.0.3
+ file 5.1.0
+ file_utils 0.1.4
+ globbing 0.3.0
+ intl 0.16.1
+ io 0.3.3
+ logger 0.8.3
+ matcher 0.12.6
+ meta 1.1.8
+ money2 1.3.0
+ path 1.6.4
+ pub_semver 1.4.2
+ pubspec 0.1.3
+ quiver 2.1.2+1
+ recase 3.0.0
+ source_span 1.6.0
+ stack_trace 1.9.3
+ string_scanner 1.0.5
+ term_glyph 1.1.0
+ uri 0.11.3+1
+ utf 0.9.0+5
+ yaml 2.2.0
Changed 26 dependencies!
Precompiling executables...
Precompiled dshell:dshell_complete.
Precompiled dshell:dshell.

Unexpected object (Class with illegal cid, full-aot): 0x7fc6cc693741 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!

But if I use this script with dshell compile, there is no error.

void main() {
  print('foo');
}

Next I removed the pubspec.yaml, I also removed all the things dart create after pub get. analysis_server does not detect dshell and mark errors where I tried to use things that are part of dshell, even though import 'package:dshell/dshell.dart'; is on top of the file.

If tried to dshell compile, I get this error.

Created Virtual Project at /home/last/.dshell/cache/home/last/bin/scripts/rofi_bangs.project
Running pub get...
Resolving dependencies...
+ args 1.5.2
+ charcode 1.1.2
+ collection 1.14.12
+ dshell 1.1.1 (1.1.2-dev.1 available)
+ equatable 1.0.3
+ file 5.1.0
+ file_utils 0.1.4
+ globbing 0.3.0
+ intl 0.16.1
+ io 0.3.3
+ logger 0.8.3
+ matcher 0.12.6
+ meta 1.1.8
+ money2 1.3.0
+ path 1.6.4
+ pub_semver 1.4.2
+ pubspec 0.1.3
+ quiver 2.1.2+1
+ recase 3.0.0
+ source_span 1.6.0
+ stack_trace 1.9.3
+ string_scanner 1.0.5
+ term_glyph 1.1.0
+ uri 0.11.3+1
+ utf 0.9.0+5
+ yaml 2.2.0
Changed 26 dependencies!
Precompiling executables...
Precompiled dshell:dshell_complete.
Precompiled dshell:dshell.
../../../../../../../bin/scripts/rofi_bangs.dart:2:8: Error: Not found: 'package:dshell/dshell.dart'
import 'package:dshell/dshell.dart';
       ^
../../../../../../../bin/scripts/rofi_bangs.dart:5:11: Error: Getter not found: 'HOME'.
  print('$HOME');
          ^^^^
Error: Could not resolve the package 'dshell' in 'package:dshell/dshell.dart'.

Failed to generate native files:
Generating AOT kernel dill failed!

Like I mentioned before, some how it is trying to use version 1.1.1. Is there something wrong with this command when I update dshell?

pub global activate --overwrite dshell 1.1.2-dev.1
dshell install

I updated again dshell but this time I removed the --overwrite option. but no luck.

bsutton commented 4 years ago

I've just published a new dev version which has an updated dshell doctor which might help us understand why it is running 1.1.1

can you do: pub global activate dshell 1.1.2-dev-5

Then run

cd dshell doctor rofl.dart

and post the results.

ram535 commented 4 years ago

I see. So the virtual pubspec.yaml of the rofi_bangs.dart script is not getting modify when updating dshell. I also see that dependecies.yaml is not getting modify either.

Dshell doctor version    : 1.1.2-dev-5

OS                       : linux
OS Version               : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017
Path separator           : /

dart version             : 2.7.1
dart exe path            : /<HOME>/bin/dart-sdk/bin/dart
dart path                : /<HOME>/bin/dart-sdk/bin/dart : /<HOME>/bin/dart-sdk/bin/dart
dart2Native path         : /<HOME>/bin/dart-sdk/bin/dart2native : /<HOME>/bin/dart-sdk/bin/dart2native

pub get path             : /<HOME>/bin/dart-sdk/bin/pub : /<HOME>/bin/dart-sdk/bin/pub
.pub-cache               : /<HOME>/.pub-cache
Package Config           : Not Passed

PATH
    /<HOME>/bin/flutter/bin
    /<HOME>/bin/dart-sdk/bin
    /<HOME>/.pub-cache/bin
    /<HOME>/bin
    /snap/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin
$SHELL                   : /bin/zsh
True SHELL               : nvim
Shell Start Script       : Not Found

Dart location(s)
                         : /home/last/bin/dart-sdk/bin/dart

Permissions

.dshell/dependencies.yaml
  dshell                 : ^1.0.0
  args                   : ^1.5.2
  path                   : ^1.6.4

Script Details
Name                     : rofi_bangs.dart
Directory                : /<HOME>/bin/scripts
Virtual Project          : /<HOME>/.dshell/cache/<HOME>/bin/scripts/rofi_bangs.project

Virtual pubspec.yaml
  name: rofi_bangs
  version: 1.0.0
  dependencies: 
    dshell: ^1.0.0
    args: ^1.5.2
    path: ^1.6.4

Dependencies             : 
  dshell                 : ^1.0.0
  args                   : ^1.5.2
  path                   : ^1.6.4
bsutton commented 4 years ago

I've just released a new stable build 1.1.3.

can you try again with the latest build.

ram535 commented 4 years ago

It still trying to use version 1.0.0. I deleted ~/.dshell directory and run dshell install again.

Hang on a tick whilst we install dshell.

Creating /home/last/.dshell

Creating /home/last/.dshell/dependencies.yaml with default packages.
Default packages are:
  dshell:^1.0.0
  args:^1.5.2
  path:^1.6.4

Edit dependencies.yaml to add/remove/update your default dependencies.

Creating Template directory in: /home/last/.dshell/templates.

Creating Cache directory in: /home/last/.dshell/cache.

Creating bin directory in: /home/last/.dshell/bin.

dshell found in : /home/last/.pub-cache/bin/dshell.

dshell installation complete.

Create your first dshell script using:
  dshell create <scriptname>.dart

  Run your script by typing:
  ./<scriptname>.dart

dshell doctor rofi_bangs.dart

Dshell doctor version    : 1.1.3

OS                       : linux
OS Version               : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017
Path separator           : /

dart version             : 2.7.1
dart exe path            : /<HOME>/bin/dart-sdk/bin/dart
dart path                : /<HOME>/bin/dart-sdk/bin/dart : /<HOME>/bin/dart-sdk/bin/dart
dart2Native path         : /<HOME>/bin/dart-sdk/bin/dart2native : /<HOME>/bin/dart-sdk/bin/dart2native

pub get path             : /<HOME>/bin/dart-sdk/bin/pub : /<HOME>/bin/dart-sdk/bin/pub
.pub-cache               : /<HOME>/.pub-cache
Package Config           : Not Passed

PATH
    /<HOME>/bin/flutter/bin
    /<HOME>/bin/dart-sdk/bin
    /<HOME>/.pub-cache/bin
    /<HOME>/bin
    /snap/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin
    /usr/local/go/bin
$SHELL                   : /bin/zsh
True SHELL               : nvim
Shell Start Script       : Not Found

Dart location(s)
                         : /home/last/bin/dart-sdk/bin/dart

Permissions

.dshell/dependencies.yaml
  dshell                 : ^1.0.0
  args                   : ^1.5.2
  path                   : ^1.6.4

Script Details
Name                     : rofi_bangs.dart
Directory                : /<HOME>/bin/scripts
Virtual Project          : /<HOME>/.dshell/cache/<HOME>/bin/scripts/rofi_bangs.project

Virtual pubspec.yaml
  name: rofi_bangs
  version: 1.0.0
  dependencies: 
    dshell: ^1.0.0
    args: ^1.5.2
    path: ^1.6.4

Dependencies             : 
  dshell                 : ^1.0.0
  args                   : ^1.5.2
  path                   : ^1.6.4
bsutton commented 4 years ago

No you are actually running 1.1.3 which you can see from the doctor version.

The dependency statements with the ^ just say user any version from 1.0.0 out greater.

Run dshell clean on Rolo.dart.

Run the compile again and post the output.

If it still shows 1.0.0 in the stack trace then change the version in . dshell/dependencies to 1.1.3.

Run clean on roli and Run the compile again.

If that fails then delete your entire ~.pub-cache reinstall dshell and the try again.

If that still fails it's time to file a bug report with Google.

On Mon, 3 Feb 2020, 9:50 pm Ramses, notifications@github.com wrote:

It still using version 1.0.0. I deleted ~/.dshell directory and run dshell install again.

Hang on a tick whilst we install dshell.

Creating /home/last/.dshell

Creating /home/last/.dshell/dependencies.yaml with default packages. Default packages are: dshell:^1.0.0 args:^1.5.2 path:^1.6.4

Edit dependencies.yaml to add/remove/update your default dependencies.

Creating Template directory in: /home/last/.dshell/templates.

Creating Cache directory in: /home/last/.dshell/cache.

Creating bin directory in: /home/last/.dshell/bin.

dshell found in : /home/last/.pub-cache/bin/dshell.

dshell installation complete.

Create your first dshell script using: dshell create .dart

Run your script by typing: ./.dart

dshell doctor rofi_bangs.dart

Dshell doctor version : 1.1.3

OS : linux OS Version : Linux 4.10.0-37-generic #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017 Path separator : /

dart version : 2.7.1 dart exe path : //bin/dart-sdk/bin/dart dart path : //bin/dart-sdk/bin/dart : //bin/dart-sdk/bin/dart dart2Native path : //bin/dart-sdk/bin/dart2native : //bin/dart-sdk/bin/dart2native

pub get path : //bin/dart-sdk/bin/pub : //bin/dart-sdk/bin/pub .pub-cache : //.pub-cache Package Config : Not Passed

PATH //bin/flutter/bin //bin/dart-sdk/bin //.pub-cache/bin //bin /snap/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/go/bin $SHELL : /bin/zsh True SHELL : nvim Shell Start Script : Not Found

Dart location(s) : /home/last/bin/dart-sdk/bin/dart

Permissions

.dshell/dependencies.yaml dshell : ^1.0.0 args : ^1.5.2 path : ^1.6.4

Script Details Name : rofi_bangs.dart Directory : //bin/scripts Virtual Project : //.dshell/cache//bin/scripts/rofi_bangs.project

Virtual pubspec.yaml name: rofi_bangs version: 1.0.0 dependencies: dshell: ^1.0.0 args: ^1.5.2 path: ^1.6.4

Dependencies : dshell : ^1.0.0 args : ^1.5.2 path : ^1.6.4

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/50?email_source=notifications&email_token=AAG32OCBSXSVEZHOJZPJKNTRA7ZIPA5CNFSM4KOPZ5UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKTL3BY#issuecomment-581352839, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32ODT5Q55CPFMU2UWZ23RA7ZIPANCNFSM4KOPZ5UA .

ram535 commented 4 years ago

I did the above. For some reason when running dshell compile foo.dart, it seems it cannot find the dshell package.

Created Virtual Project at /home/last/.dshell/cache/home/last/bin/scripts/foo.project
Running pub get...
Resolving dependencies...
+ args 1.5.2
+ charcode 1.1.2
+ collection 1.14.12
+ dshell 1.1.3
+ equatable 1.0.3
+ file 5.1.0
+ file_utils 0.1.4
+ globbing 0.3.0
+ intl 0.16.1
+ io 0.3.3
+ logger 0.8.3
+ matcher 0.12.6
+ meta 1.1.8
+ money2 1.3.0
+ path 1.6.4
+ pub_semver 1.4.2
+ pubspec 0.1.3
+ quiver 2.1.2+1
+ recase 3.0.0
+ source_span 1.6.0
+ stack_trace 1.9.3
+ string_scanner 1.0.5
+ term_glyph 1.1.0
+ uri 0.11.3+1
+ utf 0.9.0+5
+ yaml 2.2.0
Changed 26 dependencies!
../../../../../../../bin/scripts/foo.dart:2:8: Error: Not found: 'package:dshell/dshell.dart'
import 'package:dshell/dshell.dart';
       ^
../../../../../../../bin/scripts/foo.dart:14:11: Error: Getter not found: 'HOME'.
  print('$HOME');
          ^^^^
Error: Could not resolve the package 'dshell' in 'package:dshell/dshell.dart'.

Failed to generate native files:
Generating AOT kernel dill failed!

I created a pubspec.yalm in the directory where my scripts are and run dshell compile foo.dart.

Created Virtual Project at /home/last/.dshell/cache/home/last/bin/scripts/foo.project
Running pub get...
Resolving dependencies...
+ args 1.5.2
+ charcode 1.1.2
+ collection 1.14.12
+ dshell 1.1.3
+ equatable 1.0.3
+ file 5.1.0
+ file_utils 0.1.4
+ globbing 0.3.0
+ intl 0.16.1
+ io 0.3.3
+ logger 0.8.3
+ matcher 0.12.6
+ meta 1.1.8
+ money2 1.3.0
+ path 1.6.4
+ pub_semver 1.4.2
+ pubspec 0.1.3
+ quiver 2.1.2+1
+ recase 3.0.0
+ source_span 1.6.0
+ stack_trace 1.9.3
+ string_scanner 1.0.5
+ term_glyph 1.1.0
+ uri 0.11.3+1
+ utf 0.9.0+5
+ yaml 2.2.0
Changed 26 dependencies!

Unexpected object (Class with illegal cid, full-aot): 0x7f7e6c2155d1 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!

I see this is a really hard to figure it out error. This is not a function that I need. I just wanted to understand what was going on. If you want to continue debugging, I can keep continue testing. Or maybe is better focusing in other features and see if more people stumble with this error.

If you think I should make a report to google, I can do it. I will need guidance in what to say in the report.

bsutton commented 4 years ago

Could you retry compiling with the latest 1.8.2 and let me the know the results?

ram535 commented 4 years ago

I had to add pubspec.yaml in the working directory because it did not recognize or detected the one in ./dshell/......

When running dshell compile.

Compiling foo.dart...

Running pub get...
Resolving dependencies...
Got dependencies!

Unexpected object (Class with illegal cid, full-aot): 0x7f5b8beb8481 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!

I have been playing with dart:io and dart:convert and reproduced the scripts I did with dshell. There where no problems when using dart2native.

bsutton commented 4 years ago

@ram535 I've just released 1.8.3 and there is a chance that I've fixed this problem. Could you try again and let me know.

ram535 commented 4 years ago

The error still persist.

  dshell create test.dart

  cat test.dart
#! /usr/bin/env dshell

import 'package:dshell/dshell.dart';

void main() {
  print('$HOME');
}

  dshell compile test.dart

Compiling test.dart...

Waiting for clean to complete...
Running pub get...
Resolving dependencies...
Got dependencies!

Unexpected object (Class with illegal cid, full-aot): 0x7f3ceb67d6a1 Library:'dart:collection' Class: _CompactLinkedHashSet@3220832

Failed to generate native files:
Generating AOT snapshot failed!

  dshell doctor
Dshell doctor version    : 1.8.3

OS                       : linux
OS Version               : Linux 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020
Path separator           : /

dart version             : 2.7.1
dart exe path            : /<HOME>/bin/dart-sdk/bin/dart
dart path                : /<HOME>/bin/dart-sdk/bin/dart : /<HOME>/bin/dart-sdk/bin/dart
dart2Native path         : /<HOME>/bin/dart-sdk/bin/dart2native : /<HOME>/bin/dart-sdk/bin/dart2native

pub get path             : /<HOME>/bin/dart-sdk/bin/pub : /<HOME>/bin/dart-sdk/bin/pub
.pub-cache               : /<HOME>/.pub-cache
Package Config           : Not Passed

PATH
        /<HOME>/bin/cmake/bin
        /<HOME>/bin/jdk/bin
        /<HOME>/.pub-cache/bin
        /<HOME>/bin/dart-sdk/bin
        /<HOME>/bin/neovim
        /<HOME>/bin/emacs/bin
        /<HOME>/bin/alacritty
        /<HOME>/bin
        /usr/local/sbin
        /usr/local/bin
        /usr/sbin
        /usr/bin
        /sbin
        /bin
        /usr/games
        /usr/local/games
        /<HOME>/.fzf/bin
$SHELL                   : /bin/bash
True SHELL               : bash
Shell Start Script       : /<HOME>/.bashrc

Dart location(s)
                         : /home/last/bin/dart-sdk/bin/dart

Permissions

.dshell/dependencies.yaml
  dshell                 : dshell: ^1.0.0
  args                   : args: ^1.5.2
  path                   : path: ^1.6.4
bsutton commented 4 years ago

finally some good news on this one.

I've been able to reproduce the problem under windows and narrowed it down to inclusion of the logger package. I've now removed the logger package and can now compile under windows. I'm optimistic your issue is caused by the same problem. I've logged a bug report with google: https://github.com/google/dart_cli_pkg/issues/42

I will release 1.8.4 in the next week or so which includes a fix (I've removed the problematic package).

Thanks for your help on this one. Brett

bsutton commented 4 years ago

This is fixed in 1.8.4 which has now been released so closing out.

ram535 commented 4 years ago

Nice, I confirm the new fix solved the problem. Thanks.