onepub-dev / dcli

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

Unable to find the 'AppData' environmental variable error #64

Closed Tembocs closed 5 months ago

Tembocs commented 4 years ago

I tried installing dshell by doing pub global activate dshell which worked. I then did dshell install and got the following error message.

Exception occured: Unable to find the 'AppData' enviroment variable. Please ensure it is set and try again. of type DShellException
Unhandled exception:
FormatException: Invalid radix-10 number (at character 1)
/Users/<username>/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3...

I'm on Windows 10 x64 build 19035.1

The full error message is as seen below.

Hang on a tick whilst we install dshell.

Exception occured: Unable to find the 'AppData' enviroment variable. Please ensure it is set and try again. of type DShellException
Unhandled exception:
FormatException: Invalid radix-10 number (at character 1)
/Users/tembo/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3...
^

#0      int._throwFormatException (dart:core-patch/integers_patch.dart:133:5)
#1      int._parseRadix (dart:core-patch/integers_patch.dart:159:16)
#2      int._parse (dart:core-patch/integers_patch.dart:102:12)
#3      int.parse (dart:core-patch/integers_patch.dart:65:12)
#4      StackTraceImpl._extractFrames (package:dshell/src/util/stack_trace_impl.dart:148:33)        #5      StackTraceImpl.frames (package:dshell/src/util/stack_trace_impl.dart:103:17)
#6      StackTraceImpl.formatStackTrace (package:dshell/src/util/stack_trace_impl.dart:71:28)       #7      EntryPoint._parseCmdLine (package:dshell/src/script/entry_point.dart:52:36)
#8      EntryPoint.process (package:dshell/src/script/entry_point.dart:31:12)
#9      DShell.run (file:///C:/Users/tembo/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3/bin/dshell.dart:9:18)
#10     main (file:///C:/Users/tembo/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3/bin/dshell.dart:4:12)
#11     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#12     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
Hang on a tick whilst we install dshell.

Exception occured: Unable to find the 'AppData' enviroment variable. Please ensure it is set and try again. of type DShellException
Unhandled exception:
FormatException: Invalid radix-10 number (at character 1)
/Users/tembo/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3...
^

#0      int._throwFormatException (dart:core-patch/integers_patch.dart:133:5)
#1      int._parseRadix (dart:core-patch/integers_patch.dart:159:16)
#2      int._parse (dart:core-patch/integers_patch.dart:102:12)
#3      int.parse (dart:core-patch/integers_patch.dart:65:12)
#4      StackTraceImpl._extractFrames (package:dshell/src/util/stack_trace_impl.dart:148:33)        #5      StackTraceImpl.frames (package:dshell/src/util/stack_trace_impl.dart:103:17)
#6      StackTraceImpl.formatStackTrace (package:dshell/src/util/stack_trace_impl.dart:71:28)       #7      EntryPoint._parseCmdLine (package:dshell/src/script/entry_point.dart:52:36)
#8      EntryPoint.process (package:dshell/src/script/entry_point.dart:31:12)
#9      DShell.run (file:///C:/Users/tembo/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3/bin/dshell.dart:9:18)
#10     main (file:///C:/Users/tembo/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dshell-1.8.3/bin/dshell.dart:4:12)
#11     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#12     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
bsutton commented 4 years ago

Thanks for the bug report. I've not had access to a windows machine to test dshell but I will this weekend.

There are two errors here. Looks like a bug in the stack frame parser caused by the C: a the file name. This should be an easy fix. The primary error is that my env map is case sensitive.

I will have a fix for both by tomorrow.

Tembocs commented 4 years ago

Thanks for the bug report. I've not had access to a windows machine to test dshell but I will this weekend.

There are two errors here. Looks like a bug in the stack frame parser caused by the C: a the file name. This should be an easy fix. The primary error is that my env map is case sensitive.

I will have a fix for both by tomorrow.

Hi, any success on this?

bsutton commented 4 years ago

I've fixed the bugs you reported but I'm still working through a few more I discovered along the way. Currently in battling with getting the unit tests to work and poor connectivity as I'm traveling. Probably another day before I get everything nailed down.

On Sun, 8 Mar 2020, 7:00 am Tembo, notifications@github.com wrote:

Thanks for the bug report. I've not had access to a windows machine to test dshell but I will this weekend.

There are two errors here. Looks like a bug in the stack frame parser caused by the C: a the file name. This should be an easy fix. The primary error is that my env map is case sensitive.

I will have a fix for both by tomorrow.

Hi, any success on this?

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

Tembocs commented 4 years ago

Thank you. I've a Windows machine so will re-install dshell once you have updated the published version on pub.dev.

brad-jones commented 4 years ago

@bsutton any chance you could push your WIP fixes to a branch. Keen to see if I can integrate dshell with a dartlang task runner framework I am in the middle of building. But I too have to deal with the unpleasantries of a Windows system at my day job.

bsutton commented 4 years ago

I will push the code tonight (about 10hrs from now).

nlhnt commented 4 years ago

Cool to see the updates, I am dealing with the same issue.

bsutton commented 4 years ago

So I've made a fair amount of progress on this but its not there as yet. At this point I still can't get a full run of the unit tests to pass under Windows. This is essentially a path issue so I don't think I'm too far from having it done.

I will push a new dev release to pub.dev but I don't know how successful you will be running it.

To get the dev version run: pub global activate dshell 1.8.4-dev.3

I'm hoping to have the remaining issues cleaned up tomorrow night. I've now get a windows vm running on my dev box so testing should run fairly smoothly.

bsutton commented 4 years ago

I've just pushed another release to pub.dev pub global activate dshell 1.8.4-dev.4

Unit tests are still not passing but looks to be an artifact of the unit tests rather than a dshell problem. I can't promise this version will work but it now has a reasonable chance.

