tekartik / process_run.dart

Process run helper
BSD 2-Clause "Simplified" License
200 stars 20 forks source link

ProcesException: Permissino denied #21

Open glennmichaelmejias opened 4 years ago

glennmichaelmejias commented 4 years ago

i want to install and able to run git on my flutter app.

Unhandled Exception: ShellException(git, error: ProcessException: Permission denied E/flutter ( 1432): Command: git , workingDirectory: /) E/flutter ( 1432): #0 Shell.runExecutableArguments (package:process_run/shell.dart:297:7)

alextekartik commented 4 years ago

Thanks for the report. Can you specify on which platform you are (MacOS requires some xcode setting to allow spawning binaries) to see how I can reproduce the issus? This simple test works for me (event run inside a flutter app:

import 'package:process_run/shell.dart';

Future main() async {
  var shell = Shell();
  await shell.run('git --version');
}

Make sure you using the latest version of process_run. It seems you are using / as the working directory which could be the issue too.

glennmichaelmejias commented 4 years ago

@alextekartik thanks for reply. how to change working directory?

alextekartik commented 4 years ago

There is a working directory argument in Shell.

// Specify a directory
var shell = Shell(workingDirectory: '/home');

// Change directory
shell = shell.cd('/other_dir');
glennmichaelmejias commented 4 years ago

i am using flutter in android

here is my full code

import 'package:process_run/shell.dart';

import 'package:flutter/material.dart';

class TerminalWindow extends StatefulWidget {
  @override
  _TerminalWindowState createState() => _TerminalWindowState();
}

class _TerminalWindowState extends State<TerminalWindow> {

  @override
  void initState() {
    // TODO: implement initState

    super.initState();

  }

  void onInput(String input) {
    print('input: $input');

  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blueGrey,

      floatingActionButton: FloatingActionButton(
        onPressed: (){

         testing();

        },
      ),
    );
  }
}

void testing()async{
 var shell = Shell(workingDirectory: "/home");
  await shell.run('git --version');
}

when i try to run it says

 [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: ShellException(git --version, error: ProcessException: No such file or directory
E/flutter (10839):   Command: git --version, workingDirectory: /home)
E/flutter (10839): #0      Shell.runExecutableArguments (package:process_run/shell.dart:297:7)
alextekartik commented 4 years ago

Some questions:

glennmichaelmejias commented 4 years ago
alextekartik commented 4 years ago

i am using android

Ok that's the reason, there is no git client on Android

i don't know, where should i put working directory

Use path_provider to get a correct location

glennmichaelmejias commented 4 years ago

okay thank you. can i use apt get install git? i want to create a window similar to termux

alextekartik commented 4 years ago

can i use apt get install git?

I don't think so. Although android based on Linux I don't think you have access to any debian install tool

glennmichaelmejias commented 4 years ago

what if i will put the executables on the directory that i can access? and run it with ./git is it possible?

alextekartik commented 4 years ago

what if i will put the executables on the directory that i can access? and run it with ./git is it possible?

Yes.

glennmichaelmejias commented 4 years ago

okay thank you so much. i will try.

arzakmiftakhul commented 2 years ago

How about this issue? I can run some scripts just using await shell.run() on Lineage OS for raspberry pi 4 (konstakang) without working directory setting. But I can't use it on Android 9 for Radxa Zero. It always show the error

E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: ShellException(dart --version, error: ProcessException: Permission denied
      Command: dart --version, workingDirectory: /)

Which working directory should it be? Even just run simple script await shell.run("ls"), I got same error.

alextekartik commented 2 years ago

I'm don't think you can run any system command on Android for security reason. You might be able to bundle an executable then extract it in a folder you have write access to (use path_provider to find the location) and run it from here. However this package mainly target Desktop (as mentioned in the README.md) and I never tested on mobile yet.

arzakmiftakhul commented 2 years ago

I'm don't think you can run any system command on Android for security reason. You might be able to bundle an executable then extract it in a folder you have write access to (use path_provider to find the location) and run it from here. However this package mainly target Desktop (as mentioned in the README.md) and I never tested on mobile yet.

Thanks for this great library. I've installed Lineage OS android 11 on raspberry 4 from Konstakang. I can run system command for example copy/move file from Document folder to connected flash disk, check device temperature, reboot device, etc. But I get an error when I run on Radxa Zero device. Both were rooted devices.