onepub-dev / dcli

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

Creating script... CopyException: The 'to' directory /home/user/bin/bin does not exists. #178

Closed whoizit closed 2 years ago

whoizit commented 2 years ago

I am trying to create a script in the bin directory. The bin directory already exist.

~ > pwd
/home/user
~ > dcli create bin/spawn.dart
Creating script...
CopyException: The 'to' directory /home/user/bin/bin does not exists. 
Stacktrace: wait_for_ex.dart : waitForEx : 62
copy.dart : copy : 28
dart_project.dart : DartProject._createFromTemplate : 308
dart_project.dart : DartProject.createScript : 370
create.dart : CreateCommand.run : 63
command_line_runner.dart : CommandLineRunner.process : 86
entry_point.dart : EntryPoint._parseCmdLine : 35
entry_point.dart : EntryPoint.process : 30
dcli.dart : DCli.run : 13
dcli.dart : main : 8
bsutton commented 2 years ago

The fact that you get a stack trace is a bug however I note your path has bin/bin

Do you actually have a bin directory within a bin directory?

The dcli create command expects the directory to already exists.

whoizit commented 2 years ago

no, nothing in this path

~ > \ls -l ~/bin/bin                                                                                                ± master | 23 Nov 22:39:31 (2)
/usr/bin/ls: cannot access '/home/user/bin/bin': No such file or directory
whoizit commented 2 years ago

this issue still not fixed. I run command dcli create bin/spawn.dart in /home/user directory, but it trying create script in /home/user/bin/bin/ directory, ofcourse this directory not exists

whoizit commented 2 years ago

to reproduce:

~ > dart pub global activate -sgit https://github.com/noojee/dcli.git
...
~ > mkdir -p ~/tmp/bin
~ > cd ~/tmp
~/tmp > \ls -lA bin
total 0
~/tmp > dcli create bin/test.dart 
Creating script...
CopyException: The 'to' directory /home/user/tmp/bin/bin does not exists. 
Stacktrace: wait_for_ex.dart : waitForEx : 62
copy.dart : copy : 28
dart_project.dart : DartProject._createFromTemplate : 308
dart_project.dart : DartProject.createScript : 370
create.dart : CreateCommand.run : 63
command_line_runner.dart : CommandLineRunner.process : 86
entry_point.dart : EntryPoint._parseCmdLine : 35
entry_point.dart : EntryPoint.process : 30
dcli.dart : DCli.run : 13
dcli.dart : main : 8

i've expect to create file /home/user/tmp/bin/test.dart

bsutton commented 2 years ago

The problem is that you are already in the bin directory.

Cd to the project root and the command will succeed.

On Wed, 24 Nov 2021, 7:39 am whoami, @.***> wrote:

to reproduce:

~ > dart pub global activate -sgit https://github.com/noojee/dcli.git ... ~ > mkdir -p ~/tmp/bin ~ > cd ~/tmp ~/tmp > \ls -lA bin total 0 ~/tmp > dcli create bin/test.dart Creating script... CopyException: The 'to' directory /home/user/tmp/bin/bin does not exists. Stacktrace: wait_for_ex.dart : waitForEx : 62 copy.dart : copy : 28 dart_project.dart : DartProject._createFromTemplate : 308 dart_project.dart : DartProject.createScript : 370 create.dart : CreateCommand.run : 63 command_line_runner.dart : CommandLineRunner.process : 86 entry_point.dart : EntryPoint._parseCmdLine : 35 entry_point.dart : EntryPoint.process : 30 dcli.dart : DCli.run : 13 dcli.dart : main : 8

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/noojee/dcli/issues/178#issuecomment-977151272, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OGNCYUHQIRKGS2B3NLUNP3WJANCNFSM5ITWU4PA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

bsutton commented 2 years ago

try the latest version of dcli. You should now get a neat message rather than a stack trace.

You should be doing

mkdir /home/user/bin
cd /home/user
create bin/spawn.dart

I believe that your problem is caused by you doing the following:

mkdir /home/user/bin
cd /home/user/bin
create bin/spawn.dart

Note the difference in the middle line. If this still doesn't work then place post the output of

dcli doctor

dcli -v create bin/spawn.dart

S. Brett Sutton Noojee Contact Solutions 03 8320 8100

On Wed, 24 Nov 2021 at 06:52, whoami @.***> wrote:

this issue still not fixed. I run command dcli create bin/spawn.dart in /home/user directory, but it trying create script in /home/user/bin/bin/ directory, ofcourse this directory not exists

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/noojee/dcli/issues/178#issuecomment-977093131, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32ODGVGBGRBNEKGXZTV3UNPWJBANCNFSM5ITWU4PA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

whoizit commented 2 years ago
~ > dcli version
Dcli Version: 1.13.3, Located at: /home/user/.pub-cache/bin/dcli
~ > ls -ld bin
drwxr-xr-x 7 user user 12288 Nov 24 10:53 bin
~ > ls -ld bin/spawn.dart
/usr/bin/ls: cannot access 'bin/spawn.dart': No such file or directory
~ > pwd
/home/user
~ > dcli create bin/spawn.dart
Creating script...
CopyException: The 'to' directory /home/user/bin/bin does not exists. 
Stacktrace: wait_for_ex.dart : waitForEx : 62
copy.dart : copy : 28
dart_project.dart : DartProject._createFromTemplate : 308
dart_project.dart : DartProject.createScript : 370
create.dart : CreateCommand.run : 63
command_line_runner.dart : CommandLineRunner.process : 86
entry_point.dart : EntryPoint._parseCmdLine : 35
entry_point.dart : EntryPoint.process : 30
dcli.dart : DCli.run : 13
dcli.dart : main : 8
~ > dcli doctor
DCli version      1.13.3                                                 

OS                linux                                                  
OS version        Linux 5.15.0-pf2 #1 SMP PREEMPT Sun, 21 Nov 2021 17:44:10 +0000
path separator    /                                                      

dart version      2.14.4                                                 

dcli path         /<HOME>/.pub-cache/bin/dcli                            
dart exe path     /opt/flutter/bin/dart                                  
dart path         /opt/flutter/bin/dart                                   which: /opt/flutter/bin/dart                           
compiler          using 'dart compile exe'                               

pub               using 'dart pub'                                       

pub cache         /<HOME>/.pub-cache                                     
PUB_CACHE Env     false                                                  

package config    /<HOME>/not passed                                     

PATH
                  /<HOME>/.local/bin                                     
                  /usr/local/sbin                                        
                  /usr/local/bin                                         
                  /usr/bin                                               
                  /<HOME>/.local/share/flatpak/exports/bin               
                  /var/lib/flatpak/exports/bin                           
                  /opt/flutter/bin                                       
                  /usr/lib/jvm/default/bin                               
                  /usr/bin/site_perl                                     
                  /usr/bin/vendor_perl                                   
                  /usr/bin/core_perl                                     
                  /usr/lib/plan9/bin                                     
                  /<HOME>/bin                                            
                  /<HOME>/.pub-cache/bin                                 
                  /<HOME>/.dcli/bin                                      
                  /<HOME>/.cargo/bin                                     
                  /<HOME>/.asdf/shims                                    
                  /<HOME>/.go/bin                                        
                  /<HOME>/.poetry/bin                                    

Shell Settings
$SHELL            /bin/zsh                                               
detected          zsh                                                    
Start script      /<HOME>/.zshrc                                         

dart location(s)
                  /opt/flutter/bin/dart                                  

permissions
HOME              rwx------ <user>:<user> /<HOME> 
.dcli             (guid) rw <user>:<user> /<HOME>/.dcli 
templates         (guid) rw <user>:<user> /<HOME>/.dcli/templates 
pub cache         (guid) rw <user>:<user> /<HOME>/.pub-cache 
~ > pwd
/home/user
~ > dcli -v create bin/spawn.dart
Setting flag: verbose
DCli Version: 1.13.3
Found command Instance of 'CreateCommand'
Creating script...
DartProject.fromPath: /home/user/bin
CopyException: The 'to' directory /home/user/bin/bin does not exists. 
Stacktrace: wait_for_ex.dart : waitForEx : 62
copy.dart : copy : 28
dart_project.dart : DartProject._createFromTemplate : 308
dart_project.dart : DartProject.createScript : 370
create.dart : CreateCommand.run : 63
command_line_runner.dart : CommandLineRunner.process : 86
entry_point.dart : EntryPoint._parseCmdLine : 35
entry_point.dart : EntryPoint.process : 30
dcli.dart : DCli.run : 13
dcli.dart : main : 8
~ > 
bsutton commented 2 years ago

OK, apologies I doubted you.

I've now managed to reproduce it and fix the problem.

I've just published 1.13.4 which fixes the problem.