Tembocs commented 4 years ago

I've just installed dshell 1.8.4-dev.4 successful. I have created a simple dshell script:

#! /usr/bin/env dshell.bat

import 'dart:io';
import 'package:dshell/dshell.dart';

/// dshell script generated by:
/// dshell create main.dart
/// 
/// See 
/// https://pub.dev/packages/dshell#-installing-tab-
/// 
/// For details on installing dshell.
/// 

void main() {
  print('Hello World');
  print('First script!');
}

Running dshell main.dart gives the following error message:

Exception occured: Unable to create the directory C:\Users\<username>\AppData\Roaming\.dshell\cache\:\users\<username>\desktop\qnd\dart\learn-dshell. Error: FileSystemException: Exists failed, path = 'C:\Users\<username>\AppData\Roaming\.dshell\cache\:\users\tembo\desktop\qnd\dart\learn-dshell' (OS Error: The filename, directory name, or volume label syntax is incorrect.
, errno = 123) of type FunctionException
Stacktrace: with_lock.dart : NamedLock.withLock.<anonymous closure> : 115
zone.dart : runZoned : 1505
with_lock.dart : NamedLock.withLock : 86
virtual_project.dart : VirtualProject.build : 297
run.dart : RunCommand.run : 44
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

I'm on Windows 10 x64 build 19035.1.

bsutton commented 4 years ago

I'm at my day job right now, but will be able to have a look tonight (about 8 hrs). I'm hoping to get all of the unit tests passing tonight and I think I understand the source of your error so it shouldn't be to hard to fix.

Will post an update when I have a new release with a fix.

On Wed, 11 Mar 2020 at 09:03, Tembo notifications@github.com wrote:

I've just installed dshell 1.8.4-dev.4 successful. I have created a simple dshell script:

! /usr/bin/env dshell.bat

import 'dart:io'; import 'package:dshell/dshell.dart';

/// dshell script generated by: /// dshell create main.dart /// /// See /// https://pub.dev/packages/dshell#-installing-tab- /// /// For details on installing dshell. ///

void main() { print('Hello World'); print('First script!'); }

Running dshell main.dart gives the following error message:

Exception occured: Unable to create the directory C:\Users\\AppData\Roaming.dshell\cache\:\users\\desktop\qnd\dart\learn-dshell. Error: FileSystemException: Exists failed, path = 'C:\Users\\AppData\Roaming.dshell\cache\:\users\tembo\desktop\qnd\dart\learn-dshell' (OS Error: The filename, directory name, or volume label syntax is incorrect. , errno = 123) of type FunctionException Stacktrace: with_lock.dart : NamedLock.withLock. : 115 zone.dart : runZoned : 1505 with_lock.dart : NamedLock.withLock : 86 virtual_project.dart : VirtualProject.build : 297 run.dart : RunCommand.run : 44 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

I'm on Windows 10 x64 build 19035.1.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/64?email_source=notifications&email_token=AAG32OCPU6RTEBO2MLOZYL3RG22MNA5CNFSM4LCQVJXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEONK5FQ#issuecomment-597339798, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OBNNXX2NNOTUUQQIPLRG22MNANCNFSM4LCQVJXA .

bsutton commented 4 years ago

I've just pushed a release that looks to be reasonably coherent. I'm still seeing over half the unit tests fail but basic command line actions are working and the core library should be in a fairly good start. I will keep working through the unit tests to resolve the remaining problems many of which are test artefacts as apposed to real bug.

The new release is: dshell 1.8.4-dev.6

bsutton commented 4 years ago

And now another release: The new release is: dshell 1.8.4-dev.7

The main change here is that I now suppress glob expansion (wildcards) as powershell normally doesn't expand globs so when dshell does powershell commands get confused. I'm done for the night, will tackle some more unit tests tomorrow night.

Tembocs commented 4 years ago

Thanks for the hard work. I've just installed dshell 1.8.4-dev.7. To run dshell create <filename.dart> one need administrator privilege, is this by design? Running ./created_filename.dart on PowerShell terminal pops a dialog asking on how you want to open this file.

bsutton commented 4 years ago

The shebang doesnt work on windows so at the moment you need to use dshell explicitly.

dshell created_file.dart

I'm investigating ways of removing the need to use the command with dshell.

You shouldnt need admin privileges to create a script.

Did you run dshell install as an admin? Under Linux if you run install as root you end up with the pub cache having the wrong permissions I'm wondering if you have a similar problem?

Can you run dshell doctor and post the results.

On Thu, 12 Mar 2020, 4:31 am Tembo, notifications@github.com wrote:

Thanks for the hard work. I've just installed dshell 1.8.4-dev.7. To run dshell create one need administrator privilege, is this by design? Running ./created_filename.dart on PowerShell terminal pops a dialog asking on how you want to open this file.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bsutton/dshell/issues/64#issuecomment-597767135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OAAUWYTBDLAADF2KMDRG7DHNANCNFSM4LCQVJXA .

bsutton commented 4 years ago

@Tembocs I think I've been doing all of my testing as admin under powershell. As such I'm not certain on what the issue is. I will run some tests tonight and see if I can find out what's causing the admin rights requirements. What error are you getting when you try to create a script without admin rights?

Also maybe you can help. Do you know how to create a file association for a powershell script? If found a couple of possible solutions: 1) use assoc command from the cmd shell. But this only seems to work for scripts run via cmd and it pops a window open asking for confirmation. 2) I found a global powershell script (which I can't find right now) that works a bit like .bashrc, but this felt a little invasive.

Also am I making a reasonable assumption that most admins are using powershell rather then cmd for their daily cli work?

I've not used windows for about 15 years so I'm rather out of the loop on current practices.

bsutton commented 5 months ago

closed as stale - and I think it has been resolved.