diff --git a/compiler/main.v b/compiler/main.v index e9b994c758..64d2e1d6b9 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -782,7 +782,15 @@ fn new_v(args[]string) *V { println('Setting VROOT to "$lang_dir".') os.write_file(TmpPath + '/VROOT', lang_dir) } else { - println('Please do it from "v/compiler" directory.') + println('V repo not found. Cloning...') + os.mv('v', 'v.bin') + os.system('git clone https://github.com/vlang/v') + if !os.dir_exists('v') { + println('failed to clone github.com/vlang/v') + exit(1) + } + os.mv('v.bin', 'v/compiler/v') + println('Re-launch V from v/compiler') exit(1) } } diff --git a/os/os.v b/os/os.v index e4dfa7fb01..5f21eb38c8 100644 --- a/os/os.v +++ b/os/os.v @@ -84,6 +84,10 @@ pub fn file_size(path string) int { return 0 } +pub fn mv(old, new string) { + C.rename(old.cstr(), new.cstr()) +} + pub fn file_last_mod_unix(path string) int { # struct stat attr; # stat(path.str, &attr);